software/libbase: memcpy: same with 2 alignment
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Sun, 27 May 2012 14:06:23 +0000 (16:06 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Sun, 27 May 2012 14:06:23 +0000 (16:06 +0200)
software/libbase/libc.c

index d0667f1cdfdcc2a345e6a2f8172c355d3a31e380..16aac09a56edbd3ab90540caef912b6a45f66bf2 100644 (file)
@@ -280,6 +280,21 @@ void *memcpy(void *to, const void *from, size_t n)
                from = sfrom;
                n -= 2;
        }
+       if((long)from & 2) {
+               short *sto = to;
+               const short *sfrom = from;
+               temp = n >> 1;
+               for (; temp; temp--)
+                       *sto++ = *sfrom++;
+               to = sto;
+               from = sfrom;
+               if(n & 1) {
+                       char *cto = to;
+                       const char *cfrom = from;
+                       *cto = *cfrom;
+               }
+               return xto;
+       }
        temp = n >> 2;
        if(temp) {
                long *lto = to;