Ticket #2318: feature_tests.h

File feature_tests.h, 13.9 KB (added by maeder, 5 years ago)

system header file

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