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