ia64/xen-unstable

changeset 4598:bfda446f80cb

bitkeeper revision 1.1343 (42669573FPZbSiupGqFkPopp_NRfpA)

Make the fallback memset/memcpy/memmove have a concrete in-place
implementation, or we end up with a recursive dependency when building
for x86/64.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Apr 20 17:46:27 2005 +0000 (2005-04-20)
parents 159c47d556ef
children ebe62f849001
files xen/arch/x86/string.c
line diff
     1.1 --- a/xen/arch/x86/string.c	Wed Apr 20 14:29:18 2005 +0000
     1.2 +++ b/xen/arch/x86/string.c	Wed Apr 20 17:46:27 2005 +0000
     1.3 @@ -9,19 +9,55 @@
     1.4  #include <xen/lib.h>
     1.5  
     1.6  #undef memmove
     1.7 -void *memmove(void *dest, const void *src, size_t count)
     1.8 +void *memmove(void *dest, const void *src, size_t n)
     1.9  {
    1.10 -    return __memmove(dest, src, count);
    1.11 +    int d0, d1, d2;
    1.12 + 
    1.13 +    if ( dest < src )
    1.14 +        return memcpy(dest, src, n);
    1.15 +
    1.16 +    __asm__ __volatile__ (
    1.17 +        "   std         ; "
    1.18 +        "   rep ; movsb ; "
    1.19 +        "   cld           "
    1.20 +        : "=&c" (d0), "=&S" (d1), "=&D" (d2)
    1.21 +        : "0" (n), "1" (n-1+(const char *)src), "2" (n-1+(char *)dest)
    1.22 +        : "memory");
    1.23 +
    1.24 +    return dest;
    1.25  }
    1.26  
    1.27  #undef memcpy
    1.28 -void *memcpy(void *dest, const void *src, size_t count)
    1.29 +void *memcpy(void *dest, const void *src, size_t n)
    1.30  {
    1.31 -    return __memcpy(dest, src, count);
    1.32 +    int d0, d1, d2;
    1.33 +
    1.34 +    __asm__ __volatile__ (
    1.35 +        "   rep ; movsl      ; "
    1.36 +        "   testb $2,%b4     ; "
    1.37 +        "   je 1f            ; "
    1.38 +        "   movsw            ; "
    1.39 +        "1: testb $1,%b4     ; "
    1.40 +        "   je 2f            ; "
    1.41 +        "   movsb            ; "
    1.42 +        "2:                    "
    1.43 +        : "=&c" (d0), "=&D" (d1), "=&S" (d2)
    1.44 +        : "0" (n/4), "q" (n), "1" (dest), "2" (src)
    1.45 +        : "memory");
    1.46 +
    1.47 +    return dest;
    1.48  }
    1.49  
    1.50  #undef memset
    1.51 -void *memset(void *s, int c, size_t count)
    1.52 +void *memset(void *s, int c, size_t n)
    1.53  {
    1.54 -    return __memset(s, c, count);
    1.55 +    int d0, d1;
    1.56 +
    1.57 +    __asm__ __volatile__ (
    1.58 +        "rep ; stosb"
    1.59 +        : "=&c" (d0), "=&D" (d1)
    1.60 +        : "a" (c), "1" (s), "0" (n)
    1.61 +        : "memory");
    1.62 +
    1.63 +    return s;
    1.64  }