17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52b6e762cSahl * Common Development and Distribution License (the "License"). 62b6e762cSahl * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 212b6e762cSahl 227c478bd9Sstevel@tonic-gate /* 23*ba3594baSGarrett D'Amore * Copyright 2013 Garrett D'Amore <garrett@damore.org> 24*ba3594baSGarrett D'Amore * 252b6e762cSahl * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 267c478bd9Sstevel@tonic-gate * Use is subject to license terms. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _SYS_FEATURE_TESTS_H 307c478bd9Sstevel@tonic-gate #define _SYS_FEATURE_TESTS_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <sys/ccompile.h> 337c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* 407c478bd9Sstevel@tonic-gate * Values of _POSIX_C_SOURCE 417c478bd9Sstevel@tonic-gate * 427c478bd9Sstevel@tonic-gate * undefined not a POSIX compilation 437c478bd9Sstevel@tonic-gate * 1 POSIX.1-1990 compilation 447c478bd9Sstevel@tonic-gate * 2 POSIX.2-1992 compilation 457c478bd9Sstevel@tonic-gate * 199309L POSIX.1b-1993 compilation (Real Time) 467c478bd9Sstevel@tonic-gate * 199506L POSIX.1c-1995 compilation (POSIX Threads) 477c478bd9Sstevel@tonic-gate * 200112L POSIX.1-2001 compilation (Austin Group Revision) 482d08521bSGarrett D'Amore * 200809L POSIX.1-2008 compilation 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) 517c478bd9Sstevel@tonic-gate #define _POSIX_C_SOURCE 1 527c478bd9Sstevel@tonic-gate #endif 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* 552d08521bSGarrett D'Amore * The feature test macros __XOPEN_OR_POSIX, _STRICT_STDC, _STRICT_SYMBOLS, 562d08521bSGarrett D'Amore * and _STDC_C99 are Sun implementation specific macros created in order to 572d08521bSGarrett D'Amore * compress common standards specified feature test macros for easier reading. 587c478bd9Sstevel@tonic-gate * These macros should not be used by the application developer as 597c478bd9Sstevel@tonic-gate * unexpected results may occur. Instead, the user should reference 607c478bd9Sstevel@tonic-gate * standards(5) for correct usage of the standards feature test macros. 617c478bd9Sstevel@tonic-gate * 627c478bd9Sstevel@tonic-gate * __XOPEN_OR_POSIX Used in cases where a symbol is defined by both 637c478bd9Sstevel@tonic-gate * X/Open or POSIX or in the negative, when neither 647c478bd9Sstevel@tonic-gate * X/Open or POSIX defines a symbol. 657c478bd9Sstevel@tonic-gate * 667c478bd9Sstevel@tonic-gate * _STRICT_STDC __STDC__ is specified by the C Standards and defined 677c478bd9Sstevel@tonic-gate * by the compiler. For Sun compilers the value of 687c478bd9Sstevel@tonic-gate * __STDC__ is either 1, 0, or not defined based on the 697c478bd9Sstevel@tonic-gate * compilation mode (see cc(1)). When the value of 707c478bd9Sstevel@tonic-gate * __STDC__ is 1 and in the absence of any other feature 717c478bd9Sstevel@tonic-gate * test macros, the namespace available to the application 727c478bd9Sstevel@tonic-gate * is limited to only those symbols defined by the C 737c478bd9Sstevel@tonic-gate * Standard. _STRICT_STDC provides a more readable means 747c478bd9Sstevel@tonic-gate * of identifying symbols defined by the standard, or in 757c478bd9Sstevel@tonic-gate * the negative, symbols that are extensions to the C 767c478bd9Sstevel@tonic-gate * Standard. See additional comments for GNU C differences. 777c478bd9Sstevel@tonic-gate * 787c478bd9Sstevel@tonic-gate * _STDC_C99 __STDC_VERSION__ is specified by the C standards and 797c478bd9Sstevel@tonic-gate * defined by the compiler and indicates the version of 807c478bd9Sstevel@tonic-gate * the C standard. A value of 199901L indicates a 817c478bd9Sstevel@tonic-gate * compiler that complies with ISO/IEC 9899:1999, other- 827c478bd9Sstevel@tonic-gate * wise known as the C99 standard. 832d08521bSGarrett D'Amore * 842d08521bSGarrett D'Amore * _STRICT_SYMBOLS Used in cases where symbol visibility is restricted 852d08521bSGarrett D'Amore * by the standards, and the user has not explicitly 862d08521bSGarrett D'Amore * relaxed the strictness via __EXTENSIONS__. 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE) 907c478bd9Sstevel@tonic-gate #define __XOPEN_OR_POSIX 917c478bd9Sstevel@tonic-gate #endif 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * ISO/IEC 9899:1990 and it's revision, ISO/IEC 9899:1999 specify the 957c478bd9Sstevel@tonic-gate * following predefined macro name: 967c478bd9Sstevel@tonic-gate * 977c478bd9Sstevel@tonic-gate * __STDC__ The integer constant 1, intended to indicate a conforming 987c478bd9Sstevel@tonic-gate * implementation. 997c478bd9Sstevel@tonic-gate * 1007c478bd9Sstevel@tonic-gate * Furthermore, a strictly conforming program shall use only those features 1017c478bd9Sstevel@tonic-gate * of the language and library specified in these standards. A conforming 1027c478bd9Sstevel@tonic-gate * implementation shall accept any strictly conforming program. 1037c478bd9Sstevel@tonic-gate * 1047c478bd9Sstevel@tonic-gate * Based on these requirements, Sun's C compiler defines __STDC__ to 1 for 1057c478bd9Sstevel@tonic-gate * strictly conforming environments and __STDC__ to 0 for environments that 1067c478bd9Sstevel@tonic-gate * use ANSI C semantics but allow extensions to the C standard. For non-ANSI 1077c478bd9Sstevel@tonic-gate * C semantics, Sun's C compiler does not define __STDC__. 1087c478bd9Sstevel@tonic-gate * 1097c478bd9Sstevel@tonic-gate * The GNU C project interpretation is that __STDC__ should always be defined 1107c478bd9Sstevel@tonic-gate * to 1 for compilation modes that accept ANSI C syntax regardless of whether 1117c478bd9Sstevel@tonic-gate * or not extensions to the C standard are used. Violations of conforming 1127c478bd9Sstevel@tonic-gate * behavior are conditionally flagged as warnings via the use of the 1137c478bd9Sstevel@tonic-gate * -pedantic option. In addition to defining __STDC__ to 1, the GNU C 1147c478bd9Sstevel@tonic-gate * compiler also defines __STRICT_ANSI__ as a means of specifying strictly 1157c478bd9Sstevel@tonic-gate * conforming environments using the -ansi or -std=<standard> options. 1167c478bd9Sstevel@tonic-gate * 1177c478bd9Sstevel@tonic-gate * In the absence of any other compiler options, Sun and GNU set the value 1187c478bd9Sstevel@tonic-gate * of __STDC__ as follows when using the following options: 1197c478bd9Sstevel@tonic-gate * 1207c478bd9Sstevel@tonic-gate * Value of __STDC__ __STRICT_ANSI__ 1217c478bd9Sstevel@tonic-gate * 1227c478bd9Sstevel@tonic-gate * cc -Xa (default) 0 undefined 1237c478bd9Sstevel@tonic-gate * cc -Xt (transitional) 0 undefined 1247c478bd9Sstevel@tonic-gate * cc -Xc (strictly conforming) 1 undefined 1257c478bd9Sstevel@tonic-gate * cc -Xs (K&R C) undefined undefined 1267c478bd9Sstevel@tonic-gate * 1277c478bd9Sstevel@tonic-gate * gcc (default) 1 undefined 1287c478bd9Sstevel@tonic-gate * gcc -ansi, -std={c89, c99,...) 1 defined 1297c478bd9Sstevel@tonic-gate * gcc -traditional (K&R) undefined undefined 1307c478bd9Sstevel@tonic-gate * 1317c478bd9Sstevel@tonic-gate * The default compilation modes for Sun C compilers versus GNU C compilers 1327c478bd9Sstevel@tonic-gate * results in a differing value for __STDC__ which results in a more 1337c478bd9Sstevel@tonic-gate * restricted namespace when using Sun compilers. To allow both GNU and Sun 1347c478bd9Sstevel@tonic-gate * interpretations to peacefully co-exist, we use the following Sun 1357c478bd9Sstevel@tonic-gate * implementation _STRICT_STDC_ macro: 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate #if (__STDC__ - 0 == 1 && !defined(__GNUC__)) || \ 1397c478bd9Sstevel@tonic-gate (defined(__GNUC__) && defined(__STRICT_ANSI__)) 1407c478bd9Sstevel@tonic-gate #define _STRICT_STDC 1417c478bd9Sstevel@tonic-gate #else 1427c478bd9Sstevel@tonic-gate #undef _STRICT_STDC 1437c478bd9Sstevel@tonic-gate #endif 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * Compiler complies with ISO/IEC 9899:1999 1477c478bd9Sstevel@tonic-gate */ 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate #if __STDC_VERSION__ - 0 >= 199901L 1507c478bd9Sstevel@tonic-gate #define _STDC_C99 1517c478bd9Sstevel@tonic-gate #endif 1527c478bd9Sstevel@tonic-gate 1532d08521bSGarrett D'Amore /* 1542d08521bSGarrett D'Amore * Use strict symbol visibility. 1552d08521bSGarrett D'Amore */ 1562d08521bSGarrett D'Amore #if (defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX)) && \ 1572d08521bSGarrett D'Amore !defined(__EXTENSIONS__) 1582d08521bSGarrett D'Amore #define _STRICT_SYMBOLS 1592d08521bSGarrett D'Amore #endif 1602d08521bSGarrett D'Amore 1617c478bd9Sstevel@tonic-gate /* 1627c478bd9Sstevel@tonic-gate * Large file interfaces: 1637c478bd9Sstevel@tonic-gate * 1647c478bd9Sstevel@tonic-gate * _LARGEFILE_SOURCE 1657c478bd9Sstevel@tonic-gate * 1 large file-related additions to POSIX 1667c478bd9Sstevel@tonic-gate * interfaces requested (fseeko, etc.) 1677c478bd9Sstevel@tonic-gate * _LARGEFILE64_SOURCE 1687c478bd9Sstevel@tonic-gate * 1 transitional large-file-related interfaces 1697c478bd9Sstevel@tonic-gate * requested (seek64, stat64, etc.) 1707c478bd9Sstevel@tonic-gate * 1717c478bd9Sstevel@tonic-gate * The corresponding announcement macros are respectively: 1727c478bd9Sstevel@tonic-gate * _LFS_LARGEFILE 1737c478bd9Sstevel@tonic-gate * _LFS64_LARGEFILE 1747c478bd9Sstevel@tonic-gate * (These are set in <unistd.h>.) 1757c478bd9Sstevel@tonic-gate * 1767c478bd9Sstevel@tonic-gate * Requesting _LARGEFILE64_SOURCE implies requesting _LARGEFILE_SOURCE as 1777c478bd9Sstevel@tonic-gate * well. 1787c478bd9Sstevel@tonic-gate * 1797c478bd9Sstevel@tonic-gate * The large file interfaces are made visible regardless of the initial values 1807c478bd9Sstevel@tonic-gate * of the feature test macros under certain circumstances: 1817c478bd9Sstevel@tonic-gate * - If no explicit standards-conforming environment is requested (neither 1827c478bd9Sstevel@tonic-gate * of _POSIX_SOURCE nor _XOPEN_SOURCE is defined and the value of 1837c478bd9Sstevel@tonic-gate * __STDC__ does not imply standards conformance). 1847c478bd9Sstevel@tonic-gate * - Extended system interfaces are explicitly requested (__EXTENSIONS__ 1857c478bd9Sstevel@tonic-gate * is defined). 1867c478bd9Sstevel@tonic-gate * - Access to in-kernel interfaces is requested (_KERNEL or _KMEMUSER is 1877c478bd9Sstevel@tonic-gate * defined). (Note that this dependency is an artifact of the current 1887c478bd9Sstevel@tonic-gate * kernel implementation and may change in future releases.) 1897c478bd9Sstevel@tonic-gate */ 1907c478bd9Sstevel@tonic-gate #if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ 1917c478bd9Sstevel@tonic-gate defined(_KERNEL) || defined(_KMEMUSER) || \ 1927c478bd9Sstevel@tonic-gate defined(__EXTENSIONS__) 1937c478bd9Sstevel@tonic-gate #undef _LARGEFILE64_SOURCE 1947c478bd9Sstevel@tonic-gate #define _LARGEFILE64_SOURCE 1 1957c478bd9Sstevel@tonic-gate #endif 1967c478bd9Sstevel@tonic-gate #if _LARGEFILE64_SOURCE - 0 == 1 1977c478bd9Sstevel@tonic-gate #undef _LARGEFILE_SOURCE 1987c478bd9Sstevel@tonic-gate #define _LARGEFILE_SOURCE 1 1997c478bd9Sstevel@tonic-gate #endif 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate /* 2027c478bd9Sstevel@tonic-gate * Large file compilation environment control: 2037c478bd9Sstevel@tonic-gate * 2047c478bd9Sstevel@tonic-gate * The setting of _FILE_OFFSET_BITS controls the size of various file-related 2057c478bd9Sstevel@tonic-gate * types and governs the mapping between file-related source function symbol 2067c478bd9Sstevel@tonic-gate * names and the corresponding binary entry points. 2077c478bd9Sstevel@tonic-gate * 2087c478bd9Sstevel@tonic-gate * In the 32-bit environment, the default value is 32; if not set, set it to 2097c478bd9Sstevel@tonic-gate * the default here, to simplify tests in other headers. 2107c478bd9Sstevel@tonic-gate * 2117c478bd9Sstevel@tonic-gate * In the 64-bit compilation environment, the only value allowed is 64. 2127c478bd9Sstevel@tonic-gate */ 2137c478bd9Sstevel@tonic-gate #if defined(_LP64) 2147c478bd9Sstevel@tonic-gate #ifndef _FILE_OFFSET_BITS 2157c478bd9Sstevel@tonic-gate #define _FILE_OFFSET_BITS 64 2167c478bd9Sstevel@tonic-gate #endif 2177c478bd9Sstevel@tonic-gate #if _FILE_OFFSET_BITS - 0 != 64 2187c478bd9Sstevel@tonic-gate #error "invalid _FILE_OFFSET_BITS value specified" 2197c478bd9Sstevel@tonic-gate #endif 2207c478bd9Sstevel@tonic-gate #else /* _LP64 */ 2217c478bd9Sstevel@tonic-gate #ifndef _FILE_OFFSET_BITS 2227c478bd9Sstevel@tonic-gate #define _FILE_OFFSET_BITS 32 2237c478bd9Sstevel@tonic-gate #endif 2247c478bd9Sstevel@tonic-gate #if _FILE_OFFSET_BITS - 0 != 32 && _FILE_OFFSET_BITS - 0 != 64 2257c478bd9Sstevel@tonic-gate #error "invalid _FILE_OFFSET_BITS value specified" 2267c478bd9Sstevel@tonic-gate #endif 2277c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate /* 2307c478bd9Sstevel@tonic-gate * Use of _XOPEN_SOURCE 2317c478bd9Sstevel@tonic-gate * 2327c478bd9Sstevel@tonic-gate * The following X/Open specifications are supported: 2337c478bd9Sstevel@tonic-gate * 2347c478bd9Sstevel@tonic-gate * X/Open Portability Guide, Issue 3 (XPG3) 2357c478bd9Sstevel@tonic-gate * X/Open CAE Specification, Issue 4 (XPG4) 2367c478bd9Sstevel@tonic-gate * X/Open CAE Specification, Issue 4, Version 2 (XPG4v2) 2377c478bd9Sstevel@tonic-gate * X/Open CAE Specification, Issue 5 (XPG5) 2387c478bd9Sstevel@tonic-gate * Open Group Technical Standard, Issue 6 (XPG6), also referred to as 2397c478bd9Sstevel@tonic-gate * IEEE Std. 1003.1-2001 and ISO/IEC 9945:2002. 2402d08521bSGarrett D'Amore * Open Group Technical Standard, Issue 7 (XPG7), also referred to as 2412d08521bSGarrett D'Amore * IEEE Std. 1003.1-2008 and ISO/IEC 9945:2009. 2427c478bd9Sstevel@tonic-gate * 2437c478bd9Sstevel@tonic-gate * XPG4v2 is also referred to as UNIX 95 (SUS or SUSv1). 2447c478bd9Sstevel@tonic-gate * XPG5 is also referred to as UNIX 98 or the Single Unix Specification, 2457c478bd9Sstevel@tonic-gate * Version 2 (SUSv2) 2467c478bd9Sstevel@tonic-gate * XPG6 is the result of a merge of the X/Open and POSIX specifications 2477c478bd9Sstevel@tonic-gate * and as such is also referred to as IEEE Std. 1003.1-2001 in 2487c478bd9Sstevel@tonic-gate * addition to UNIX 03 and SUSv3. 2492d08521bSGarrett D'Amore * XPG7 is also referred to as UNIX 08 and SUSv4. 2507c478bd9Sstevel@tonic-gate * 2517c478bd9Sstevel@tonic-gate * When writing a conforming X/Open application, as per the specification 2527c478bd9Sstevel@tonic-gate * requirements, the appropriate feature test macros must be defined at 2537c478bd9Sstevel@tonic-gate * compile time. These are as follows. For more info, see standards(5). 2547c478bd9Sstevel@tonic-gate * 2557c478bd9Sstevel@tonic-gate * Feature Test Macro Specification 2567c478bd9Sstevel@tonic-gate * ------------------------------------------------ ------------- 2577c478bd9Sstevel@tonic-gate * _XOPEN_SOURCE XPG3 2587c478bd9Sstevel@tonic-gate * _XOPEN_SOURCE && _XOPEN_VERSION = 4 XPG4 2597c478bd9Sstevel@tonic-gate * _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1 XPG4v2 2607c478bd9Sstevel@tonic-gate * _XOPEN_SOURCE = 500 XPG5 2617c478bd9Sstevel@tonic-gate * _XOPEN_SOURCE = 600 (or POSIX_C_SOURCE=200112L) XPG6 2622d08521bSGarrett D'Amore * _XOPEN_SOURCE = 700 (or POSIX_C_SOURCE=200809L) XPG7 2637c478bd9Sstevel@tonic-gate * 2647c478bd9Sstevel@tonic-gate * In order to simplify the guards within the headers, the following 2657c478bd9Sstevel@tonic-gate * implementation private test macros have been created. Applications 2667c478bd9Sstevel@tonic-gate * must NOT use these private test macros as unexpected results will 2677c478bd9Sstevel@tonic-gate * occur. 2687c478bd9Sstevel@tonic-gate * 2697c478bd9Sstevel@tonic-gate * Note that in general, the use of these private macros is cumulative. 2707c478bd9Sstevel@tonic-gate * For example, the use of _XPG3 with no other restrictions on the X/Open 2717c478bd9Sstevel@tonic-gate * namespace will make the symbols visible for XPG3 through XPG6 2727c478bd9Sstevel@tonic-gate * compilation environments. The use of _XPG4_2 with no other X/Open 2737c478bd9Sstevel@tonic-gate * namespace restrictions indicates that the symbols were introduced in 2747c478bd9Sstevel@tonic-gate * XPG4v2 and are therefore visible for XPG4v2 through XPG6 compilation 2757c478bd9Sstevel@tonic-gate * environments, but not for XPG3 or XPG4 compilation environments. 2767c478bd9Sstevel@tonic-gate * 2777c478bd9Sstevel@tonic-gate * _XPG3 X/Open Portability Guide, Issue 3 (XPG3) 2787c478bd9Sstevel@tonic-gate * _XPG4 X/Open CAE Specification, Issue 4 (XPG4) 2797c478bd9Sstevel@tonic-gate * _XPG4_2 X/Open CAE Specification, Issue 4, Version 2 (XPG4v2/UNIX 95/SUS) 2807c478bd9Sstevel@tonic-gate * _XPG5 X/Open CAE Specification, Issue 5 (XPG5/UNIX 98/SUSv2) 2817c478bd9Sstevel@tonic-gate * _XPG6 Open Group Technical Standard, Issue 6 (XPG6/UNIX 03/SUSv3) 2822d08521bSGarrett D'Amore * _XPG7 Open Group Technical Standard, Issue 7 (XPG7/UNIX 08/SUSv4) 2837c478bd9Sstevel@tonic-gate */ 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate /* X/Open Portability Guide, Issue 3 */ 2867c478bd9Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 < 500) && \ 2877c478bd9Sstevel@tonic-gate (_XOPEN_VERSION - 0 < 4) && !defined(_XOPEN_SOURCE_EXTENDED) 2887c478bd9Sstevel@tonic-gate #define _XPG3 2897c478bd9Sstevel@tonic-gate /* X/Open CAE Specification, Issue 4 */ 2907c478bd9Sstevel@tonic-gate #elif (defined(_XOPEN_SOURCE) && _XOPEN_VERSION - 0 == 4) 2917c478bd9Sstevel@tonic-gate #define _XPG4 2927c478bd9Sstevel@tonic-gate #define _XPG3 2937c478bd9Sstevel@tonic-gate /* X/Open CAE Specification, Issue 4, Version 2 */ 2947c478bd9Sstevel@tonic-gate #elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1) 2957c478bd9Sstevel@tonic-gate #define _XPG4_2 2967c478bd9Sstevel@tonic-gate #define _XPG4 2977c478bd9Sstevel@tonic-gate #define _XPG3 2987c478bd9Sstevel@tonic-gate /* X/Open CAE Specification, Issue 5 */ 2997c478bd9Sstevel@tonic-gate #elif (_XOPEN_SOURCE - 0 == 500) 3007c478bd9Sstevel@tonic-gate #define _XPG5 3017c478bd9Sstevel@tonic-gate #define _XPG4_2 3027c478bd9Sstevel@tonic-gate #define _XPG4 3037c478bd9Sstevel@tonic-gate #define _XPG3 3047c478bd9Sstevel@tonic-gate #undef _POSIX_C_SOURCE 3057c478bd9Sstevel@tonic-gate #define _POSIX_C_SOURCE 199506L 3067c478bd9Sstevel@tonic-gate /* Open Group Technical Standard , Issue 6 */ 3077c478bd9Sstevel@tonic-gate #elif (_XOPEN_SOURCE - 0 == 600) || (_POSIX_C_SOURCE - 0 == 200112L) 3087c478bd9Sstevel@tonic-gate #define _XPG6 3097c478bd9Sstevel@tonic-gate #define _XPG5 3107c478bd9Sstevel@tonic-gate #define _XPG4_2 3117c478bd9Sstevel@tonic-gate #define _XPG4 3127c478bd9Sstevel@tonic-gate #define _XPG3 3137c478bd9Sstevel@tonic-gate #undef _POSIX_C_SOURCE 3147c478bd9Sstevel@tonic-gate #define _POSIX_C_SOURCE 200112L 3157c478bd9Sstevel@tonic-gate #undef _XOPEN_SOURCE 3167c478bd9Sstevel@tonic-gate #define _XOPEN_SOURCE 600 3172d08521bSGarrett D'Amore 3182d08521bSGarrett D'Amore /* Open Group Technical Standard, Issue 7 */ 3192d08521bSGarrett D'Amore #elif (_XOPEN_SOURCE - 0 == 700) || (_POSIX_C_SOURCE - 0 == 200809L) 3202d08521bSGarrett D'Amore #define _XPG7 3212d08521bSGarrett D'Amore #define _XPG6 3222d08521bSGarrett D'Amore #define _XPG5 3232d08521bSGarrett D'Amore #define _XPG4_2 3242d08521bSGarrett D'Amore #define _XPG4 3252d08521bSGarrett D'Amore #define _XPG3 3262d08521bSGarrett D'Amore #undef _POSIX_C_SOURCE 3272d08521bSGarrett D'Amore #define _POSIX_C_SOURCE 200809L 3282d08521bSGarrett D'Amore #undef _XOPEN_SOURCE 3292d08521bSGarrett D'Amore #define _XOPEN_SOURCE 700 3307c478bd9Sstevel@tonic-gate #endif 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate /* 3337c478bd9Sstevel@tonic-gate * _XOPEN_VERSION is defined by the X/Open specifications and is not 3347c478bd9Sstevel@tonic-gate * normally defined by the application, except in the case of an XPG4 3357c478bd9Sstevel@tonic-gate * application. On the implementation side, _XOPEN_VERSION defined with 3367c478bd9Sstevel@tonic-gate * the value of 3 indicates an XPG3 application. _XOPEN_VERSION defined 3377c478bd9Sstevel@tonic-gate * with the value of 4 indicates an XPG4 or XPG4v2 (UNIX 95) application. 3387c478bd9Sstevel@tonic-gate * _XOPEN_VERSION defined with a value of 500 indicates an XPG5 (UNIX 98) 3397c478bd9Sstevel@tonic-gate * application and with a value of 600 indicates an XPG6 (UNIX 03) 3402d08521bSGarrett D'Amore * application and with a value of 700 indicates an XPG7 (UNIX 08). 3412d08521bSGarrett D'Amore * The appropriate version is determined by the use of the 3427c478bd9Sstevel@tonic-gate * feature test macros described earlier. The value of _XOPEN_VERSION 3437c478bd9Sstevel@tonic-gate * defaults to 3 otherwise indicating support for XPG3 applications. 3447c478bd9Sstevel@tonic-gate */ 3457c478bd9Sstevel@tonic-gate #ifndef _XOPEN_VERSION 3462d08521bSGarrett D'Amore #if defined(_XPG7) 3472d08521bSGarrett D'Amore #define _XOPEN_VERSION 700 3482d08521bSGarrett D'Amore #elif defined(_XPG6) 3497c478bd9Sstevel@tonic-gate #define _XOPEN_VERSION 600 3507c478bd9Sstevel@tonic-gate #elif defined(_XPG5) 3517c478bd9Sstevel@tonic-gate #define _XOPEN_VERSION 500 3527c478bd9Sstevel@tonic-gate #elif defined(_XPG4_2) 3537c478bd9Sstevel@tonic-gate #define _XOPEN_VERSION 4 3547c478bd9Sstevel@tonic-gate #else 3557c478bd9Sstevel@tonic-gate #define _XOPEN_VERSION 3 3567c478bd9Sstevel@tonic-gate #endif 3577c478bd9Sstevel@tonic-gate #endif 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate /* 3607c478bd9Sstevel@tonic-gate * ANSI C and ISO 9899:1990 say the type long long doesn't exist in strictly 3617c478bd9Sstevel@tonic-gate * conforming environments. ISO 9899:1999 says it does. 3627c478bd9Sstevel@tonic-gate * 3637c478bd9Sstevel@tonic-gate * The presence of _LONGLONG_TYPE says "long long exists" which is therefore 3647c478bd9Sstevel@tonic-gate * defined in all but strictly conforming environments that disallow it. 3657c478bd9Sstevel@tonic-gate */ 3667c478bd9Sstevel@tonic-gate #if !defined(_STDC_C99) && defined(_STRICT_STDC) && !defined(__GNUC__) 3677c478bd9Sstevel@tonic-gate /* 3687c478bd9Sstevel@tonic-gate * Resist attempts to force the definition of long long in this case. 3697c478bd9Sstevel@tonic-gate */ 3707c478bd9Sstevel@tonic-gate #if defined(_LONGLONG_TYPE) 3717c478bd9Sstevel@tonic-gate #error "No long long in strictly conforming ANSI C & 1990 ISO C environments" 3727c478bd9Sstevel@tonic-gate #endif 3737c478bd9Sstevel@tonic-gate #else 3747c478bd9Sstevel@tonic-gate #if !defined(_LONGLONG_TYPE) 3757c478bd9Sstevel@tonic-gate #define _LONGLONG_TYPE 3767c478bd9Sstevel@tonic-gate #endif 3777c478bd9Sstevel@tonic-gate #endif 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate /* 3807c478bd9Sstevel@tonic-gate * It is invalid to compile an XPG3, XPG4, XPG4v2, or XPG5 application 3817c478bd9Sstevel@tonic-gate * using c99. The same is true for POSIX.1-1990, POSIX.2-1992, POSIX.1b, 3827c478bd9Sstevel@tonic-gate * and POSIX.1c applications. Likewise, it is invalid to compile an XPG6 3837c478bd9Sstevel@tonic-gate * or a POSIX.1-2001 application with anything other than a c99 or later 3847c478bd9Sstevel@tonic-gate * compiler. Therefore, we force an error in both cases. 3857c478bd9Sstevel@tonic-gate */ 3867c478bd9Sstevel@tonic-gate #if defined(_STDC_C99) && (defined(__XOPEN_OR_POSIX) && !defined(_XPG6)) 3877c478bd9Sstevel@tonic-gate #error "Compiler or options invalid for pre-UNIX 03 X/Open applications \ 3887c478bd9Sstevel@tonic-gate and pre-2001 POSIX applications" 3897c478bd9Sstevel@tonic-gate #elif !defined(_STDC_C99) && \ 3907c478bd9Sstevel@tonic-gate (defined(__XOPEN_OR_POSIX) && defined(_XPG6)) 3917c478bd9Sstevel@tonic-gate #error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \ 3927c478bd9Sstevel@tonic-gate require the use of c99" 3937c478bd9Sstevel@tonic-gate #endif 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate /* 3967c478bd9Sstevel@tonic-gate * The following macro defines a value for the ISO C99 restrict 3977c478bd9Sstevel@tonic-gate * keyword so that _RESTRICT_KYWD resolves to "restrict" if 3987c478bd9Sstevel@tonic-gate * an ISO C99 compiler is used and "" (null string) if any other 3997c478bd9Sstevel@tonic-gate * compiler is used. This allows for the use of single prototype 4007c478bd9Sstevel@tonic-gate * declarations regardless of compiler version. 4017c478bd9Sstevel@tonic-gate */ 402dbae7a13SRichard Lowe #if (defined(__STDC__) && defined(_STDC_C99)) && !defined(__cplusplus) 4037c478bd9Sstevel@tonic-gate #define _RESTRICT_KYWD restrict 4047c478bd9Sstevel@tonic-gate #else 4057c478bd9Sstevel@tonic-gate #define _RESTRICT_KYWD 4067c478bd9Sstevel@tonic-gate #endif 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate /* 4097c478bd9Sstevel@tonic-gate * The following macro indicates header support for the ANSI C++ 4107c478bd9Sstevel@tonic-gate * standard. The ISO/IEC designation for this is ISO/IEC FDIS 14882. 4117c478bd9Sstevel@tonic-gate */ 4127c478bd9Sstevel@tonic-gate #define _ISO_CPP_14882_1998 4137c478bd9Sstevel@tonic-gate 4147c478bd9Sstevel@tonic-gate /* 4157c478bd9Sstevel@tonic-gate * The following macro indicates header support for the C99 standard, 4167c478bd9Sstevel@tonic-gate * ISO/IEC 9899:1999, Programming Languages - C. 4177c478bd9Sstevel@tonic-gate */ 4187c478bd9Sstevel@tonic-gate #define _ISO_C_9899_1999 4197c478bd9Sstevel@tonic-gate 4202b6e762cSahl /* 4212b6e762cSahl * The following macro indicates header support for DTrace. The value is an 4222b6e762cSahl * integer that corresponds to the major version number for DTrace. 4232b6e762cSahl */ 4242b6e762cSahl #define _DTRACE_VERSION 1 4252b6e762cSahl 4267c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4277c478bd9Sstevel@tonic-gate } 4287c478bd9Sstevel@tonic-gate #endif 4297c478bd9Sstevel@tonic-gate 4307c478bd9Sstevel@tonic-gate #endif /* _SYS_FEATURE_TESTS_H */ 431