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