INN's BSD typedefs and glibc...
James Ralston
qralston+ml.inn-workers at andrew.cmu.edu
Fri May 11 21:16:19 UTC 2001
I was doing some more investigating last night, and I don't believe
it's worth it to remove the instances where INN uses BSD-specific
typedefs (u_int, u_short, and so forth).
It would seem (at least to my knowledge) that the only systems so far
that run into problems where those typedefs aren't defined are glibc
systems. I wrote a simple program to demonstrate what glibc features
are made available depending on what glibc feature-test macros are
used. If you do not explicitly use any features, this is what's
available:
$ gcc -o sf sf.c
$ ./sf
__USE_POSIX
__USE_POSIX2
__USE_POSIX199309
__USE_POSIX199506
__USE_BSD
__USE_SVID
__USE_MISC
With _XOPEN_SOURCE=500:
$ gcc -D_XOPEN_SOURCE=500 -o sf sf.c
$ ./sf
__USE_POSIX
__USE_POSIX2
__USE_POSIX199309
__USE_POSIX199506
__USE_XOPEN
__USE_XOPEN_EXTENDED
__USE_UNIX98
__USE_LARGEFILE
Note that although __USE_BSD is set if no feature-test macros are
used, explicitly using any feature-test macro means that you must
explicitly enable the BSD features:
$ gcc -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -o sf sf.c
$ ./sf
__USE_POSIX
__USE_POSIX2
__USE_POSIX199309
__USE_POSIX199506
__USE_XOPEN
__USE_XOPEN_EXTENDED
__USE_UNIX98
__USE_LARGEFILE
__USE_BSD
__USE_MISC
And _GNU_SOURCE turns on everything:
$ gcc -D_GNU_SOURCE -o sf sf.c
$ ./sf
__USE_ISOC99
__USE_POSIX
__USE_POSIX2
__USE_POSIX199309
__USE_POSIX199506
__USE_XOPEN
__USE_XOPEN_EXTENDED
__USE_UNIX98
__USE_XOPEN2K
__USE_LARGEFILE
__USE_LARGEFILE64
__USE_BSD
__USE_SVID
__USE_MISC
__USE_GNU
The reason why __USE_BSD must be set is because many of glibc's own
include files use the BSD-specific typedefs, because the include files
(and presumably the functions themselves) are taken from BSD.
So, you *must* have _BSD_SOURCE set (either implicitly, or explicitly)
when compiling on glibc systems. That means either using no
feature-test macros (which won't work, because pread/pwrite needs at
least -D_XOPEN_SOURCE=500), using -D_XOPEN_SOURCE=500 -D_BSD_SOURCE,
or using -D_GNU_SOURCE.
_GNU_SOURCE is preferable (according to glibc itself), but INN has
symbol clashes if _GNU_SOURCE is used. I'm going to go ahead and fix
up those clashes; expect to see the patch hit inn-patches today or
tomorrow.
Also, can anyone else demonstrate a non-glibc system where the BSD
typedefs are not available in <sys/types.h>? In other words, do we
know if it is necessary to add a check for the BSD typedefs to
configure, so that they're defined if the system include files don't
define them? (Right now, INN doesn't check to make sure the typedefs
are available; it just assumes they will be.)
--
James Ralston, Information Technology
Software Engineering Institute
Carnegie Mellon University, Pittsburgh, PA, USA
More information about the inn-workers
mailing list