[PATCH 3/3] x86, boot: merge memcpy()

From: Brian Gerst
Date: Sat Feb 26 2011 - 12:54:29 EST


Merge the 32-bit and 64-bit memcpy functions.

Signed-off-by: Brian Gerst <brgerst@xxxxxxxxx>
---
arch/x86/boot/compressed/misc.c | 23 +++++------------------
1 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index c13b5e9..704bec1 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -10,6 +10,7 @@
*/

#include "misc.h"
+#include <asm/asm.h>

/* WARNING!!
* This code is compiled with -fPIC and it is relocated dynamically
@@ -227,35 +228,21 @@ void *memset(void *s, int c, size_t n)
ss[i] = c;
return s;
}
-#ifdef CONFIG_X86_32
-void *memcpy(void *dest, const void *src, size_t n)
-{
- int d0, d1, d2;
- asm volatile(
- "rep ; movsl\n\t"
- "movl %4,%%ecx\n\t"
- "rep ; movsb\n\t"
- : "=&c" (d0), "=&D" (d1), "=&S" (d2)
- : "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src)
- : "memory");

- return dest;
-}
-#else
void *memcpy(void *dest, const void *src, size_t n)
{
long d0, d1, d2;
asm volatile(
- "rep ; movsq\n\t"
- "movq %4,%%rcx\n\t"
+ "rep ; " __ASM_SIZE(movs) "\n\t"
+ "mov %4,%0\n\t"
"rep ; movsb\n\t"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
- : "0" (n >> 3), "g" (n & 7), "1" (dest), "2" (src)
+ : "0" (n / sizeof(long)), "g" (n & (sizeof(long) - 1)),
+ "1" (dest), "2" (src)
: "memory");

return dest;
}
-#endif

static void error(char *x)
{
--
1.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/