[PATCH] Use memcpy in memmove when possible
Roland McGrath
roland@hack.frob.com
Thu Sep 6 19:58:00 GMT 2012
Definitely do not insert an extra RETURN (dest). There's no reason for that.
You should use tail calls for the memcpy invocations. i.e.
return memcpy (dest, src, len);
To avoid more #if nonsense for the bcopy case, write:
dest = memcpy (dest, src, len);
Then the compiler ought to turn it into the tail call (but verify that).
Is there really ever going to be a case for MEMCPY_OK_FOR_BWD_MEMMOVE?
That is, will there ever be an implementation of memcpy that works for the
overlapping case but not the nonoverlapping case? I can't really imagine
one. If there isn't, then any case that would define your
MEMCPY_OK_FOR_BWD_MEMMOVE macro should really just be making memmove an
alias for memcpy instead.
Thanks,
Roland
More information about the Libc-alpha
mailing list