Bug 4364 - _XOPEN_VERSION and unistd.h
Summary: _XOPEN_VERSION and unistd.h
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
Depends on:
Reported: 2007-04-15 00:43 UTC by Pierre Habouzit
Modified: 2014-07-10 20:33 UTC (History)
1 user (show)

See Also:
Last reconfirmed:
fweimer: security-

XOPEN_VERSION will be 600 when __USE_XOPEN2K is defined. (340 bytes, patch)
2007-04-15 00:45 UTC, Pierre Habouzit
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre Habouzit 2007-04-15 00:43:57 UTC
quoting from: http://bugs.debian.org/203412, attached is a patch

SUSv3 [0] states that:

  The following symbolic constant shall be defined only if the
  implementation supports the XSI option; see XSI Conformance.
    Integer value indicating version of the X/Open Portability Guide to
        which the implementation conforms. The value shall be 600. 

It furthermore states [0]:

     The implementation supports the XSI extension.

Therefore, if _XOPEN_UNIX is defined, as it is, unconditionally to 1,
then at least at some time _XOPEN_VERSION must be defined to 600.

The only place I can find that _XOPEN_VERSION is mentioned is unistd.h,
which has the following snippet of code:

  /* X/Open version number to which the library conforms.  It is selectable.  
  #ifdef __USE_UNIX98
  # define _XOPEN_VERSION       500
  # define _XOPEN_VERSION       4

There is a complicated set of preprocessor directives in features.h that
chooses appropriately; for _XOPEN_SOURCE=600, _XOPEN_VERSION=500, not
600. Oops.

  [0] http://www.opengroup.org/onlinepubs/007904975/basedefs/unistd.h.html
Comment 1 Pierre Habouzit 2007-04-15 00:45:08 UTC
Created attachment 1688 [details]
XOPEN_VERSION will be 600
when __USE_XOPEN2K is defined.

XOPEN_VERSION will be 600 when __USE_XOPEN2K is defined.
Comment 2 Jakub Jelinek 2007-04-15 01:08:34 UTC
I'd use #elif instead, other than that it looks ok to me.
/* X/Open version number to which the library conforms.  It is selectable.  */
#ifdef __USE_XOPEN2K
# define _XOPEN_VERSION 600
#elif defined __USE_UNIX98
# define _XOPEN_VERSION 500
# define _XOPEN_VERSION 4
Comment 3 Ulrich Drepper 2007-04-17 00:44:45 UTC
I checked in the patch.
Comment 4 cvs-commit@gcc.gnu.org 2007-07-12 15:10:13 UTC
Subject: Bug 4364

CVSROOT:	/cvs/glibc
Module name:	libc
Branch: 	glibc-2_5-branch
Changes by:	jakub@sourceware.org	2007-07-12 15:09:59

Modified files:
	.              : ChangeLog 
	posix          : unistd.h 

Log message:
	2007-04-16  Ulrich Drepper  <drepper@redhat.com>
	[BZ #4364]
	* posix/unistd.h (_XOPEN_VERSION): Define appropriately for SUSv3.