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, 16 insertions(+), 1 deletions(-)

diff --git a/lib_generic/string.c b/lib_generic/string.c
index 9911941..5f7aff9 100644
--- a/lib_generic/string.c
+++ b/lib_generic/string.c
@@ -404,7 +404,22 @@ char *strswab(const char *s)
 void * memset(void * s,int c,size_t count)
 {
        char *xs = (char *) s;
-
+       unsigned long *sl = (unsigned long *) s;
+       unsigned long cl = 0;
+       int i;
+
+       /* do it one word at a time (32 bits or 64 bits) if possible */
+       if ( ((count | (int)s) & (sizeof(long) - 1)) == 0) {
+               count /= sizeof(long);
+               for (i=0; i<sizeof(long); ++i) {
+                       cl <<= 8;
+                       cl |= c & 0xff;
+               }
+               while (count--)
+                       *sl++ = cl;
+               return s;
+       }
+       /* else, fill 8 bits at a time */
        while (count--)
                *xs++ = c;
 
-- 
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