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


 219  * X/Open Portability Guide, Issue 3 (XPG3)
 220  * X/Open CAE Specification, Issue 4 (XPG4)
 221  * X/Open CAE Specification, Issue 4, Version 2 (XPG4v2)
 222  * X/Open CAE Specification, Issue 5 (XPG5)
 223  * Open Group Technical Standard, Issue 6 (XPG6), also referred to as
 224  *    IEEE Std. 1003.1-2001 and ISO/IEC 9945:2002.
 225  *
 226  * XPG4v2 is also referred to as UNIX 95 (SUS or SUSv1).
 227  * XPG5 is also referred to as UNIX 98 or the Single Unix Specification,
 228  *     Version 2 (SUSv2)
 229  * XPG6 is the result of a merge of the X/Open and POSIX specifications
 230  *     and as such is also referred to as IEEE Std. 1003.1-2001 in
 231  *     addition to UNIX 03 and SUSv3.
 232  *
 233  * When writing a conforming X/Open application, as per the specification
 234  * requirements, the appropriate feature test macros must be defined at
 235  * compile time. These are as follows. For more info, see standards(5).
 236  *
 237  * Feature Test Macro                                Specification
 238  * ------------------------------------------------  -------------
 239  * _XOPEN_SOURCE                                         XPG3
 240  * _XOPEN_SOURCE && _XOPEN_VERSION = 4                   XPG4
 241  * _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1           XPG4v2
 242  * _XOPEN_SOURCE = 500                                   XPG5
 243  * _XOPEN_SOURCE = 600  (or POSIX_C_SOURCE=200112L)      XPG6
 244  *
 245  * In order to simplify the guards within the headers, the following
 246  * implementation private test macros have been created. Applications
 247  * must NOT use these private test macros as unexpected results will
 248  * occur.
 249  *
 250  * Note that in general, the use of these private macros is cumulative.
 251  * For example, the use of _XPG3 with no other restrictions on the X/Open
 252  * namespace will make the symbols visible for XPG3 through XPG6
 253  * compilation environments. The use of _XPG4_2 with no other X/Open
 254  * namespace restrictions indicates that the symbols were introduced in
 255  * XPG4v2 and are therefore visible for XPG4v2 through XPG6 compilation
 256  * environments, but not for XPG3 or XPG4 compilation environments.
 257  *
 258  * _XPG3    X/Open Portability Guide, Issue 3 (XPG3)
 259  * _XPG4    X/Open CAE Specification, Issue 4 (XPG4)
 260  * _XPG4_2  X/Open CAE Specification, Issue 4, Version 2 (XPG4v2/UNIX 95/SUS)
 261  * _XPG5    X/Open CAE Specification, Issue 5 (XPG5/UNIX 98/SUSv2)
 262  * _XPG6    Open Group Technical Standard, Issue 6 (XPG6/UNIX 03/SUSv3)
 263  */
 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)
 275 #define _XPG4_2
 276 #define _XPG4
 277 #define _XPG3




 278 /* X/Open CAE Specification, Issue 5 */
 279 #elif   (_XOPEN_SOURCE - 0 == 500)
 280 #define _XPG5
 281 #define _XPG4_2
 282 #define _XPG4
 283 #define _XPG3
 284 #undef  _POSIX_C_SOURCE
 285 #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
 290 #define _XPG4_2
 291 #define _XPG4
 292 #define _XPG3
 293 #undef  _POSIX_C_SOURCE
 294 #define _POSIX_C_SOURCE                 200112L
 295 #undef  _XOPEN_SOURCE
 296 #define _XOPEN_SOURCE                   600



 297 #endif
 298 
 299 /*
 300  * _XOPEN_VERSION is defined by the X/Open specifications and is not
 301  * normally defined by the application, except in the case of an XPG4
 302  * application.  On the implementation side, _XOPEN_VERSION defined with
 303  * the value of 3 indicates an XPG3 application. _XOPEN_VERSION defined
 304  * with the value of 4 indicates an XPG4 or XPG4v2 (UNIX 95) application.
 305  * _XOPEN_VERSION  defined with a value of 500 indicates an XPG5 (UNIX 98)
 306  * application and with a value of 600 indicates an XPG6 (UNIX 03)
 307  * application.  The appropriate version is determined by the use of the
 308  * feature test macros described earlier.  The value of _XOPEN_VERSION
 309  * defaults to 3 otherwise indicating support for XPG3 applications.
 310  */
 311 #ifndef _XOPEN_VERSION
 312 #ifdef  _XPG6
 313 #define _XOPEN_VERSION 600
 314 #elif defined(_XPG5)
 315 #define _XOPEN_VERSION 500
 316 #elif   defined(_XPG4_2)




 219  * X/Open Portability Guide, Issue 3 (XPG3)
 220  * X/Open CAE Specification, Issue 4 (XPG4)
 221  * X/Open CAE Specification, Issue 4, Version 2 (XPG4v2)
 222  * X/Open CAE Specification, Issue 5 (XPG5)
 223  * Open Group Technical Standard, Issue 6 (XPG6), also referred to as
 224  *    IEEE Std. 1003.1-2001 and ISO/IEC 9945:2002.
 225  *
 226  * XPG4v2 is also referred to as UNIX 95 (SUS or SUSv1).
 227  * XPG5 is also referred to as UNIX 98 or the Single Unix Specification,
 228  *     Version 2 (SUSv2)
 229  * XPG6 is the result of a merge of the X/Open and POSIX specifications
 230  *     and as such is also referred to as IEEE Std. 1003.1-2001 in
 231  *     addition to UNIX 03 and SUSv3.
 232  *
 233  * When writing a conforming X/Open application, as per the specification
 234  * requirements, the appropriate feature test macros must be defined at
 235  * compile time. These are as follows. For more info, see standards(5).
 236  *
 237  * Feature Test Macro                                Specification
 238  * ------------------------------------------------  -------------
 239  * _XOPEN_SOURCE >= 600  (or POSIX_C_SOURCE>=200112L)    XPG6
 240  * _XOPEN_SOURCE >= 500                                  XPG5
 241  * _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1           XPG4v2
 242  * _XOPEN_SOURCE && _XOPEN_VERSION = 4                   XPG4
 243  * _XOPEN_SOURCE                                         XPG3
 244  *
 245  * In order to simplify the guards within the headers, the following
 246  * implementation private test macros have been created. Applications
 247  * must NOT use these private test macros as unexpected results will
 248  * occur.
 249  *
 250  * Note that in general, the use of these private macros is cumulative.
 251  * For example, the use of _XPG3 with no other restrictions on the X/Open
 252  * namespace will make the symbols visible for XPG3 through XPG6
 253  * compilation environments. The use of _XPG4_2 with no other X/Open
 254  * namespace restrictions indicates that the symbols were introduced in
 255  * XPG4v2 and are therefore visible for XPG4v2 through XPG6 compilation
 256  * environments, but not for XPG3 or XPG4 compilation environments.
 257  *
 258  * _XPG3    X/Open Portability Guide, Issue 3 (XPG3)
 259  * _XPG4    X/Open CAE Specification, Issue 4 (XPG4)
 260  * _XPG4_2  X/Open CAE Specification, Issue 4, Version 2 (XPG4v2/UNIX 95/SUS)
 261  * _XPG5    X/Open CAE Specification, Issue 5 (XPG5/UNIX 98/SUSv2)
 262  * _XPG6    Open Group Technical Standard, Issue 6 (XPG6/UNIX 03/SUSv3)
 263  */
 264 
 265 /* Open Group Technical Standard , Issue 6 */
 266 #if     (_XOPEN_SOURCE - 0 >= 600) || (_POSIX_C_SOURCE - 0 >= 200112L)
 267 #define _XPG6
 268 #define _XPG5






 269 #define _XPG4_2
 270 #define _XPG4
 271 #define _XPG3
 272 #undef  _POSIX_C_SOURCE
 273 #define _POSIX_C_SOURCE                 200112L
 274 #undef  _XOPEN_SOURCE
 275 #define _XOPEN_SOURCE                   600
 276 /* X/Open CAE Specification, Issue 5 */
 277 #elif   (_XOPEN_SOURCE - 0 >= 500)
 278 #define _XPG5
 279 #define _XPG4_2
 280 #define _XPG4
 281 #define _XPG3
 282 #undef  _POSIX_C_SOURCE
 283 #define _POSIX_C_SOURCE                 199506L
 284 /* X/Open CAE Specification, Issue 4, Version 2 */
 285 #elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1)


 286 #define _XPG4_2
 287 #define _XPG4
 288 #define _XPG3
 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
 296 #endif
 297 
 298 /*
 299  * _XOPEN_VERSION is defined by the X/Open specifications and is not
 300  * normally defined by the application, except in the case of an XPG4
 301  * application.  On the implementation side, _XOPEN_VERSION defined with
 302  * the value of 3 indicates an XPG3 application. _XOPEN_VERSION defined
 303  * with the value of 4 indicates an XPG4 or XPG4v2 (UNIX 95) application.
 304  * _XOPEN_VERSION  defined with a value of 500 indicates an XPG5 (UNIX 98)
 305  * application and with a value of 600 indicates an XPG6 (UNIX 03)
 306  * application.  The appropriate version is determined by the use of the
 307  * feature test macros described earlier.  The value of _XOPEN_VERSION
 308  * defaults to 3 otherwise indicating support for XPG3 applications.
 309  */
 310 #ifndef _XOPEN_VERSION
 311 #ifdef  _XPG6
 312 #define _XOPEN_VERSION 600
 313 #elif defined(_XPG5)
 314 #define _XOPEN_VERSION 500
 315 #elif   defined(_XPG4_2)