svn commit: r253636 - head/sys/vm

David Chisnall theraven at FreeBSD.org
Fri Jul 26 09:50:01 UTC 2013


On 25 Jul 2013, at 16:10, mdf at FreeBSD.org wrote:

> Isn't that a compiler bug?  memset(p, 0, n) is the same as bzero(p, n).  Why would the compiler warn on one and not the other?

They are different.  memcpy is defined by the C standard.  bzero is defined by POSIX.  When you are compiling C code, the compiler is free to assume behaviour of any C standard functions but not of POSIX functions because it does not know that you are compiling for a POSIX target (possibly it should do this if the relevant POSIX macros are set).  

As Bruce says, however, the C standard excludes memset() and memcpy() in freestanding environments (which is a shame, because a lot of optimisations depend on their existence, and something I had thought was fixed in C11), so this is not relevant in the kernel.

> Does clang have a similar bias for memcpy versus bcopy?

Almost certainly.

David

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 881 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20130726/ade733df/attachment.sig>


More information about the svn-src-all mailing list