1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_FEATURE_TESTS_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_FEATURE_TESTS_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <sys/ccompile.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 36*7c478bd9Sstevel@tonic-gate extern "C" { 37*7c478bd9Sstevel@tonic-gate #endif 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate /* 40*7c478bd9Sstevel@tonic-gate * Values of _POSIX_C_SOURCE 41*7c478bd9Sstevel@tonic-gate * 42*7c478bd9Sstevel@tonic-gate * undefined not a POSIX compilation 43*7c478bd9Sstevel@tonic-gate * 1 POSIX.1-1990 compilation 44*7c478bd9Sstevel@tonic-gate * 2 POSIX.2-1992 compilation 45*7c478bd9Sstevel@tonic-gate * 199309L POSIX.1b-1993 compilation (Real Time) 46*7c478bd9Sstevel@tonic-gate * 199506L POSIX.1c-1995 compilation (POSIX Threads) 47*7c478bd9Sstevel@tonic-gate * 200112L POSIX.1-2001 compilation (Austin Group Revision) 48*7c478bd9Sstevel@tonic-gate */ 49*7c478bd9Sstevel@tonic-gate #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) 50*7c478bd9Sstevel@tonic-gate #define _POSIX_C_SOURCE 1 51*7c478bd9Sstevel@tonic-gate #endif 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate /* 54*7c478bd9Sstevel@tonic-gate * The feature test macros __XOPEN_OR_POSIX, _STRICT_STDC, and _STDC_C99 55*7c478bd9Sstevel@tonic-gate * are Sun implementation specific macros created in order to compress 56*7c478bd9Sstevel@tonic-gate * common standards specified feature test macros for easier reading. 57*7c478bd9Sstevel@tonic-gate * These macros should not be used by the application developer as 58*7c478bd9Sstevel@tonic-gate * unexpected results may occur. Instead, the user should reference 59*7c478bd9Sstevel@tonic-gate * standards(5) for correct usage of the standards feature test macros. 60*7c478bd9Sstevel@tonic-gate * 61*7c478bd9Sstevel@tonic-gate * __XOPEN_OR_POSIX Used in cases where a symbol is defined by both 62*7c478bd9Sstevel@tonic-gate * X/Open or POSIX or in the negative, when neither 63*7c478bd9Sstevel@tonic-gate * X/Open or POSIX defines a symbol. 64*7c478bd9Sstevel@tonic-gate * 65*7c478bd9Sstevel@tonic-gate * _STRICT_STDC __STDC__ is specified by the C Standards and defined 66*7c478bd9Sstevel@tonic-gate * by the compiler. For Sun compilers the value of 67*7c478bd9Sstevel@tonic-gate * __STDC__ is either 1, 0, or not defined based on the 68*7c478bd9Sstevel@tonic-gate * compilation mode (see cc(1)). When the value of 69*7c478bd9Sstevel@tonic-gate * __STDC__ is 1 and in the absence of any other feature 70*7c478bd9Sstevel@tonic-gate * test macros, the namespace available to the application 71*7c478bd9Sstevel@tonic-gate * is limited to only those symbols defined by the C 72*7c478bd9Sstevel@tonic-gate * Standard. _STRICT_STDC provides a more readable means 73*7c478bd9Sstevel@tonic-gate * of identifying symbols defined by the standard, or in 74*7c478bd9Sstevel@tonic-gate * the negative, symbols that are extensions to the C 75*7c478bd9Sstevel@tonic-gate * Standard. See additional comments for GNU C differences. 76*7c478bd9Sstevel@tonic-gate * 77*7c478bd9Sstevel@tonic-gate * _STDC_C99 __STDC_VERSION__ is specified by the C standards and 78*7c478bd9Sstevel@tonic-gate * defined by the compiler and indicates the version of 79*7c478bd9Sstevel@tonic-gate * the C standard. A value of 199901L indicates a 80*7c478bd9Sstevel@tonic-gate * compiler that complies with ISO/IEC 9899:1999, other- 81*7c478bd9Sstevel@tonic-gate * wise known as the C99 standard. 82*7c478bd9Sstevel@tonic-gate */ 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE) 85*7c478bd9Sstevel@tonic-gate #define __XOPEN_OR_POSIX 86*7c478bd9Sstevel@tonic-gate #endif 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate /* 89*7c478bd9Sstevel@tonic-gate * ISO/IEC 9899:1990 and it's revision, ISO/IEC 9899:1999 specify the 90*7c478bd9Sstevel@tonic-gate * following predefined macro name: 91*7c478bd9Sstevel@tonic-gate * 92*7c478bd9Sstevel@tonic-gate * __STDC__ The integer constant 1, intended to indicate a conforming 93*7c478bd9Sstevel@tonic-gate * implementation. 94*7c478bd9Sstevel@tonic-gate * 95*7c478bd9Sstevel@tonic-gate * Furthermore, a strictly conforming program shall use only those features 96*7c478bd9Sstevel@tonic-gate * of the language and library specified in these standards. A conforming 97*7c478bd9Sstevel@tonic-gate * implementation shall accept any strictly conforming program. 98*7c478bd9Sstevel@tonic-gate * 99*7c478bd9Sstevel@tonic-gate * Based on these requirements, Sun's C compiler defines __STDC__ to 1 for 100*7c478bd9Sstevel@tonic-gate * strictly conforming environments and __STDC__ to 0 for environments that 101*7c478bd9Sstevel@tonic-gate * use ANSI C semantics but allow extensions to the C standard. For non-ANSI 102*7c478bd9Sstevel@tonic-gate * C semantics, Sun's C compiler does not define __STDC__. 103*7c478bd9Sstevel@tonic-gate * 104*7c478bd9Sstevel@tonic-gate * The GNU C project interpretation is that __STDC__ should always be defined 105*7c478bd9Sstevel@tonic-gate * to 1 for compilation modes that accept ANSI C syntax regardless of whether 106*7c478bd9Sstevel@tonic-gate * or not extensions to the C standard are used. Violations of conforming 107*7c478bd9Sstevel@tonic-gate * behavior are conditionally flagged as warnings via the use of the 108*7c478bd9Sstevel@tonic-gate * -pedantic option. In addition to defining __STDC__ to 1, the GNU C 109*7c478bd9Sstevel@tonic-gate * compiler also defines __STRICT_ANSI__ as a means of specifying strictly 110*7c478bd9Sstevel@tonic-gate * conforming environments using the -ansi or -std=<standard> options. 111*7c478bd9Sstevel@tonic-gate * 112*7c478bd9Sstevel@tonic-gate * In the absence of any other compiler options, Sun and GNU set the value 113*7c478bd9Sstevel@tonic-gate * of __STDC__ as follows when using the following options: 114*7c478bd9Sstevel@tonic-gate * 115*7c478bd9Sstevel@tonic-gate * Value of __STDC__ __STRICT_ANSI__ 116*7c478bd9Sstevel@tonic-gate * 117*7c478bd9Sstevel@tonic-gate * cc -Xa (default) 0 undefined 118*7c478bd9Sstevel@tonic-gate * cc -Xt (transitional) 0 undefined 119*7c478bd9Sstevel@tonic-gate * cc -Xc (strictly conforming) 1 undefined 120*7c478bd9Sstevel@tonic-gate * cc -Xs (K&R C) undefined undefined 121*7c478bd9Sstevel@tonic-gate * 122*7c478bd9Sstevel@tonic-gate * gcc (default) 1 undefined 123*7c478bd9Sstevel@tonic-gate * gcc -ansi, -std={c89, c99,...) 1 defined 124*7c478bd9Sstevel@tonic-gate * gcc -traditional (K&R) undefined undefined 125*7c478bd9Sstevel@tonic-gate * 126*7c478bd9Sstevel@tonic-gate * The default compilation modes for Sun C compilers versus GNU C compilers 127*7c478bd9Sstevel@tonic-gate * results in a differing value for __STDC__ which results in a more 128*7c478bd9Sstevel@tonic-gate * restricted namespace when using Sun compilers. To allow both GNU and Sun 129*7c478bd9Sstevel@tonic-gate * interpretations to peacefully co-exist, we use the following Sun 130*7c478bd9Sstevel@tonic-gate * implementation _STRICT_STDC_ macro: 131*7c478bd9Sstevel@tonic-gate */ 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate #if (__STDC__ - 0 == 1 && !defined(__GNUC__)) || \ 134*7c478bd9Sstevel@tonic-gate (defined(__GNUC__) && defined(__STRICT_ANSI__)) 135*7c478bd9Sstevel@tonic-gate #define _STRICT_STDC 136*7c478bd9Sstevel@tonic-gate #else 137*7c478bd9Sstevel@tonic-gate #undef _STRICT_STDC 138*7c478bd9Sstevel@tonic-gate #endif 139*7c478bd9Sstevel@tonic-gate 140*7c478bd9Sstevel@tonic-gate /* 141*7c478bd9Sstevel@tonic-gate * Compiler complies with ISO/IEC 9899:1999 142*7c478bd9Sstevel@tonic-gate */ 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate #if __STDC_VERSION__ - 0 >= 199901L 145*7c478bd9Sstevel@tonic-gate #define _STDC_C99 146*7c478bd9Sstevel@tonic-gate #endif 147*7c478bd9Sstevel@tonic-gate 148*7c478bd9Sstevel@tonic-gate /* 149*7c478bd9Sstevel@tonic-gate * Large file interfaces: 150*7c478bd9Sstevel@tonic-gate * 151*7c478bd9Sstevel@tonic-gate * _LARGEFILE_SOURCE 152*7c478bd9Sstevel@tonic-gate * 1 large file-related additions to POSIX 153*7c478bd9Sstevel@tonic-gate * interfaces requested (fseeko, etc.) 154*7c478bd9Sstevel@tonic-gate * _LARGEFILE64_SOURCE 155*7c478bd9Sstevel@tonic-gate * 1 transitional large-file-related interfaces 156*7c478bd9Sstevel@tonic-gate * requested (seek64, stat64, etc.) 157*7c478bd9Sstevel@tonic-gate * 158*7c478bd9Sstevel@tonic-gate * The corresponding announcement macros are respectively: 159*7c478bd9Sstevel@tonic-gate * _LFS_LARGEFILE 160*7c478bd9Sstevel@tonic-gate * _LFS64_LARGEFILE 161*7c478bd9Sstevel@tonic-gate * (These are set in <unistd.h>.) 162*7c478bd9Sstevel@tonic-gate * 163*7c478bd9Sstevel@tonic-gate * Requesting _LARGEFILE64_SOURCE implies requesting _LARGEFILE_SOURCE as 164*7c478bd9Sstevel@tonic-gate * well. 165*7c478bd9Sstevel@tonic-gate * 166*7c478bd9Sstevel@tonic-gate * The large file interfaces are made visible regardless of the initial values 167*7c478bd9Sstevel@tonic-gate * of the feature test macros under certain circumstances: 168*7c478bd9Sstevel@tonic-gate * - If no explicit standards-conforming environment is requested (neither 169*7c478bd9Sstevel@tonic-gate * of _POSIX_SOURCE nor _XOPEN_SOURCE is defined and the value of 170*7c478bd9Sstevel@tonic-gate * __STDC__ does not imply standards conformance). 171*7c478bd9Sstevel@tonic-gate * - Extended system interfaces are explicitly requested (__EXTENSIONS__ 172*7c478bd9Sstevel@tonic-gate * is defined). 173*7c478bd9Sstevel@tonic-gate * - Access to in-kernel interfaces is requested (_KERNEL or _KMEMUSER is 174*7c478bd9Sstevel@tonic-gate * defined). (Note that this dependency is an artifact of the current 175*7c478bd9Sstevel@tonic-gate * kernel implementation and may change in future releases.) 176*7c478bd9Sstevel@tonic-gate */ 177*7c478bd9Sstevel@tonic-gate #if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ 178*7c478bd9Sstevel@tonic-gate defined(_KERNEL) || defined(_KMEMUSER) || \ 179*7c478bd9Sstevel@tonic-gate defined(__EXTENSIONS__) 180*7c478bd9Sstevel@tonic-gate #undef _LARGEFILE64_SOURCE 181*7c478bd9Sstevel@tonic-gate #define _LARGEFILE64_SOURCE 1 182*7c478bd9Sstevel@tonic-gate #endif 183*7c478bd9Sstevel@tonic-gate #if _LARGEFILE64_SOURCE - 0 == 1 184*7c478bd9Sstevel@tonic-gate #undef _LARGEFILE_SOURCE 185*7c478bd9Sstevel@tonic-gate #define _LARGEFILE_SOURCE 1 186*7c478bd9Sstevel@tonic-gate #endif 187*7c478bd9Sstevel@tonic-gate 188*7c478bd9Sstevel@tonic-gate /* 189*7c478bd9Sstevel@tonic-gate * Large file compilation environment control: 190*7c478bd9Sstevel@tonic-gate * 191*7c478bd9Sstevel@tonic-gate * The setting of _FILE_OFFSET_BITS controls the size of various file-related 192*7c478bd9Sstevel@tonic-gate * types and governs the mapping between file-related source function symbol 193*7c478bd9Sstevel@tonic-gate * names and the corresponding binary entry points. 194*7c478bd9Sstevel@tonic-gate * 195*7c478bd9Sstevel@tonic-gate * In the 32-bit environment, the default value is 32; if not set, set it to 196*7c478bd9Sstevel@tonic-gate * the default here, to simplify tests in other headers. 197*7c478bd9Sstevel@tonic-gate * 198*7c478bd9Sstevel@tonic-gate * In the 64-bit compilation environment, the only value allowed is 64. 199*7c478bd9Sstevel@tonic-gate */ 200*7c478bd9Sstevel@tonic-gate #if defined(_LP64) 201*7c478bd9Sstevel@tonic-gate #ifndef _FILE_OFFSET_BITS 202*7c478bd9Sstevel@tonic-gate #define _FILE_OFFSET_BITS 64 203*7c478bd9Sstevel@tonic-gate #endif 204*7c478bd9Sstevel@tonic-gate #if _FILE_OFFSET_BITS - 0 != 64 205*7c478bd9Sstevel@tonic-gate #error "invalid _FILE_OFFSET_BITS value specified" 206*7c478bd9Sstevel@tonic-gate #endif 207*7c478bd9Sstevel@tonic-gate #else /* _LP64 */ 208*7c478bd9Sstevel@tonic-gate #ifndef _FILE_OFFSET_BITS 209*7c478bd9Sstevel@tonic-gate #define _FILE_OFFSET_BITS 32 210*7c478bd9Sstevel@tonic-gate #endif 211*7c478bd9Sstevel@tonic-gate #if _FILE_OFFSET_BITS - 0 != 32 && _FILE_OFFSET_BITS - 0 != 64 212*7c478bd9Sstevel@tonic-gate #error "invalid _FILE_OFFSET_BITS value specified" 213*7c478bd9Sstevel@tonic-gate #endif 214*7c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate /* 217*7c478bd9Sstevel@tonic-gate * Use of _XOPEN_SOURCE 218*7c478bd9Sstevel@tonic-gate * 219*7c478bd9Sstevel@tonic-gate * The following X/Open specifications are supported: 220*7c478bd9Sstevel@tonic-gate * 221*7c478bd9Sstevel@tonic-gate * X/Open Portability Guide, Issue 3 (XPG3) 222*7c478bd9Sstevel@tonic-gate * X/Open CAE Specification, Issue 4 (XPG4) 223*7c478bd9Sstevel@tonic-gate * X/Open CAE Specification, Issue 4, Version 2 (XPG4v2) 224*7c478bd9Sstevel@tonic-gate * X/Open CAE Specification, Issue 5 (XPG5) 225*7c478bd9Sstevel@tonic-gate * Open Group Technical Standard, Issue 6 (XPG6), also referred to as 226*7c478bd9Sstevel@tonic-gate * IEEE Std. 1003.1-2001 and ISO/IEC 9945:2002. 227*7c478bd9Sstevel@tonic-gate * 228*7c478bd9Sstevel@tonic-gate * XPG4v2 is also referred to as UNIX 95 (SUS or SUSv1). 229*7c478bd9Sstevel@tonic-gate * XPG5 is also referred to as UNIX 98 or the Single Unix Specification, 230*7c478bd9Sstevel@tonic-gate * Version 2 (SUSv2) 231*7c478bd9Sstevel@tonic-gate * XPG6 is the result of a merge of the X/Open and POSIX specifications 232*7c478bd9Sstevel@tonic-gate * and as such is also referred to as IEEE Std. 1003.1-2001 in 233*7c478bd9Sstevel@tonic-gate * addition to UNIX 03 and SUSv3. 234*7c478bd9Sstevel@tonic-gate * 235*7c478bd9Sstevel@tonic-gate * When writing a conforming X/Open application, as per the specification 236*7c478bd9Sstevel@tonic-gate * requirements, the appropriate feature test macros must be defined at 237*7c478bd9Sstevel@tonic-gate * compile time. These are as follows. For more info, see standards(5). 238*7c478bd9Sstevel@tonic-gate * 239*7c478bd9Sstevel@tonic-gate * Feature Test Macro Specification 240*7c478bd9Sstevel@tonic-gate * ------------------------------------------------ ------------- 241*7c478bd9Sstevel@tonic-gate * _XOPEN_SOURCE XPG3 242*7c478bd9Sstevel@tonic-gate * _XOPEN_SOURCE && _XOPEN_VERSION = 4 XPG4 243*7c478bd9Sstevel@tonic-gate * _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1 XPG4v2 244*7c478bd9Sstevel@tonic-gate * _XOPEN_SOURCE = 500 XPG5 245*7c478bd9Sstevel@tonic-gate * _XOPEN_SOURCE = 600 (or POSIX_C_SOURCE=200112L) XPG6 246*7c478bd9Sstevel@tonic-gate * 247*7c478bd9Sstevel@tonic-gate * In order to simplify the guards within the headers, the following 248*7c478bd9Sstevel@tonic-gate * implementation private test macros have been created. Applications 249*7c478bd9Sstevel@tonic-gate * must NOT use these private test macros as unexpected results will 250*7c478bd9Sstevel@tonic-gate * occur. 251*7c478bd9Sstevel@tonic-gate * 252*7c478bd9Sstevel@tonic-gate * Note that in general, the use of these private macros is cumulative. 253*7c478bd9Sstevel@tonic-gate * For example, the use of _XPG3 with no other restrictions on the X/Open 254*7c478bd9Sstevel@tonic-gate * namespace will make the symbols visible for XPG3 through XPG6 255*7c478bd9Sstevel@tonic-gate * compilation environments. The use of _XPG4_2 with no other X/Open 256*7c478bd9Sstevel@tonic-gate * namespace restrictions indicates that the symbols were introduced in 257*7c478bd9Sstevel@tonic-gate * XPG4v2 and are therefore visible for XPG4v2 through XPG6 compilation 258*7c478bd9Sstevel@tonic-gate * environments, but not for XPG3 or XPG4 compilation environments. 259*7c478bd9Sstevel@tonic-gate * 260*7c478bd9Sstevel@tonic-gate * _XPG3 X/Open Portability Guide, Issue 3 (XPG3) 261*7c478bd9Sstevel@tonic-gate * _XPG4 X/Open CAE Specification, Issue 4 (XPG4) 262*7c478bd9Sstevel@tonic-gate * _XPG4_2 X/Open CAE Specification, Issue 4, Version 2 (XPG4v2/UNIX 95/SUS) 263*7c478bd9Sstevel@tonic-gate * _XPG5 X/Open CAE Specification, Issue 5 (XPG5/UNIX 98/SUSv2) 264*7c478bd9Sstevel@tonic-gate * _XPG6 Open Group Technical Standard, Issue 6 (XPG6/UNIX 03/SUSv3) 265*7c478bd9Sstevel@tonic-gate */ 266*7c478bd9Sstevel@tonic-gate 267*7c478bd9Sstevel@tonic-gate /* X/Open Portability Guide, Issue 3 */ 268*7c478bd9Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 < 500) && \ 269*7c478bd9Sstevel@tonic-gate (_XOPEN_VERSION - 0 < 4) && !defined(_XOPEN_SOURCE_EXTENDED) 270*7c478bd9Sstevel@tonic-gate #define _XPG3 271*7c478bd9Sstevel@tonic-gate /* X/Open CAE Specification, Issue 4 */ 272*7c478bd9Sstevel@tonic-gate #elif (defined(_XOPEN_SOURCE) && _XOPEN_VERSION - 0 == 4) 273*7c478bd9Sstevel@tonic-gate #define _XPG4 274*7c478bd9Sstevel@tonic-gate #define _XPG3 275*7c478bd9Sstevel@tonic-gate /* X/Open CAE Specification, Issue 4, Version 2 */ 276*7c478bd9Sstevel@tonic-gate #elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1) 277*7c478bd9Sstevel@tonic-gate #define _XPG4_2 278*7c478bd9Sstevel@tonic-gate #define _XPG4 279*7c478bd9Sstevel@tonic-gate #define _XPG3 280*7c478bd9Sstevel@tonic-gate /* X/Open CAE Specification, Issue 5 */ 281*7c478bd9Sstevel@tonic-gate #elif (_XOPEN_SOURCE - 0 == 500) 282*7c478bd9Sstevel@tonic-gate #define _XPG5 283*7c478bd9Sstevel@tonic-gate #define _XPG4_2 284*7c478bd9Sstevel@tonic-gate #define _XPG4 285*7c478bd9Sstevel@tonic-gate #define _XPG3 286*7c478bd9Sstevel@tonic-gate #undef _POSIX_C_SOURCE 287*7c478bd9Sstevel@tonic-gate #define _POSIX_C_SOURCE 199506L 288*7c478bd9Sstevel@tonic-gate /* Open Group Technical Standard , Issue 6 */ 289*7c478bd9Sstevel@tonic-gate #elif (_XOPEN_SOURCE - 0 == 600) || (_POSIX_C_SOURCE - 0 == 200112L) 290*7c478bd9Sstevel@tonic-gate #define _XPG6 291*7c478bd9Sstevel@tonic-gate #define _XPG5 292*7c478bd9Sstevel@tonic-gate #define _XPG4_2 293*7c478bd9Sstevel@tonic-gate #define _XPG4 294*7c478bd9Sstevel@tonic-gate #define _XPG3 295*7c478bd9Sstevel@tonic-gate #undef _POSIX_C_SOURCE 296*7c478bd9Sstevel@tonic-gate #define _POSIX_C_SOURCE 200112L 297*7c478bd9Sstevel@tonic-gate #undef _XOPEN_SOURCE 298*7c478bd9Sstevel@tonic-gate #define _XOPEN_SOURCE 600 299*7c478bd9Sstevel@tonic-gate #endif 300*7c478bd9Sstevel@tonic-gate 301*7c478bd9Sstevel@tonic-gate /* 302*7c478bd9Sstevel@tonic-gate * _XOPEN_VERSION is defined by the X/Open specifications and is not 303*7c478bd9Sstevel@tonic-gate * normally defined by the application, except in the case of an XPG4 304*7c478bd9Sstevel@tonic-gate * application. On the implementation side, _XOPEN_VERSION defined with 305*7c478bd9Sstevel@tonic-gate * the value of 3 indicates an XPG3 application. _XOPEN_VERSION defined 306*7c478bd9Sstevel@tonic-gate * with the value of 4 indicates an XPG4 or XPG4v2 (UNIX 95) application. 307*7c478bd9Sstevel@tonic-gate * _XOPEN_VERSION defined with a value of 500 indicates an XPG5 (UNIX 98) 308*7c478bd9Sstevel@tonic-gate * application and with a value of 600 indicates an XPG6 (UNIX 03) 309*7c478bd9Sstevel@tonic-gate * application. The appropriate version is determined by the use of the 310*7c478bd9Sstevel@tonic-gate * feature test macros described earlier. The value of _XOPEN_VERSION 311*7c478bd9Sstevel@tonic-gate * defaults to 3 otherwise indicating support for XPG3 applications. 312*7c478bd9Sstevel@tonic-gate */ 313*7c478bd9Sstevel@tonic-gate #ifndef _XOPEN_VERSION 314*7c478bd9Sstevel@tonic-gate #ifdef _XPG6 315*7c478bd9Sstevel@tonic-gate #define _XOPEN_VERSION 600 316*7c478bd9Sstevel@tonic-gate #elif defined(_XPG5) 317*7c478bd9Sstevel@tonic-gate #define _XOPEN_VERSION 500 318*7c478bd9Sstevel@tonic-gate #elif defined(_XPG4_2) 319*7c478bd9Sstevel@tonic-gate #define _XOPEN_VERSION 4 320*7c478bd9Sstevel@tonic-gate #else 321*7c478bd9Sstevel@tonic-gate #define _XOPEN_VERSION 3 322*7c478bd9Sstevel@tonic-gate #endif 323*7c478bd9Sstevel@tonic-gate #endif 324*7c478bd9Sstevel@tonic-gate 325*7c478bd9Sstevel@tonic-gate /* 326*7c478bd9Sstevel@tonic-gate * ANSI C and ISO 9899:1990 say the type long long doesn't exist in strictly 327*7c478bd9Sstevel@tonic-gate * conforming environments. ISO 9899:1999 says it does. 328*7c478bd9Sstevel@tonic-gate * 329*7c478bd9Sstevel@tonic-gate * The presence of _LONGLONG_TYPE says "long long exists" which is therefore 330*7c478bd9Sstevel@tonic-gate * defined in all but strictly conforming environments that disallow it. 331*7c478bd9Sstevel@tonic-gate */ 332*7c478bd9Sstevel@tonic-gate #if !defined(_STDC_C99) && defined(_STRICT_STDC) && !defined(__GNUC__) 333*7c478bd9Sstevel@tonic-gate /* 334*7c478bd9Sstevel@tonic-gate * Resist attempts to force the definition of long long in this case. 335*7c478bd9Sstevel@tonic-gate */ 336*7c478bd9Sstevel@tonic-gate #if defined(_LONGLONG_TYPE) 337*7c478bd9Sstevel@tonic-gate #error "No long long in strictly conforming ANSI C & 1990 ISO C environments" 338*7c478bd9Sstevel@tonic-gate #endif 339*7c478bd9Sstevel@tonic-gate #else 340*7c478bd9Sstevel@tonic-gate #if !defined(_LONGLONG_TYPE) 341*7c478bd9Sstevel@tonic-gate #define _LONGLONG_TYPE 342*7c478bd9Sstevel@tonic-gate #endif 343*7c478bd9Sstevel@tonic-gate #endif 344*7c478bd9Sstevel@tonic-gate 345*7c478bd9Sstevel@tonic-gate /* 346*7c478bd9Sstevel@tonic-gate * It is invalid to compile an XPG3, XPG4, XPG4v2, or XPG5 application 347*7c478bd9Sstevel@tonic-gate * using c99. The same is true for POSIX.1-1990, POSIX.2-1992, POSIX.1b, 348*7c478bd9Sstevel@tonic-gate * and POSIX.1c applications. Likewise, it is invalid to compile an XPG6 349*7c478bd9Sstevel@tonic-gate * or a POSIX.1-2001 application with anything other than a c99 or later 350*7c478bd9Sstevel@tonic-gate * compiler. Therefore, we force an error in both cases. 351*7c478bd9Sstevel@tonic-gate */ 352*7c478bd9Sstevel@tonic-gate #if defined(_STDC_C99) && (defined(__XOPEN_OR_POSIX) && !defined(_XPG6)) 353*7c478bd9Sstevel@tonic-gate #error "Compiler or options invalid for pre-UNIX 03 X/Open applications \ 354*7c478bd9Sstevel@tonic-gate and pre-2001 POSIX applications" 355*7c478bd9Sstevel@tonic-gate #elif !defined(_STDC_C99) && \ 356*7c478bd9Sstevel@tonic-gate (defined(__XOPEN_OR_POSIX) && defined(_XPG6)) 357*7c478bd9Sstevel@tonic-gate #error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \ 358*7c478bd9Sstevel@tonic-gate require the use of c99" 359*7c478bd9Sstevel@tonic-gate #endif 360*7c478bd9Sstevel@tonic-gate 361*7c478bd9Sstevel@tonic-gate /* 362*7c478bd9Sstevel@tonic-gate * The following macro defines a value for the ISO C99 restrict 363*7c478bd9Sstevel@tonic-gate * keyword so that _RESTRICT_KYWD resolves to "restrict" if 364*7c478bd9Sstevel@tonic-gate * an ISO C99 compiler is used and "" (null string) if any other 365*7c478bd9Sstevel@tonic-gate * compiler is used. This allows for the use of single prototype 366*7c478bd9Sstevel@tonic-gate * declarations regardless of compiler version. 367*7c478bd9Sstevel@tonic-gate */ 368*7c478bd9Sstevel@tonic-gate #if (defined(__STDC__) && defined(_STDC_C99)) 369*7c478bd9Sstevel@tonic-gate #define _RESTRICT_KYWD restrict 370*7c478bd9Sstevel@tonic-gate #else 371*7c478bd9Sstevel@tonic-gate #define _RESTRICT_KYWD 372*7c478bd9Sstevel@tonic-gate #endif 373*7c478bd9Sstevel@tonic-gate 374*7c478bd9Sstevel@tonic-gate /* 375*7c478bd9Sstevel@tonic-gate * The following macro indicates header support for the ANSI C++ 376*7c478bd9Sstevel@tonic-gate * standard. The ISO/IEC designation for this is ISO/IEC FDIS 14882. 377*7c478bd9Sstevel@tonic-gate */ 378*7c478bd9Sstevel@tonic-gate #define _ISO_CPP_14882_1998 379*7c478bd9Sstevel@tonic-gate 380*7c478bd9Sstevel@tonic-gate /* 381*7c478bd9Sstevel@tonic-gate * The following macro indicates header support for the C99 standard, 382*7c478bd9Sstevel@tonic-gate * ISO/IEC 9899:1999, Programming Languages - C. 383*7c478bd9Sstevel@tonic-gate */ 384*7c478bd9Sstevel@tonic-gate #define _ISO_C_9899_1999 385*7c478bd9Sstevel@tonic-gate 386*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387*7c478bd9Sstevel@tonic-gate } 388*7c478bd9Sstevel@tonic-gate #endif 389*7c478bd9Sstevel@tonic-gate 390*7c478bd9Sstevel@tonic-gate #endif /* _SYS_FEATURE_TESTS_H */ 391