This is the mail archive of the
mailing list for the glibc project.
[RFC] Do not call memmove when memcpy suffices.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Tue, 13 Aug 2013 13:11:23 +0200
- Subject: [RFC] Do not call memmove when memcpy suffices.
We in memmove currently do lot of custom logic that is not neccessary
for most of time. When strings do not overlap we could and should just
One way to do this is to add check for overlap before all memmove calls.
This allows user to just install new glibc without recompiling.
Other way is also possible, as distributions often ship old glibc
version we could modify header and developers can recompile without
worrying if user upgrades.
For header version I prepared following macro but where should I put it?
A most likely place is string/bits/string2.h but I am not quite sure.
#define memmove(_dest, _src, _n) \
char *dest = (_dest); \
char *src = (_src); \
size_t n = (_n); \
if (__glibc_likely ((size_t)((src - n) - dest) >= 2 * n)) \
return memcpy (dest, src, n); \
return memmove (dest, src, n); \