# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1186754469 -3600
# Node ID 8c77ae93f9823f0ed64807b8bfa20c0dadb975d3
# Parent 95f90f24f3b1f33f911d3e9a01cb1d7bce5b29e0
x86: Improved memcpy() asm implementation.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
xen/arch/x86/string.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff -r 95f90f24f3b1 -r 8c77ae93f982 xen/arch/x86/string.c
--- a/xen/arch/x86/string.c Thu Aug 09 16:21:41 2007 +0100
+++ b/xen/arch/x86/string.c Fri Aug 10 15:01:09 2007 +0100
@@ -11,10 +11,18 @@
#undef memcpy
void *memcpy(void *dest, const void *src, size_t n)
{
- int d0, d1, d2;
+ long d0, d1, d2;
__asm__ __volatile__ (
- " rep ; movsl ; "
+#ifdef __i386__
+ " rep movsl ; "
+#else
+ " rep movsq ; "
+ " testb $4,%b4 ; "
+ " je 0f ; "
+ " movsl ; "
+ "0: ; "
+#endif
" testb $2,%b4 ; "
" je 1f ; "
" movsw ; "
@@ -23,7 +31,7 @@ void *memcpy(void *dest, const void *src
" movsb ; "
"2: "
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
- : "0" (n/4), "q" (n), "1" (dest), "2" (src)
+ : "0" (n/sizeof(long)), "q" (n), "1" (dest), "2" (src)
: "memory");
return dest;
@@ -32,10 +40,10 @@ void *memcpy(void *dest, const void *src
#undef memset
void *memset(void *s, int c, size_t n)
{
- int d0, d1;
+ long d0, d1;
__asm__ __volatile__ (
- "rep ; stosb"
+ "rep stosb"
: "=&c" (d0), "=&D" (d1)
: "a" (c), "1" (s), "0" (n)
: "memory");
@@ -46,14 +54,14 @@ void *memset(void *s, int c, size_t n)
#undef memmove
void *memmove(void *dest, const void *src, size_t n)
{
- int d0, d1, d2;
+ long d0, d1, d2;
if ( dest < src )
return memcpy(dest, src, n);
__asm__ __volatile__ (
" std ; "
- " rep ; movsb ; "
+ " rep movsb ; "
" cld "
: "=&c" (d0), "=&S" (d1), "=&D" (d2)
: "0" (n), "1" (n-1+(const char *)src), "2" (n-1+(char *)dest)
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|