summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Weisser <weisserm@arcor.de>2011-05-22 23:03:55 +0000
committerWolfgang Denk <wd@denx.de>2011-07-26 00:28:44 +0200
commitb038db852b5b7120f1ff825d8e2a5c2cd14c2f0f (patch)
treef17c46b445dab4e227a4c47abad4eab5249789e4
parent942e31437d2ba34acab259901b929532ba77390a (diff)
downloadu-boot-b038db852b5b7120f1ff825d8e2a5c2cd14c2f0f.tar.gz
u-boot-b038db852b5b7120f1ff825d8e2a5c2cd14c2f0f.tar.xz
u-boot-b038db852b5b7120f1ff825d8e2a5c2cd14c2f0f.zip
memcpy/memmove: Do not copy to same address
In some cases (e.g. bootm with a elf payload which is already at the right position) there is a in place copy of data to the same address. Catching this saves some ms while booting. Signed-off-by: Matthias Weisser <weisserm@arcor.de>
-rw-r--r--lib/string.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c
index b375b8124a..2c4f0ec9a1 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -467,6 +467,9 @@ void * memcpy(void *dest, const void *src, size_t count)
unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src;
char *d8, *s8;
+ if (src == dest)
+ return dest;
+
/* while all data is aligned (common case), copy a word at a time */
if ( (((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) {
while (count >= sizeof(*dl)) {
@@ -497,6 +500,9 @@ void * memmove(void * dest,const void *src,size_t count)
{
char *tmp, *s;
+ if (src == dest)
+ return dest;
+
if (dest <= src) {
tmp = (char *) dest;
s = (char *) src;