Print this page
Be more consistent with other OSes. Try to avoid failing on unknown _XOPEN_SOURCE values.
3801 _XOPEN_SOURCE value is ignored if __XOPEN_SOURCE_EXTENDED is set

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/sys/feature_tests.h
          +++ new/usr/src/uts/common/sys/feature_tests.h
↓ open down ↓ 228 lines elided ↑ open up ↑
 229  229   * XPG6 is the result of a merge of the X/Open and POSIX specifications
 230  230   *     and as such is also referred to as IEEE Std. 1003.1-2001 in
 231  231   *     addition to UNIX 03 and SUSv3.
 232  232   *
 233  233   * When writing a conforming X/Open application, as per the specification
 234  234   * requirements, the appropriate feature test macros must be defined at
 235  235   * compile time. These are as follows. For more info, see standards(5).
 236  236   *
 237  237   * Feature Test Macro                                Specification
 238  238   * ------------------------------------------------  -------------
 239      - * _XOPEN_SOURCE                                         XPG3
 240      - * _XOPEN_SOURCE && _XOPEN_VERSION = 4                   XPG4
      239 + * _XOPEN_SOURCE >= 600  (or POSIX_C_SOURCE>=200112L)    XPG6
      240 + * _XOPEN_SOURCE >= 500                                  XPG5
 241  241   * _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1           XPG4v2
 242      - * _XOPEN_SOURCE = 500                                   XPG5
 243      - * _XOPEN_SOURCE = 600  (or POSIX_C_SOURCE=200112L)      XPG6
      242 + * _XOPEN_SOURCE && _XOPEN_VERSION = 4                   XPG4
      243 + * _XOPEN_SOURCE                                         XPG3
 244  244   *
 245  245   * In order to simplify the guards within the headers, the following
 246  246   * implementation private test macros have been created. Applications
 247  247   * must NOT use these private test macros as unexpected results will
 248  248   * occur.
 249  249   *
 250  250   * Note that in general, the use of these private macros is cumulative.
 251  251   * For example, the use of _XPG3 with no other restrictions on the X/Open
 252  252   * namespace will make the symbols visible for XPG3 through XPG6
 253  253   * compilation environments. The use of _XPG4_2 with no other X/Open
↓ open down ↓ 1 lines elided ↑ open up ↑
 255  255   * XPG4v2 and are therefore visible for XPG4v2 through XPG6 compilation
 256  256   * environments, but not for XPG3 or XPG4 compilation environments.
 257  257   *
 258  258   * _XPG3    X/Open Portability Guide, Issue 3 (XPG3)
 259  259   * _XPG4    X/Open CAE Specification, Issue 4 (XPG4)
 260  260   * _XPG4_2  X/Open CAE Specification, Issue 4, Version 2 (XPG4v2/UNIX 95/SUS)
 261  261   * _XPG5    X/Open CAE Specification, Issue 5 (XPG5/UNIX 98/SUSv2)
 262  262   * _XPG6    Open Group Technical Standard, Issue 6 (XPG6/UNIX 03/SUSv3)
 263  263   */
 264  264  
 265      -/* X/Open Portability Guide, Issue 3 */
 266      -#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 < 500) && \
 267      -        (_XOPEN_VERSION - 0 < 4) && !defined(_XOPEN_SOURCE_EXTENDED)
 268      -#define _XPG3
 269      -/* X/Open CAE Specification, Issue 4 */
 270      -#elif   (defined(_XOPEN_SOURCE) && _XOPEN_VERSION - 0 == 4)
 271      -#define _XPG4
 272      -#define _XPG3
 273      -/* X/Open CAE Specification, Issue 4, Version 2 */
 274      -#elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1)
      265 +/* Open Group Technical Standard , Issue 6 */
      266 +#if     (_XOPEN_SOURCE - 0 >= 600) || (_POSIX_C_SOURCE - 0 >= 200112L)
      267 +#define _XPG6
      268 +#define _XPG5
 275  269  #define _XPG4_2
 276  270  #define _XPG4
 277  271  #define _XPG3
      272 +#undef  _POSIX_C_SOURCE
      273 +#define _POSIX_C_SOURCE                 200112L
      274 +#undef  _XOPEN_SOURCE
      275 +#define _XOPEN_SOURCE                   600
 278  276  /* X/Open CAE Specification, Issue 5 */
 279      -#elif   (_XOPEN_SOURCE - 0 == 500)
      277 +#elif   (_XOPEN_SOURCE - 0 >= 500)
 280  278  #define _XPG5
 281  279  #define _XPG4_2
 282  280  #define _XPG4
 283  281  #define _XPG3
 284  282  #undef  _POSIX_C_SOURCE
 285  283  #define _POSIX_C_SOURCE                 199506L
 286      -/* Open Group Technical Standard , Issue 6 */
 287      -#elif   (_XOPEN_SOURCE - 0 == 600) || (_POSIX_C_SOURCE - 0 == 200112L)
 288      -#define _XPG6
 289      -#define _XPG5
      284 +/* X/Open CAE Specification, Issue 4, Version 2 */
      285 +#elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1)
 290  286  #define _XPG4_2
 291  287  #define _XPG4
 292  288  #define _XPG3
 293      -#undef  _POSIX_C_SOURCE
 294      -#define _POSIX_C_SOURCE                 200112L
 295      -#undef  _XOPEN_SOURCE
 296      -#define _XOPEN_SOURCE                   600
      289 +/* X/Open CAE Specification, Issue 4 */
      290 +#elif   (defined(_XOPEN_SOURCE) && _XOPEN_VERSION - 0 == 4)
      291 +#define _XPG4
      292 +#define _XPG3
      293 +/* X/Open Portability Guide, Issue 3 */
      294 +#elif defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 < 4)
      295 +#define _XPG3
 297  296  #endif
 298  297  
 299  298  /*
 300  299   * _XOPEN_VERSION is defined by the X/Open specifications and is not
 301  300   * normally defined by the application, except in the case of an XPG4
 302  301   * application.  On the implementation side, _XOPEN_VERSION defined with
 303  302   * the value of 3 indicates an XPG3 application. _XOPEN_VERSION defined
 304  303   * with the value of 4 indicates an XPG4 or XPG4v2 (UNIX 95) application.
 305  304   * _XOPEN_VERSION  defined with a value of 500 indicates an XPG5 (UNIX 98)
 306  305   * application and with a value of 600 indicates an XPG6 (UNIX 03)
↓ open down ↓ 88 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX