From: Sebastien Bourdeauducq Date: Sun, 27 May 2012 14:06:23 +0000 (+0200) Subject: software/libbase: memcpy: same with 2 alignment X-Git-Tag: 24jan2021_ls180~3155 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=333179e1c565d9d7b9ed970d806b04544e0b634c;p=litex.git software/libbase: memcpy: same with 2 alignment --- diff --git a/software/libbase/libc.c b/software/libbase/libc.c index d0667f1c..16aac09a 100644 --- a/software/libbase/libc.c +++ b/software/libbase/libc.c @@ -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;