This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Not so fast std::copy, std::memcpy and ::memcpy on linux


Hello

I was trying to compile code to run fast on linux and had been optimizing
and profiling for a while when I ended up with a call

memcpy(buf, "foo!", 4);

that I thought would expand to about the same as if compiled with C using
glibc - that is a single dword move but instead I got surprised by an actual
call to memcpy so I checked the header file to see what was happening and
found that

a) libc and libstdc++ undefs memcpy for c++
b) std::memcpy is an alias for ::memcpy (Not that unexpected)
c) std::copy evaluates to a call to memmove

Now, a) and b) are demands from the standard as far as I understands but for
c) I think that a better version could be provided along the lines of glibc,
would such a patch be acceptable?

/MF


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