From: Alessandro Rubini <rub...@unipv.it>

Signed-off-by: Alessandro Rubini <rub...@unipv.it>
Acked-by: Andrea Gallo <andrea.ga...@stericsson.com>
---
 lib_generic/string.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib_generic/string.c b/lib_generic/string.c
index 181eda6..9911941 100644
--- a/lib_generic/string.c
+++ b/lib_generic/string.c
@@ -446,12 +446,21 @@ char * bcopy(const char * src, char * dest, int count)
  * You should not use this function to access IO space, use memcpy_toio()
  * or memcpy_fromio() instead.
  */
-void * memcpy(void * dest,const void *src,size_t count)
+void * memcpy(void *dest, const void *src, size_t count)
 {
-       char *tmp = (char *) dest, *s = (char *) src;
+       char *d8 = (char *)dest, *s8 = (char *)src;
+       unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src;
 
+       /* if all data is aligned (common case), copy a word at a time */
+       if ( (((int)dest | (int)src | count) & (sizeof(long) - 1)) == 0) {
+               count /= sizeof(unsigned long);
+               while (count--)
+                       *dl++ = *sl++;
+               return dest;
+       }
+       /* else, use 1-byte copy */
        while (count--)
-               *tmp++ = *s++;
+               *d8++ = *s8++;
 
        return dest;
 }
-- 
1.6.0.2
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to