Hi,

Thanks for this pointer, very interesting and commented

So we have to be double careful when using memcpy though, even if it
acts faster than its cousin memmove !

Nicolas

Le samedi 08 janvier 2011 ? 09:43 +0100, Julien BLACHE a ?crit :
> Nicolas Martin <nicolas0martin at gmail.com> wrote:
> 
> Hi,
> 
> > What is weird here, is that the effect of overlap in memcpy does not
> > seem to produce the same effect on different systems !
> 
> Using memcpy() on overlapping memory areas is undefined behaviour per
> spec.
> 
> glibc has several memcpy() implementations optimized for different
> hardware capabilities. A recent implementation for Atom/Core2 CPUs
> performs the copy from tail to head (giving a nice 4x/5x speedup on
> these CPUs), which breaks with overlapping memory areas.
> 
> Using memmove() is the correct way to handle overlapping areas, as
> documented.
> 
> See <http://lwn.net/Articles/414467/> for more (links/comments).
> 
> HTH,
> 
> JB.
> 



Reply via email to