Standard byteorder functions across BSD / Linux

Nanno Langstraat nlcom_os at
Thu Jun 5 09:45:14 UTC 2008

Max Laier wrote:
> On Thursday 05 June 2008 00:33:19 Nanno Langstraat wrote:
>>     * <endian.h> or <sys/endian.h> ?
>>       I maintain that it should be <endian.h> for user applications:
>>       IMHO <sys/> is for the user-kernel API, and byteorder belongs to
>>       libc not the kernel API.
>>       glibc apparently agrees, OpenBSD disagreed.
> Not sure about this.  There might be namespace issues with this approach, 
> though there probably shouldn't.

True. However, glibc (i.e. Linux) has had the file <endian.h> for a long
time.  (That's probably why Ulrich Drepper simply added the new macros

Since they're something of an "800 pound gorilla", I don't think it'll
be an additional hazard for BSD to add that file to the top-level file

In fact, glibc are taking an extra risk, because their pre-existing
<endian.h> is automatically pulled in by common things like <ctype.h>
and <pthread.h>.

On FreeBSD, a newly introduced <endian.h> can sit there innocently, and
only be pulled in by user applications that explicitly know about it.

> It's obviously not a problem to have 
> both, but getting rid of sys/endian.h now is too late for sure.

Agree, won't disappear, even if only because the kernel uses it.


More information about the freebsd-hackers mailing list