mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
software/libbase: fix memcpy handling of buffers with differing alignments
This commit is contained in:
parent
4dbc938f7c
commit
48b70f09a8
1 changed files with 8 additions and 1 deletions
|
@ -265,6 +265,13 @@ void *memcpy(void *to, const void *from, size_t n)
|
||||||
from = cfrom;
|
from = cfrom;
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
|
if((long)from & 1) {
|
||||||
|
char *cto = to;
|
||||||
|
const char *cfrom = from;
|
||||||
|
for (; n; n--)
|
||||||
|
*cto++ = *cfrom++;
|
||||||
|
return xto;
|
||||||
|
}
|
||||||
if(n > 2 && (long)to & 2) {
|
if(n > 2 && (long)to & 2) {
|
||||||
short *sto = to;
|
short *sto = to;
|
||||||
const short *sfrom = from;
|
const short *sfrom = from;
|
||||||
|
@ -278,7 +285,7 @@ void *memcpy(void *to, const void *from, size_t n)
|
||||||
long *lto = to;
|
long *lto = to;
|
||||||
const long *lfrom = from;
|
const long *lfrom = from;
|
||||||
for(; temp; temp--)
|
for(; temp; temp--)
|
||||||
*lto++ = *lfrom++;
|
*lto++ = *lfrom++;
|
||||||
to = lto;
|
to = lto;
|
||||||
from = lfrom;
|
from = lfrom;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue