1 /* 2 * NOTE!!! memcpy(dest,src,n) assumes ds=es=normal data segment. This 3 * goes for all kernel functions (ds=es=kernel space, fs=local data, 4 * gs=null), as well as for all well-behaving user programs (ds=es= 5 * user data space). This is NOT a bug, as any user program that changes 6 * es deserves to die if it isn't careful. 7 */ 8 #if 0
9 #definememcpy(dest,src,n) ({ \
10 void * _res = dest; \
11 __asm____volatile__ ("cld;rep;movsb" \
12 ::"D" ((long)(_res)),"S" ((long)(src)),"c" ((long) (n)) \
13 :"di","si","cx"); \
14 _res; \
15 })
16 #else 17
18 /* this is basically memcpy_tofs. It should be faster. 19 I've reorder it. This should be a little faster. -RAB */ 20
21 #definememcpy(dest, src, n) f_memcpy(dest, src, n)
22 externinlinevoid * f_memcpy(void * to, void * from, unsignedlongn)
/* */ 23 { 24 __asm__("cld\n\t"
25 "movl %%edx, %%ecx\n\t"
26 "shrl $2,%%ecx\n\t"
27 "rep ; movsl\n\t"
28 "testb $1,%%dl\n\t"
29 "je 1f\n\t"
30 "movsb\n"
31 "1:\ttestb $2,%%dl\n\t"
32 "je 2f\n\t"
33 "movsw\n"
34 "2:\n"
35 ::"d" (n),"D" ((long) to),"S" ((long) from)
36 : "cx","di","si");
37 return (to);
38 } 39 #endif