Skip to content
Snippets Groups Projects
Commit b038db85 authored by Matthias Weisser's avatar Matthias Weisser Committed by Wolfgang Denk
Browse files

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: default avatarMatthias Weisser <weisserm@arcor.de>
parent 942e3143
No related branches found
No related tags found
No related merge requests found
...@@ -467,6 +467,9 @@ void * memcpy(void *dest, const void *src, size_t count) ...@@ -467,6 +467,9 @@ void * memcpy(void *dest, const void *src, size_t count)
unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src; unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src;
char *d8, *s8; char *d8, *s8;
if (src == dest)
return dest;
/* while all data is aligned (common case), copy a word at a time */ /* while all data is aligned (common case), copy a word at a time */
if ( (((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) { if ( (((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) {
while (count >= sizeof(*dl)) { while (count >= sizeof(*dl)) {
...@@ -497,6 +500,9 @@ void * memmove(void * dest,const void *src,size_t count) ...@@ -497,6 +500,9 @@ void * memmove(void * dest,const void *src,size_t count)
{ {
char *tmp, *s; char *tmp, *s;
if (src == dest)
return dest;
if (dest <= src) { if (dest <= src) {
tmp = (char *) dest; tmp = (char *) dest;
s = (char *) src; s = (char *) src;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment