⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libfbx-memset.c

📁 libfxb是linux下只写操作framebuffer的一个轻量级的库。
💻 C
字号:
/* *  libfbx-memset.c -- Optimized memset() routines. *  (C)opyright 2000-2001 U4X Labs * *  Written by: Paul Mundt <lethal@u4xlabs.com> *              Sat Sep 30 04:42:23 EDT 2000 * *  $Id: libfbx-memset.c,v 1.10 2001/02/11 06:00:31 lethal Exp $ * *  	All architecture specific memset() routines are located *  here. As well as a general purpose 16bit if no architecture *  specific one is available. * *  See ChangeLog for modifications, CREDITS for credits. * *  All source herein is copyright U4X Labs and its original author.  *  Any code modifications or additions are (C)opyright the original  *  author and U4X Labs respectively. * *  libfbx is free software; you can redistribute it and/or modify it  *  under the terms of the GNU Lesser General Public License as  *  published by the Free Software Foundation; either version 2.1 of  *  the License, or (at your option) any later version. * *  libfbx is distributed in the hope that it will be useful, but  *  WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  *  GNU Lesser General Public License for more details. * *  You should have received a copy of the GNU Lesser General Public *  License along with libfbx; if not, write to the Free Software  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *  USA */#include <libfbx/libfbx-arch.h>#include <linux/types.h>#include <config.h>#if defined(__mips__)static inline void *fb_arch_memset(void *s, int c, size_t n){	__asm__ __volatile__ (		"la\t$8,%0\n\t"		"lb\t$9,%1\n\t"		"lb\t$10,%2\n\t"		"loop:\n\t"		"sb\t$9,0($8)\n\t"		"add\t$8,$8,1\n\t"		"sub\t$10,$10,1\n\t"		"beqz\t$10,exit\n\t"		"j\tloop\n\t"		"exit:\n\t"		:		: "g" (s), "g" (c), "g" (n)                : "$8", "$9", "$10", "memory"	);}#elif defined(__i386__)static inline void *fb_arch_memset(void *s, int c, size_t n){	int d0, d1;	__asm__ __volatile__(		"cld\n\t"		"rep ; stosl\n\t"		"testb $2,%b3\n\t"		"je 1f\n\t"		"stosw\n"		"1:\ttestb $1,%b3\n\t"		"je 2f\n\t"		"stosb\n"		"2:"		: "=&c" (d0), "=&D" (d1)		: "a" (c), "q" (n), "0" (n/4), "1" ((long) s)		: "memory"	);			return s;}#elif defined(__superh__)static inline void *fb_arch_memset(void *s, int c, size_t n){	__asm__ __volatile__ (		"tst\tr6,r6\n"		"bt/s\t5f\n"	 	"add\tr6,r4\n"		"mov\t#12,r0\n"		"cmp/gt\tr6,r0\n"		"bt/s\t4f\n"	 	"mov\tr4,r0\n"		"and\t#3,r0\n"		"cmp/eq\t#0,r0\n"		"bt/s\t2f\n"		"sub\tr0,r6\n"		"1:\n"		"dt\tr0\n"		"bf/s\t1b\n"		"mov.b\tr5,@-r4\n"		"2:\n"		"swap.b\tr5,r0\n"		"or\tr0,r5\n"		"swap.w\tr5,r0\n"		"or\tr0,r5\n"		"mov\tr6,r0\n"		"shlr2\tr0\n"		"shlr\tr0\n"		"3:\n"		"dt\tr0\n"		"mov.l\tr5,@-r4\n"		"bf/s\t3b\n"		"mov.l\tr5,@-r4\n"		"mov\t#7,r0\n"		"and\tr0,r6\n"		"tst\tr6,r6\n"		"bt\t5f\n"		"4:\n"		"dt\tr6\n"		"bf/s\t4b\n"	 	"mov.b\tr5,@-r4\n"		"5:\n"		"rts\n"		"mov\tr4,r0\n"		:		: "a" (c), "q" (n), "0" (n/4), "1" ((long)s)		: "memory"	);	return s;}#elsestatic inline void *fb_arch_memset(void *s, int c, size_t n){  	while ((__u32)n--)		*(__u16 *)s++ = (__u16)c;		return s;}#endifinline void *fb_memset(void *s, int c, size_t n){	return fb_arch_memset(s, c, n);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -