From: Brian Gerst <brgerst@gmail.com>
To: hpa@zytor.com
Cc: x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] x86, boot: merge memcpy()
Date: Sat, 26 Feb 2011 12:54:04 -0500 [thread overview]
Message-ID: <1298742844-8256-4-git-send-email-brgerst@gmail.com> (raw)
In-Reply-To: <1298742844-8256-1-git-send-email-brgerst@gmail.com>
Merge the 32-bit and 64-bit memcpy functions.
Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
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
next prev parent reply other threads:[~2011-02-26 17:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-26 17:54 [PATCH 0/3] x86 boot cleanups Brian Gerst
2011-02-26 17:54 ` [PATCH 1/3] x86, boot: Use common ELF header defines Brian Gerst
2011-02-27 11:05 ` Pekka Enberg
2011-02-26 17:54 ` [PATCH 2/3] x86, boot: Remove memptr Brian Gerst
2011-02-27 11:07 ` Pekka Enberg
2011-02-26 17:54 ` Brian Gerst [this message]
2011-02-27 11:11 ` [PATCH 3/3] x86, boot: merge memcpy() Pekka Enberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1298742844-8256-4-git-send-email-brgerst@gmail.com \
--to=brgerst@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox