what is _XOPEN_SOURCE=500 needed for?

Josh Triplett josh at freedesktop.org
Fri May 27 23:50:47 PDT 2005


Daniel Stone wrote:
> On Mon, May 23, 2005 at 11:21:25PM -0600, Matthieu Herrb wrote:
>>I'm trying to build the modular tree on OpenBSD. One problem I noticed 
>>is that -D_XOPEN_SOURCE=500 is now added unconditionnaly to all CFLAGS.
>>This breaks things on OpenBSD, so It should probably be defined only on 
>>systems that needs it.
>>One problem when dealing with this kind of macros and autoconf is to 
>>find out what features exactly need this define.
>>So does any one know why it's needed on Linux, Solaris and cygwin (these 
>>are the only platforms that define it in the monolithic tree).
> 
> Xpoll.h requires fds_bits to be present in fd_set, which is defined as
> such on glibc:
> /* fd_set for select and pselect.  */
> typedef struct
>   {
>     /* XPG4.2 requires this member name.  Otherwise avoid the name
>        from the global namespace.  */
> #ifdef __USE_XOPEN
>     __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
> # define __FDS_BITS(set) ((set)->fds_bits)
> #else
>     __fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];
> # define __FDS_BITS(set) ((set)->__fds_bits)
> #endif
>   } fd_set;

The optimal solution to this problem would probably be to rewrite the
macros in Xpoll.h to use the portable macros FD_SET, FD_CLEAR, FD_ISSET,
and FD_ZERO.  Attempting to look at the insides of struct fd_set, and in
particular assuming that it has a member fds_bits, is non-portable;
defining _*_SOURCE just lets it use this non-portable behavior on some
additional platforms.

From
http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/select.h.html
: "The requirement for the fd_set structure to have a member fds_bits
has been removed as per The Open Group Base Resolution bwg2001-005."

If there is some old system which has fds_bits but not FD_* macros, it
should be simple enough to provide definitions for the macros if they
aren't already defined.

- Josh Triplett
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 251 bytes
Desc: OpenPGP digital signature
URL: <http://lists.x.org/archives/xorg/attachments/20050527/d3f8c3c3/attachment.pgp>


More information about the xorg mailing list