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

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
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.
  
    _XOPEN_VERSION
    [XSI] 
    Integer value indicating version of the X/Open Portability Guide to
        which the implementation conforms. The value shall be 600. 

It furthermore states [0]:

  _XOPEN_UNIX
    [XSI] 
     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
  #else
  # define _XOPEN_VERSION       4
  #endif

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
#else
# define _XOPEN_VERSION 4
#endif
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.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/ChangeLog.diff?cvsroot=glibc&only_with_tag=glibc-2_5-branch&r1=1.10362.2.66&r2=1.10362.2.67
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/posix/unistd.h.diff?cvsroot=glibc&only_with_tag=glibc-2_5-branch&r1=1.147&r2=1.147.2.1