Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Apr 1997 16:31:12 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@freefall.freebsd.org, thorpej@nas.nasa.gov
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: cvs commit: src/sys/i386/include endian.h
Message-ID:  <199704210631.QAA23521@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
> >   Don't pollute the namespace if _POSIX_SOURCE is defined.  This is
> >   broken - it makes almost everything in <machine/endian.h> inaccessible
> >   if _POSIX_SOURCE is defined, yet <machine/endian.h> is not a POSIX
> >   header.  Other systems don't do it any better.
>
>...there's a very good reason to protect the namespace:
>
>basalt (thorpej) ~ 202% uname -sm ; grep endian.h /sys/sys/types.h
>NetBSD hp300
>#include <machine/endian.h>

That's why the namspace protection implementation is broken.  After

	#define	_POSIX_SOURCE	1	/* protect namespace */
	#include <sys/types.h>		/* or anything that includes this */
	#undef	_POSIX_SOURCE		/* unprotect namespace */

the idempotency ifdef prevents further inclusions of <machine/endian.h,
so there is no way to get at the non-POSIX things in it.

It's interesting that the 4.4Lite byteorder(3) says to #include
<sys/param.h>, not <sys/types.h>, to get endian features.  This permits
a better implementation (except for <sys/param.h> being inherently
namespace-polluting).  NetBSD has fixed the man page.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199704210631.QAA23521>