📄 libfbx-memmove.c
字号:
/* * libfbx-memmove.c -- Intel Compatible ASM Optimizations * (C)opyright 2000-2001 U4X Labs * * Updated by: Michael Bourgeous <nitrogen@u4xlabs.com> * Paul Mundt <lethal@u4xlabs.com> * Sat Oct 14 15:13:22 MDT 2000 * * $Id: libfbx-memmove.c,v 1.4 2001/01/01 08:46:17 lethal Exp $ * * Architecture Optimized Routines for i386, i486, * i586, MMX, 3DNow, and compatible processors. * * 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 <stdio.h>#include <linux/types.h>#include <string.h>#if defined(__i386__)static inline void *fb_arch_memmove(void *d, const void *s, size_t count){ int d0, d1, d2, d3; if (d < s) { __asm__ __volatile__ ( "cld\n\t" "shrl $1,%%ecx\n\t" "jnc 1f\n\t" "movsb\n" "1:\tshrl $1,%%ecx\n\t" "jnc 2f\n\t" "movsw\n" "2:\trep\n\t" "movsl" : "=&c" (d0), "=&D" (d1), "=&S" (d2) :"0"(count),"1"((long)d),"2"((long)s) :"memory" ); } else { __asm__ __volatile__ ( "std\n\t" "shrl $1,%%ecx\n\t" "jnc 1f\n\t" "movb 3(%%esi),%%al\n\t" "movb %%al,3(%%edi)\n\t" "decl %%esi\n\t" "decl %%edi\n" "1:\tshrl $1,%%ecx\n\t" "jnc 2f\n\t" "movw 2(%%esi),%%ax\n\t" "movw %%ax,2(%%edi)\n\t" "decl %%esi\n\t" "decl %%edi\n\t" "decl %%esi\n\t" "decl %%edi\n" "2:\trep\n\t" "movsl\n\t" "cld" : "=&c" (d0), "=&D" (d1), "=&S" (d2), "=&a" (d3) :"0"(count),"1"(count-4+(long)d),"2"(count-4+(long)s) :"memory" ); } return d;}#elsestatic inline void *fb_arch_memmove(void *d, const void *s, size_t count){ return memmove(d, s, count);}#endif /* __i386__ */inline void *fb_memmove(void *d, const void *s, size_t count){ return fb_arch_memmove(d, s, count);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -