pkg: ship usr/lib/security/amd64/*.so links
[unleashed.git] / include / sys / feature_tests.h
blob1666cddb6a70b1d39ef9de07040d260a7b1dbb7e
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2013, 2014 Garrett D'Amore <garrett@damore.org>
24 * Copyright 2016 Joyent, Inc.
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
30 #ifndef _SYS_FEATURE_TESTS_H
31 #define _SYS_FEATURE_TESTS_H
33 #include <sys/ccompile.h>
34 #include <sys/isa_defs.h>
37 * The feature test macros __XOPEN_OR_POSIX, _STRICT_STDC, _STRICT_SYMBOLS,
38 * and _STDC_C99 are Sun implementation specific macros created in order to
39 * compress common standards specified feature test macros for easier reading.
40 * These macros should not be used by the application developer as
41 * unexpected results may occur. Instead, the user should reference
42 * standards(5) for correct usage of the standards feature test macros.
44 * __XOPEN_OR_POSIX Used in cases where a symbol is defined by both
45 * X/Open or POSIX or in the negative, when neither
46 * X/Open or POSIX defines a symbol.
48 * _STRICT_STDC __STDC__ is specified by the C Standards and defined
49 * by the compiler. For Sun compilers the value of
50 * __STDC__ is either 1, 0, or not defined based on the
51 * compilation mode (see cc(1)). When the value of
52 * __STDC__ is 1 and in the absence of any other feature
53 * test macros, the namespace available to the application
54 * is limited to only those symbols defined by the C
55 * Standard. _STRICT_STDC provides a more readable means
56 * of identifying symbols defined by the standard, or in
57 * the negative, symbols that are extensions to the C
58 * Standard. See additional comments for GNU C differences.
60 * _STDC_C99 __STDC_VERSION__ is specified by the C standards and
61 * defined by the compiler and indicates the version of
62 * the C standard. A value of 199901L indicates a
63 * compiler that complies with ISO/IEC 9899:1999, other-
64 * wise known as the C99 standard.
66 * _STDC_C11 Like _STDC_C99 except that the value of __STDC_VERSION__
67 * is 201112L indicating a compiler that compiles with
68 * ISO/IEC 9899:2011, otherwise known as the C11 standard.
70 * _STRICT_SYMBOLS Used in cases where symbol visibility is restricted
71 * by the standards, and the user has not explicitly
72 * relaxed the strictness via __EXTENSIONS__.
76 * XXX: this should go away, but right now it is required to be undefined for
77 * some code in base
79 #if defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE)
80 #define __XOPEN_OR_POSIX
81 #endif
84 * ISO/IEC 9899:1990 and it's revisions, ISO/IEC 9899:1999 and ISO/IEC
85 * 99899:2011 specify the following predefined macro name:
87 * __STDC__ The integer constant 1, intended to indicate a conforming
88 * implementation.
90 * Furthermore, a strictly conforming program shall use only those features
91 * of the language and library specified in these standards. A conforming
92 * implementation shall accept any strictly conforming program.
94 * The GCC project interpretation is that __STDC__ should always be defined
95 * to 1 for compilation modes that accept ANSI C syntax regardless of whether
96 * or not extensions to the C standard are used. Violations of conforming
97 * behavior are conditionally flagged as warnings via the use of the
98 * -pedantic option. In addition to defining __STDC__ to 1, the GNU C
99 * compiler also defines __STRICT_ANSI__ as a means of specifying strictly
100 * conforming environments using the -ansi or -std=<standard> options.
101 * Clang (LLVM) works similarly.
103 * In the absence of any other compiler options, GCC and Clang set the value of
104 * __STDC__ as follows when using the following options:
106 * __STDC__ __STRICT_ANSI__
107 * cc (default) 1 undefined
108 * cc -ansi, -std={c89, c99,...) 1 1
109 * cc -traditional (K&R) undefined undefined
112 #if (__STDC__ - 0 == 1 && defined(__STRICT_ANSI__)) || \
113 defined(_ASM)
114 #define _STRICT_STDC
115 #else
116 #undef _STRICT_STDC
117 #endif
120 * Use of _XOPEN_SOURCE
122 * The following X/Open specifications are supported:
124 * X/Open Portability Guide, Issue 3 (XPG3)
125 * X/Open CAE Specification, Issue 4 (XPG4)
126 * X/Open CAE Specification, Issue 4, Version 2 (XPG4v2)
127 * X/Open CAE Specification, Issue 5 (XPG5)
128 * Open Group Technical Standard, Issue 6 (XPG6), also referred to as
129 * IEEE Std. 1003.1-2001 and ISO/IEC 9945:2002.
130 * Open Group Technical Standard, Issue 7 (XPG7), also referred to as
131 * IEEE Std. 1003.1-2008 and ISO/IEC 9945:2009.
133 * XPG4v2 is also referred to as UNIX 95 (SUS or SUSv1).
134 * XPG5 is also referred to as UNIX 98 or the Single Unix Specification,
135 * Version 2 (SUSv2)
136 * XPG6 is the result of a merge of the X/Open and POSIX specifications
137 * and as such is also referred to as IEEE Std. 1003.1-2001 in
138 * addition to UNIX 03 and SUSv3.
139 * XPG7 is also referred to as UNIX 08 and SUSv4.
141 * When writing a conforming X/Open application, as per the specification
142 * requirements, the appropriate feature test macros must be defined at
143 * compile time. These are as follows. For more info, see standards(5).
145 * Feature Test Macro Specification
146 * ------------------------------------------------ -------------
147 * _XOPEN_SOURCE XPG3
148 * _XOPEN_SOURCE && _XOPEN_VERSION = 4 XPG4
149 * _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1 XPG4v2
150 * _XOPEN_SOURCE = 500 XPG5
151 * _XOPEN_SOURCE = 600 (or POSIX_C_SOURCE=200112L) XPG6
152 * _XOPEN_SOURCE = 700 (or POSIX_C_SOURCE=200809L) XPG7
155 #ifdef _XOPEN_SOURCE
156 # if (_XOPEN_SOURCE - 0 >= 700)
157 # define __XPG_VISIBLE 700
158 # undef _POSIX_C_SOURCE
159 # define _POSIX_C_SOURCE 200809L
160 # elif (_XOPEN_SOURCE - 0 >= 600)
161 # define __XPG_VISIBLE 600
162 # undef _POSIX_C_SOURCE
163 # define _POSIX_C_SOURCE 200112L
164 # elif (_XOPEN_SOURCE - 0 >= 500)
165 # define __XPG_VISIBLE 500
166 # undef _POSIX_C_SOURCE
167 # define _POSIX_C_SOURCE 199506L
168 # elif (_XOPEN_SOURCE_EXTENDED - 0 == 1)
169 # define __XPG_VISIBLE 420
170 # elif (_XOPEN_VERSION - 0 >= 4)
171 # define __XPG_VISIBLE 400
172 # else
173 # define __XPG_VISIBLE 300
174 # endif
175 #endif
178 * _POSIX_SOURCE==1 means POSIX.1-1988. Later standards use
179 * _POSIX_C_SOURCE:
181 * undef not POSIX
182 * 1 POSIX.1-1990
183 * 2 POSIX.2-1992
184 * 199309L POSIX.1b-1993 (Real Time)
185 * 199506L POSIX.1c-1995 (POSIX Threads)
186 * 200112L POSIX.1-2001 (Austin Group Revision)
187 * 200809L POSIX.1-2008
189 #ifdef _POSIX_C_SOURCE
190 # if (_POSIX_C_SOURCE - 0 >= 200809)
191 # define __POSIX_VISIBLE 200809
192 # elif (_POSIX_C_SOURCE - 0 >= 200112)
193 # define __POSIX_VISIBLE 200112
194 # elif (_POSIX_C_SOURCE - 0 >= 199506)
195 # define __POSIX_VISIBLE 199506
196 # elif (_POSIX_C_SOURCE - 0 >= 199309)
197 # define __POSIX_VISIBLE 199309
198 # elif (_POSIX_C_SOURCE - 0 >= 2)
199 # define __POSIX_VISIBLE 199209
200 # else
201 # define _POSIX_VISIBLE 199009
202 # endif
203 #elif defined(_POSIX_SOURCE)
204 # define __POSIX_VISIBLE 199808
205 # define __ISO_C_VISIBLE 0
206 #endif
208 #if (__POSIX_VISIBLE - 0 >= 200112)
209 # define __ISO_C_VISIBLE 1999
210 #elif (__POSIX_VISIBLE - 0 >= 199009)
211 # define __ISO_C_VISIBLE 1990
212 #endif
215 * __STDC_VERSION__ and __cplusplus are set by the compiler. They override any
216 * __ISO_C_VISIBLE implied by XPG or POSIX above.
218 #if __STDC_VERSION__ - 0 >= 201112L || __cplusplus - 0 >= 201703
219 #undef __ISO_C_VISIBLE
220 #define __ISO_C_VISIBLE 2011
221 #elif __STDC_VERSION__ - 0 >= 199901L || __cplusplus - 0 >= 201103
222 #undef __ISO_C_VISIBLE
223 #define __ISO_C_VISIBLE 1999
224 #endif
226 /* XXX illumos compat */
227 #if __ISO_C_VISIBLE >= 2011
228 # define _STDC_C11
229 #endif
230 #if __ISO_C_VISIBLE >= 1999
231 # define _STDC_C99
232 #endif
235 * The following macro defines a value for the ISO C99 restrict
236 * keyword so that _RESTRICT_KYWD resolves to "restrict" if
237 * an ISO C99 compiler is used, "__restrict" for c++ and "" (null string)
238 * if any other compiler is used. This allows for the use of single
239 * prototype declarations regardless of compiler version.
241 #if (defined(__STDC__) && defined(_STDC_C99))
242 #ifdef __cplusplus
243 #define _RESTRICT_KYWD __restrict
244 #else
246 * NOTE: The whitespace between the '#' and 'define' is significant.
247 * It foils gcc's fixincludes from defining a redundant 'restrict'.
249 /* CSTYLED */
250 # define _RESTRICT_KYWD restrict
251 #endif
252 #else
253 #define _RESTRICT_KYWD
254 #endif
257 * The following macro defines a value for the ISO C11 _Noreturn
258 * keyword so that _NORETURN_KYWD resolves to "_Noreturn" if
259 * an ISO C11 compiler is used and "" (null string) if any other
260 * compiler is used. This allows for the use of single prototype
261 * declarations regardless of compiler version.
263 #if (defined(__STDC__) && defined(_STDC_C11)) && !defined(__cplusplus)
264 #define _NORETURN_KYWD _Noreturn
265 #else
266 #define _NORETURN_KYWD
267 #endif
269 /* ISO/IEC 9899:2011 Annex K */
270 #if defined(__STDC_WANT_LIB_EXT1__)
271 #if __STDC_WANT_LIB_EXT1__
272 #define __EXT1_VISIBLE 1
273 #else
274 #define __EXT1_VISIBLE 0
275 #endif
276 #else
277 #define __EXT1_VISIBLE 0
278 #endif /* __STDC_WANT_LIB_EXT1__ */
281 * The following macro indicates header support for the ANSI C++
282 * standard. The ISO/IEC designation for this is ISO/IEC FDIS 14882.
284 #define _ISO_CPP_14882_1998
287 * The following macro indicates header support for the C99 standard,
288 * ISO/IEC 9899:1999, Programming Languages - C.
290 #define _ISO_C_9899_1999
293 * The following macro indicates header support for the C11 standard,
294 * ISO/IEC 9899:2011, Programming Languages - C.
296 #define _ISO_C_9899_2011
299 * The following macro indicates header support for the C11 standard,
300 * ISO/IEC 9899:2011 Annex K, Programming Languages - C.
302 #undef __STDC_LIB_EXT1__
305 * The following macro indicates header support for DTrace. The value is an
306 * integer that corresponds to the major version number for DTrace.
308 #define _DTRACE_VERSION 1
311 * The following macro indicates that we are on illumos, and serves to
312 * distinguish us from other SunOS derived systems.
314 #define _ILLUMOS 1
317 * __UNLEASHED_VISIBLE: interfaces that are not part of any standard. Visible
318 * by default, hidden if POSIX or XPG is requested by user.
320 #if !defined(_UNLEASHED_SOURCE) && \
321 (defined(__XPG_VISIBLE) || defined(__POSIX_VISIBLE))
322 # define __UNLEASHED_VISIBLE 0
323 #endif
326 * Default values.
328 * XXX illumos compat: if we choose the default value here, also define
329 * _XOPEN_SOURCE/_POSIX_C_SOURCE since many headers check for them. also define
330 * __EXTENSIONS__ if XPG was not specified by user.
332 #ifndef _KERNEL
333 #ifndef __XPG_VISIBLE
334 # define __XPG_VISIBLE 700
335 # define _XOPEN_SOURCE 700
336 # ifndef __EXTENSIONS__
337 # define __EXTENSIONS__
338 # endif
339 #endif
340 #ifndef __POSIX_VISIBLE
341 # define __POSIX_VISIBLE 200809
342 # define _POSIX_C_SOURCE 200809L
343 #endif
344 #ifndef __ISO_C_VISIBLE
345 # define __ISO_C_VISIBLE 2011
346 #endif
347 #endif /* _KERNEL */
348 #ifndef __UNLEASHED_VISIBLE
349 # define __UNLEASHED_VISIBLE 1
350 #endif
352 #if (defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX)) && \
353 !defined(__EXTENSIONS__)
354 #define _STRICT_SYMBOLS
355 #endif
358 * XXX for compatibility with headers inherited from illumos.
359 * the _KERNEL check is a bit of a hack; a lot of headers check "#if !_XPG4_2"
360 * when exposing things needed in-tree, so we work around by not setting these
361 * for the kernel, for now.
363 #ifndef _KERNEL
364 #if (__XPG_VISIBLE >= 700)
365 # define _XPG7
366 #endif
367 #if (__XPG_VISIBLE >= 600)
368 # define _XPG6
369 #endif
370 #if (__XPG_VISIBLE >= 500)
371 # define _XPG5
372 #endif
373 #if (__XPG_VISIBLE >= 420)
374 # define _XPG4_2
375 #endif
376 #if (__XPG_VISIBLE >= 400)
377 # define _XPG4
378 #endif
379 #if (__XPG_VISIBLE >= 300)
380 # define _XPG3
381 #endif
382 #endif
386 * XXX illumos compat. _XOPEN_VERSION is actually defined by POSIX, but it is
387 * not really useful for anything.
389 #ifndef _XOPEN_VERSION
390 #if defined(_XPG7)
391 #define _XOPEN_VERSION 700
392 #elif defined(_XPG6)
393 #define _XOPEN_VERSION 600
394 #elif defined(_XPG5)
395 #define _XOPEN_VERSION 500
396 #elif defined(_XPG4_2)
397 #define _XOPEN_VERSION 4
398 #else
399 #define _XOPEN_VERSION 3
400 #endif
401 #endif
403 #endif /* _SYS_FEATURE_TESTS_H */