xen-vtx-unstable

view xen/arch/x86/string.c @ 6774:4d899a738d59

merge?
author cl349@firebug.cl.cam.ac.uk
date Tue Sep 13 15:05:49 2005 +0000 (2005-09-13)
parents ddd290cc8f0d
children
line source
1 /******************************************************************************
2 * string.c
3 *
4 * These provide something for compiler-emitted string operations to link
5 * against.
6 */
8 #include <xen/config.h>
9 #include <xen/lib.h>
11 #undef memcpy
12 void *memcpy(void *dest, const void *src, size_t n)
13 {
14 int d0, d1, d2;
16 __asm__ __volatile__ (
17 " rep ; movsl ; "
18 " testb $2,%b4 ; "
19 " je 1f ; "
20 " movsw ; "
21 "1: testb $1,%b4 ; "
22 " je 2f ; "
23 " movsb ; "
24 "2: "
25 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
26 : "0" (n/4), "q" (n), "1" (dest), "2" (src)
27 : "memory");
29 return dest;
30 }
32 #undef memset
33 void *memset(void *s, int c, size_t n)
34 {
35 int d0, d1;
37 __asm__ __volatile__ (
38 "rep ; stosb"
39 : "=&c" (d0), "=&D" (d1)
40 : "a" (c), "1" (s), "0" (n)
41 : "memory");
43 return s;
44 }
46 #undef memmove
47 void *memmove(void *dest, const void *src, size_t n)
48 {
49 int d0, d1, d2;
51 if ( dest < src )
52 return memcpy(dest, src, n);
54 __asm__ __volatile__ (
55 " std ; "
56 " rep ; movsb ; "
57 " cld "
58 : "=&c" (d0), "=&S" (d1), "=&D" (d2)
59 : "0" (n), "1" (n-1+(const char *)src), "2" (n-1+(char *)dest)
60 : "memory");
62 return dest;
63 }