memmove broken
Paul Mackerras
paulus at samba.org
Sat Jul 5 09:38:46 EST 2003
Joakim Tjernlund writes:
> Currenly this works, but it is PPC specific:
> static inline void memcpy_update(Byte **dest, Byte **src, size_t *n)
> {
> if(*dest - *src <= 8){ /* memcpy on PPC will do 8 bytes in a chunk */
> **dest = **src;
> --(*n);
> do {
> *++(*dest) = *++(*src);
> } while (--(*n));
> (*dest)++; (*src)++;
> } else {
> memcpy(*dest, *src, *n);
> *dest += *n;
> *src += *n;
> *n = 0;
> }
Why is it an issue? Is the performance of the byte-by-byte loop
really a limiting factor for you?
In general the behaviour of memcpy with overlapping regions is very
implementation-dependent. If we use the code above then that would
place constraints on what we can do in memcpy - and very non-obvious
constraints at that. For example if we decided to use altivec loads
and stores in memcpy, it would then do 16 or 32 bytes in a chunk and
thus break zlib again.
Paul.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
More information about the Linuxppc-dev
mailing list