xref: /onnv-gate/usr/src/uts/common/sys/feature_tests.h (revision 2769:b2e3d55c6e12)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*2769Sahl  * Common Development and Distribution License (the "License").
6*2769Sahl  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*2769Sahl 
220Sstevel@tonic-gate /*
23*2769Sahl  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef _SYS_FEATURE_TESTS_H
280Sstevel@tonic-gate #define	_SYS_FEATURE_TESTS_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <sys/ccompile.h>
330Sstevel@tonic-gate #include <sys/isa_defs.h>
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef	__cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate  * Values of _POSIX_C_SOURCE
410Sstevel@tonic-gate  *
420Sstevel@tonic-gate  *		undefined   not a POSIX compilation
430Sstevel@tonic-gate  *		1	    POSIX.1-1990 compilation
440Sstevel@tonic-gate  *		2	    POSIX.2-1992 compilation
450Sstevel@tonic-gate  *		199309L	    POSIX.1b-1993 compilation (Real Time)
460Sstevel@tonic-gate  *		199506L	    POSIX.1c-1995 compilation (POSIX Threads)
470Sstevel@tonic-gate  *		200112L	    POSIX.1-2001 compilation (Austin Group Revision)
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
500Sstevel@tonic-gate #define	_POSIX_C_SOURCE 1
510Sstevel@tonic-gate #endif
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /*
540Sstevel@tonic-gate  * The feature test macros __XOPEN_OR_POSIX, _STRICT_STDC, and _STDC_C99
550Sstevel@tonic-gate  * are Sun implementation specific macros created in order to compress
560Sstevel@tonic-gate  * common standards specified feature test macros for easier reading.
570Sstevel@tonic-gate  * These macros should not be used by the application developer as
580Sstevel@tonic-gate  * unexpected results may occur. Instead, the user should reference
590Sstevel@tonic-gate  * standards(5) for correct usage of the standards feature test macros.
600Sstevel@tonic-gate  *
610Sstevel@tonic-gate  * __XOPEN_OR_POSIX     Used in cases where a symbol is defined by both
620Sstevel@tonic-gate  *                      X/Open or POSIX or in the negative, when neither
630Sstevel@tonic-gate  *                      X/Open or POSIX defines a symbol.
640Sstevel@tonic-gate  *
650Sstevel@tonic-gate  * _STRICT_STDC         __STDC__ is specified by the C Standards and defined
660Sstevel@tonic-gate  *                      by the compiler. For Sun compilers the value of
670Sstevel@tonic-gate  *                      __STDC__ is either 1, 0, or not defined based on the
680Sstevel@tonic-gate  *                      compilation mode (see cc(1)). When the value of
690Sstevel@tonic-gate  *                      __STDC__ is 1 and in the absence of any other feature
700Sstevel@tonic-gate  *                      test macros, the namespace available to the application
710Sstevel@tonic-gate  *                      is limited to only those symbols defined by the C
720Sstevel@tonic-gate  *                      Standard. _STRICT_STDC provides a more readable means
730Sstevel@tonic-gate  *                      of identifying symbols defined by the standard, or in
740Sstevel@tonic-gate  *                      the negative, symbols that are extensions to the C
750Sstevel@tonic-gate  *                      Standard. See additional comments for GNU C differences.
760Sstevel@tonic-gate  *
770Sstevel@tonic-gate  * _STDC_C99            __STDC_VERSION__ is specified by the C standards and
780Sstevel@tonic-gate  *                      defined by the compiler and indicates the version of
790Sstevel@tonic-gate  *                      the C standard. A value of 199901L indicates a
800Sstevel@tonic-gate  *                      compiler that complies with ISO/IEC 9899:1999, other-
810Sstevel@tonic-gate  *                      wise known as the C99 standard.
820Sstevel@tonic-gate  */
830Sstevel@tonic-gate 
840Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE)
850Sstevel@tonic-gate #define	__XOPEN_OR_POSIX
860Sstevel@tonic-gate #endif
870Sstevel@tonic-gate 
880Sstevel@tonic-gate /*
890Sstevel@tonic-gate  * ISO/IEC 9899:1990 and it's revision, ISO/IEC 9899:1999 specify the
900Sstevel@tonic-gate  * following predefined macro name:
910Sstevel@tonic-gate  *
920Sstevel@tonic-gate  * __STDC__	The integer constant 1, intended to indicate a conforming
930Sstevel@tonic-gate  *		implementation.
940Sstevel@tonic-gate  *
950Sstevel@tonic-gate  * Furthermore, a strictly conforming program shall use only those features
960Sstevel@tonic-gate  * of the language and library specified in these standards. A conforming
970Sstevel@tonic-gate  * implementation shall accept any strictly conforming program.
980Sstevel@tonic-gate  *
990Sstevel@tonic-gate  * Based on these requirements, Sun's C compiler defines __STDC__ to 1 for
1000Sstevel@tonic-gate  * strictly conforming environments and __STDC__ to 0 for environments that
1010Sstevel@tonic-gate  * use ANSI C semantics but allow extensions to the C standard. For non-ANSI
1020Sstevel@tonic-gate  * C semantics, Sun's C compiler does not define __STDC__.
1030Sstevel@tonic-gate  *
1040Sstevel@tonic-gate  * The GNU C project interpretation is that __STDC__ should always be defined
1050Sstevel@tonic-gate  * to 1 for compilation modes that accept ANSI C syntax regardless of whether
1060Sstevel@tonic-gate  * or not extensions to the C standard are used. Violations of conforming
1070Sstevel@tonic-gate  * behavior are conditionally flagged as warnings via the use of the
1080Sstevel@tonic-gate  * -pedantic option. In addition to defining __STDC__ to 1, the GNU C
1090Sstevel@tonic-gate  * compiler also defines __STRICT_ANSI__ as a means of specifying strictly
1100Sstevel@tonic-gate  * conforming environments using the -ansi or -std=<standard> options.
1110Sstevel@tonic-gate  *
1120Sstevel@tonic-gate  * In the absence of any other compiler options, Sun and GNU set the value
1130Sstevel@tonic-gate  * of __STDC__ as follows when using the following options:
1140Sstevel@tonic-gate  *
1150Sstevel@tonic-gate  *				Value of __STDC__  __STRICT_ANSI__
1160Sstevel@tonic-gate  *
1170Sstevel@tonic-gate  * cc -Xa (default)			0	      undefined
1180Sstevel@tonic-gate  * cc -Xt (transitional)		0             undefined
1190Sstevel@tonic-gate  * cc -Xc (strictly conforming)		1	      undefined
1200Sstevel@tonic-gate  * cc -Xs (K&R C)		    undefined	      undefined
1210Sstevel@tonic-gate  *
1220Sstevel@tonic-gate  * gcc (default)			1	      undefined
1230Sstevel@tonic-gate  * gcc -ansi, -std={c89, c99,...)  	1              defined
1240Sstevel@tonic-gate  * gcc -traditional (K&R)	    undefined	      undefined
1250Sstevel@tonic-gate  *
1260Sstevel@tonic-gate  * The default compilation modes for Sun C compilers versus GNU C compilers
1270Sstevel@tonic-gate  * results in a differing value for __STDC__ which results in a more
1280Sstevel@tonic-gate  * restricted namespace when using Sun compilers. To allow both GNU and Sun
1290Sstevel@tonic-gate  * interpretations to peacefully co-exist, we use the following Sun
1300Sstevel@tonic-gate  * implementation _STRICT_STDC_ macro:
1310Sstevel@tonic-gate  */
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate #if (__STDC__ - 0 == 1 && !defined(__GNUC__)) || \
1340Sstevel@tonic-gate 	(defined(__GNUC__) && defined(__STRICT_ANSI__))
1350Sstevel@tonic-gate #define	_STRICT_STDC
1360Sstevel@tonic-gate #else
1370Sstevel@tonic-gate #undef	_STRICT_STDC
1380Sstevel@tonic-gate #endif
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate /*
1410Sstevel@tonic-gate  * Compiler complies with ISO/IEC 9899:1999
1420Sstevel@tonic-gate  */
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate #if __STDC_VERSION__ - 0 >= 199901L
1450Sstevel@tonic-gate #define	_STDC_C99
1460Sstevel@tonic-gate #endif
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate /*
1490Sstevel@tonic-gate  * Large file interfaces:
1500Sstevel@tonic-gate  *
1510Sstevel@tonic-gate  *	_LARGEFILE_SOURCE
1520Sstevel@tonic-gate  *		1		large file-related additions to POSIX
1530Sstevel@tonic-gate  *				interfaces requested (fseeko, etc.)
1540Sstevel@tonic-gate  *	_LARGEFILE64_SOURCE
1550Sstevel@tonic-gate  *		1		transitional large-file-related interfaces
1560Sstevel@tonic-gate  *				requested (seek64, stat64, etc.)
1570Sstevel@tonic-gate  *
1580Sstevel@tonic-gate  * The corresponding announcement macros are respectively:
1590Sstevel@tonic-gate  *	_LFS_LARGEFILE
1600Sstevel@tonic-gate  *	_LFS64_LARGEFILE
1610Sstevel@tonic-gate  * (These are set in <unistd.h>.)
1620Sstevel@tonic-gate  *
1630Sstevel@tonic-gate  * Requesting _LARGEFILE64_SOURCE implies requesting _LARGEFILE_SOURCE as
1640Sstevel@tonic-gate  * well.
1650Sstevel@tonic-gate  *
1660Sstevel@tonic-gate  * The large file interfaces are made visible regardless of the initial values
1670Sstevel@tonic-gate  * of the feature test macros under certain circumstances:
1680Sstevel@tonic-gate  *    -	If no explicit standards-conforming environment is requested (neither
1690Sstevel@tonic-gate  *	of _POSIX_SOURCE nor _XOPEN_SOURCE is defined and the value of
1700Sstevel@tonic-gate  *	__STDC__ does not imply standards conformance).
1710Sstevel@tonic-gate  *    -	Extended system interfaces are explicitly requested (__EXTENSIONS__
1720Sstevel@tonic-gate  * 	is defined).
1730Sstevel@tonic-gate  *    -	Access to in-kernel interfaces is requested (_KERNEL or _KMEMUSER is
1740Sstevel@tonic-gate  *	defined).  (Note that this dependency is an artifact of the current
1750Sstevel@tonic-gate  *	kernel implementation and may change in future releases.)
1760Sstevel@tonic-gate  */
1770Sstevel@tonic-gate #if	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
1780Sstevel@tonic-gate 		defined(_KERNEL) || defined(_KMEMUSER) || \
1790Sstevel@tonic-gate 		defined(__EXTENSIONS__)
1800Sstevel@tonic-gate #undef	_LARGEFILE64_SOURCE
1810Sstevel@tonic-gate #define	_LARGEFILE64_SOURCE	1
1820Sstevel@tonic-gate #endif
1830Sstevel@tonic-gate #if	_LARGEFILE64_SOURCE - 0 == 1
1840Sstevel@tonic-gate #undef	_LARGEFILE_SOURCE
1850Sstevel@tonic-gate #define	_LARGEFILE_SOURCE	1
1860Sstevel@tonic-gate #endif
1870Sstevel@tonic-gate 
1880Sstevel@tonic-gate /*
1890Sstevel@tonic-gate  * Large file compilation environment control:
1900Sstevel@tonic-gate  *
1910Sstevel@tonic-gate  * The setting of _FILE_OFFSET_BITS controls the size of various file-related
1920Sstevel@tonic-gate  * types and governs the mapping between file-related source function symbol
1930Sstevel@tonic-gate  * names and the corresponding binary entry points.
1940Sstevel@tonic-gate  *
1950Sstevel@tonic-gate  * In the 32-bit environment, the default value is 32; if not set, set it to
1960Sstevel@tonic-gate  * the default here, to simplify tests in other headers.
1970Sstevel@tonic-gate  *
1980Sstevel@tonic-gate  * In the 64-bit compilation environment, the only value allowed is 64.
1990Sstevel@tonic-gate  */
2000Sstevel@tonic-gate #if defined(_LP64)
2010Sstevel@tonic-gate #ifndef _FILE_OFFSET_BITS
2020Sstevel@tonic-gate #define	_FILE_OFFSET_BITS	64
2030Sstevel@tonic-gate #endif
2040Sstevel@tonic-gate #if	_FILE_OFFSET_BITS - 0 != 64
2050Sstevel@tonic-gate #error	"invalid _FILE_OFFSET_BITS value specified"
2060Sstevel@tonic-gate #endif
2070Sstevel@tonic-gate #else	/* _LP64 */
2080Sstevel@tonic-gate #ifndef	_FILE_OFFSET_BITS
2090Sstevel@tonic-gate #define	_FILE_OFFSET_BITS	32
2100Sstevel@tonic-gate #endif
2110Sstevel@tonic-gate #if	_FILE_OFFSET_BITS - 0 != 32 && _FILE_OFFSET_BITS - 0 != 64
2120Sstevel@tonic-gate #error	"invalid _FILE_OFFSET_BITS value specified"
2130Sstevel@tonic-gate #endif
2140Sstevel@tonic-gate #endif	/* _LP64 */
2150Sstevel@tonic-gate 
2160Sstevel@tonic-gate /*
2170Sstevel@tonic-gate  * Use of _XOPEN_SOURCE
2180Sstevel@tonic-gate  *
2190Sstevel@tonic-gate  * The following X/Open specifications are supported:
2200Sstevel@tonic-gate  *
2210Sstevel@tonic-gate  * X/Open Portability Guide, Issue 3 (XPG3)
2220Sstevel@tonic-gate  * X/Open CAE Specification, Issue 4 (XPG4)
2230Sstevel@tonic-gate  * X/Open CAE Specification, Issue 4, Version 2 (XPG4v2)
2240Sstevel@tonic-gate  * X/Open CAE Specification, Issue 5 (XPG5)
2250Sstevel@tonic-gate  * Open Group Technical Standard, Issue 6 (XPG6), also referred to as
2260Sstevel@tonic-gate  *    IEEE Std. 1003.1-2001 and ISO/IEC 9945:2002.
2270Sstevel@tonic-gate  *
2280Sstevel@tonic-gate  * XPG4v2 is also referred to as UNIX 95 (SUS or SUSv1).
2290Sstevel@tonic-gate  * XPG5 is also referred to as UNIX 98 or the Single Unix Specification,
2300Sstevel@tonic-gate  *     Version 2 (SUSv2)
2310Sstevel@tonic-gate  * XPG6 is the result of a merge of the X/Open and POSIX specifications
2320Sstevel@tonic-gate  *     and as such is also referred to as IEEE Std. 1003.1-2001 in
2330Sstevel@tonic-gate  *     addition to UNIX 03 and SUSv3.
2340Sstevel@tonic-gate  *
2350Sstevel@tonic-gate  * When writing a conforming X/Open application, as per the specification
2360Sstevel@tonic-gate  * requirements, the appropriate feature test macros must be defined at
2370Sstevel@tonic-gate  * compile time. These are as follows. For more info, see standards(5).
2380Sstevel@tonic-gate  *
2390Sstevel@tonic-gate  * Feature Test Macro				     Specification
2400Sstevel@tonic-gate  * ------------------------------------------------  -------------
2410Sstevel@tonic-gate  * _XOPEN_SOURCE                                         XPG3
2420Sstevel@tonic-gate  * _XOPEN_SOURCE && _XOPEN_VERSION = 4                   XPG4
2430Sstevel@tonic-gate  * _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1           XPG4v2
2440Sstevel@tonic-gate  * _XOPEN_SOURCE = 500                                   XPG5
2450Sstevel@tonic-gate  * _XOPEN_SOURCE = 600  (or POSIX_C_SOURCE=200112L)      XPG6
2460Sstevel@tonic-gate  *
2470Sstevel@tonic-gate  * In order to simplify the guards within the headers, the following
2480Sstevel@tonic-gate  * implementation private test macros have been created. Applications
2490Sstevel@tonic-gate  * must NOT use these private test macros as unexpected results will
2500Sstevel@tonic-gate  * occur.
2510Sstevel@tonic-gate  *
2520Sstevel@tonic-gate  * Note that in general, the use of these private macros is cumulative.
2530Sstevel@tonic-gate  * For example, the use of _XPG3 with no other restrictions on the X/Open
2540Sstevel@tonic-gate  * namespace will make the symbols visible for XPG3 through XPG6
2550Sstevel@tonic-gate  * compilation environments. The use of _XPG4_2 with no other X/Open
2560Sstevel@tonic-gate  * namespace restrictions indicates that the symbols were introduced in
2570Sstevel@tonic-gate  * XPG4v2 and are therefore visible for XPG4v2 through XPG6 compilation
2580Sstevel@tonic-gate  * environments, but not for XPG3 or XPG4 compilation environments.
2590Sstevel@tonic-gate  *
2600Sstevel@tonic-gate  * _XPG3    X/Open Portability Guide, Issue 3 (XPG3)
2610Sstevel@tonic-gate  * _XPG4    X/Open CAE Specification, Issue 4 (XPG4)
2620Sstevel@tonic-gate  * _XPG4_2  X/Open CAE Specification, Issue 4, Version 2 (XPG4v2/UNIX 95/SUS)
2630Sstevel@tonic-gate  * _XPG5    X/Open CAE Specification, Issue 5 (XPG5/UNIX 98/SUSv2)
2640Sstevel@tonic-gate  * _XPG6    Open Group Technical Standard, Issue 6 (XPG6/UNIX 03/SUSv3)
2650Sstevel@tonic-gate  */
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate /* X/Open Portability Guide, Issue 3 */
2680Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 < 500) && \
2690Sstevel@tonic-gate 	(_XOPEN_VERSION - 0 < 4) && !defined(_XOPEN_SOURCE_EXTENDED)
2700Sstevel@tonic-gate #define	_XPG3
2710Sstevel@tonic-gate /* X/Open CAE Specification, Issue 4 */
2720Sstevel@tonic-gate #elif	(defined(_XOPEN_SOURCE) && _XOPEN_VERSION - 0 == 4)
2730Sstevel@tonic-gate #define	_XPG4
2740Sstevel@tonic-gate #define	_XPG3
2750Sstevel@tonic-gate /* X/Open CAE Specification, Issue 4, Version 2 */
2760Sstevel@tonic-gate #elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1)
2770Sstevel@tonic-gate #define	_XPG4_2
2780Sstevel@tonic-gate #define	_XPG4
2790Sstevel@tonic-gate #define	_XPG3
2800Sstevel@tonic-gate /* X/Open CAE Specification, Issue 5 */
2810Sstevel@tonic-gate #elif	(_XOPEN_SOURCE - 0 == 500)
2820Sstevel@tonic-gate #define	_XPG5
2830Sstevel@tonic-gate #define	_XPG4_2
2840Sstevel@tonic-gate #define	_XPG4
2850Sstevel@tonic-gate #define	_XPG3
2860Sstevel@tonic-gate #undef	_POSIX_C_SOURCE
2870Sstevel@tonic-gate #define	_POSIX_C_SOURCE			199506L
2880Sstevel@tonic-gate /* Open Group Technical Standard , Issue 6 */
2890Sstevel@tonic-gate #elif	(_XOPEN_SOURCE - 0 == 600) || (_POSIX_C_SOURCE - 0 == 200112L)
2900Sstevel@tonic-gate #define	_XPG6
2910Sstevel@tonic-gate #define	_XPG5
2920Sstevel@tonic-gate #define	_XPG4_2
2930Sstevel@tonic-gate #define	_XPG4
2940Sstevel@tonic-gate #define	_XPG3
2950Sstevel@tonic-gate #undef	_POSIX_C_SOURCE
2960Sstevel@tonic-gate #define	_POSIX_C_SOURCE			200112L
2970Sstevel@tonic-gate #undef	_XOPEN_SOURCE
2980Sstevel@tonic-gate #define	_XOPEN_SOURCE			600
2990Sstevel@tonic-gate #endif
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate /*
3020Sstevel@tonic-gate  * _XOPEN_VERSION is defined by the X/Open specifications and is not
3030Sstevel@tonic-gate  * normally defined by the application, except in the case of an XPG4
3040Sstevel@tonic-gate  * application.  On the implementation side, _XOPEN_VERSION defined with
3050Sstevel@tonic-gate  * the value of 3 indicates an XPG3 application. _XOPEN_VERSION defined
3060Sstevel@tonic-gate  * with the value of 4 indicates an XPG4 or XPG4v2 (UNIX 95) application.
3070Sstevel@tonic-gate  * _XOPEN_VERSION  defined with a value of 500 indicates an XPG5 (UNIX 98)
3080Sstevel@tonic-gate  * application and with a value of 600 indicates an XPG6 (UNIX 03)
3090Sstevel@tonic-gate  * application.  The appropriate version is determined by the use of the
3100Sstevel@tonic-gate  * feature test macros described earlier.  The value of _XOPEN_VERSION
3110Sstevel@tonic-gate  * defaults to 3 otherwise indicating support for XPG3 applications.
3120Sstevel@tonic-gate  */
3130Sstevel@tonic-gate #ifndef _XOPEN_VERSION
3140Sstevel@tonic-gate #ifdef	_XPG6
3150Sstevel@tonic-gate #define	_XOPEN_VERSION 600
3160Sstevel@tonic-gate #elif defined(_XPG5)
3170Sstevel@tonic-gate #define	_XOPEN_VERSION 500
3180Sstevel@tonic-gate #elif	defined(_XPG4_2)
3190Sstevel@tonic-gate #define	_XOPEN_VERSION  4
3200Sstevel@tonic-gate #else
3210Sstevel@tonic-gate #define	_XOPEN_VERSION  3
3220Sstevel@tonic-gate #endif
3230Sstevel@tonic-gate #endif
3240Sstevel@tonic-gate 
3250Sstevel@tonic-gate /*
3260Sstevel@tonic-gate  * ANSI C and ISO 9899:1990 say the type long long doesn't exist in strictly
3270Sstevel@tonic-gate  * conforming environments.  ISO 9899:1999 says it does.
3280Sstevel@tonic-gate  *
3290Sstevel@tonic-gate  * The presence of _LONGLONG_TYPE says "long long exists" which is therefore
3300Sstevel@tonic-gate  * defined in all but strictly conforming environments that disallow it.
3310Sstevel@tonic-gate  */
3320Sstevel@tonic-gate #if !defined(_STDC_C99) && defined(_STRICT_STDC) && !defined(__GNUC__)
3330Sstevel@tonic-gate /*
3340Sstevel@tonic-gate  * Resist attempts to force the definition of long long in this case.
3350Sstevel@tonic-gate  */
3360Sstevel@tonic-gate #if defined(_LONGLONG_TYPE)
3370Sstevel@tonic-gate #error	"No long long in strictly conforming ANSI C & 1990 ISO C environments"
3380Sstevel@tonic-gate #endif
3390Sstevel@tonic-gate #else
3400Sstevel@tonic-gate #if !defined(_LONGLONG_TYPE)
3410Sstevel@tonic-gate #define	_LONGLONG_TYPE
3420Sstevel@tonic-gate #endif
3430Sstevel@tonic-gate #endif
3440Sstevel@tonic-gate 
3450Sstevel@tonic-gate /*
3460Sstevel@tonic-gate  * It is invalid to compile an XPG3, XPG4, XPG4v2, or XPG5 application
3470Sstevel@tonic-gate  * using c99.  The same is true for POSIX.1-1990, POSIX.2-1992, POSIX.1b,
3480Sstevel@tonic-gate  * and POSIX.1c applications. Likewise, it is invalid to compile an XPG6
3490Sstevel@tonic-gate  * or a POSIX.1-2001 application with anything other than a c99 or later
3500Sstevel@tonic-gate  * compiler.  Therefore, we force an error in both cases.
3510Sstevel@tonic-gate  */
3520Sstevel@tonic-gate #if defined(_STDC_C99) && (defined(__XOPEN_OR_POSIX) && !defined(_XPG6))
3530Sstevel@tonic-gate #error "Compiler or options invalid for pre-UNIX 03 X/Open applications \
3540Sstevel@tonic-gate 	and pre-2001 POSIX applications"
3550Sstevel@tonic-gate #elif !defined(_STDC_C99) && \
3560Sstevel@tonic-gate 	(defined(__XOPEN_OR_POSIX) && defined(_XPG6))
3570Sstevel@tonic-gate #error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \
3580Sstevel@tonic-gate 	require the use of c99"
3590Sstevel@tonic-gate #endif
3600Sstevel@tonic-gate 
3610Sstevel@tonic-gate /*
3620Sstevel@tonic-gate  * The following macro defines a value for the ISO C99 restrict
3630Sstevel@tonic-gate  * keyword so that _RESTRICT_KYWD resolves to "restrict" if
3640Sstevel@tonic-gate  * an ISO C99 compiler is used and "" (null string) if any other
3650Sstevel@tonic-gate  * compiler is used. This allows for the use of single prototype
3660Sstevel@tonic-gate  * declarations regardless of compiler version.
3670Sstevel@tonic-gate  */
3680Sstevel@tonic-gate #if (defined(__STDC__) && defined(_STDC_C99))
3690Sstevel@tonic-gate #define	_RESTRICT_KYWD	restrict
3700Sstevel@tonic-gate #else
3710Sstevel@tonic-gate #define	_RESTRICT_KYWD
3720Sstevel@tonic-gate #endif
3730Sstevel@tonic-gate 
3740Sstevel@tonic-gate /*
3750Sstevel@tonic-gate  * The following macro indicates header support for the ANSI C++
3760Sstevel@tonic-gate  * standard.  The ISO/IEC designation for this is ISO/IEC FDIS 14882.
3770Sstevel@tonic-gate  */
3780Sstevel@tonic-gate #define	_ISO_CPP_14882_1998
3790Sstevel@tonic-gate 
3800Sstevel@tonic-gate /*
3810Sstevel@tonic-gate  * The following macro indicates header support for the C99 standard,
3820Sstevel@tonic-gate  * ISO/IEC 9899:1999, Programming Languages - C.
3830Sstevel@tonic-gate  */
3840Sstevel@tonic-gate #define	_ISO_C_9899_1999
3850Sstevel@tonic-gate 
386*2769Sahl /*
387*2769Sahl  * The following macro indicates header support for DTrace. The value is an
388*2769Sahl  * integer that corresponds to the major version number for DTrace.
389*2769Sahl  */
390*2769Sahl #define	_DTRACE_VERSION	1
391*2769Sahl 
3920Sstevel@tonic-gate #ifdef	__cplusplus
3930Sstevel@tonic-gate }
3940Sstevel@tonic-gate #endif
3950Sstevel@tonic-gate 
3960Sstevel@tonic-gate #endif	/* _SYS_FEATURE_TESTS_H */
397