This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use memcpy in memmove when possible


On 7/09/2012, at 7:58 AM, Roland McGrath wrote:

> 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.

OK, fair enough.  Attached is the simplified patch.  I confirmed that the compiler is able to optimize the tail call.

Thanks,

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics

Attachment: 0002-Use-memcpy-in-memmove-when-possible.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]