This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Not so fast std::copy, std::memcpy and ::memcpy on linux
- From: Magnus Fromreide <magfr at lysator dot liu dot se>
- To: libstdc++ at gcc dot gnu dot org
- Date: Tue, 12 Aug 2003 21:06:03 +0200
- Subject: 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