xref: /illumos-gate/usr/src/head/iso/stdlib_c11.h (revision 50971960b7b1866cdd785b20a4df98c90c231638)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2016 Joyent, Inc.
14  */
15 
16 /*
17  * An application should not include this header directly.  Instead it
18  * should be included only through the inclusion of other illumos headers.
19  *
20  * The contents of this header is limited to identifiers specified in
21  * the C11 standard and in conflict with the C++ implementation of the
22  * standard header.  The C++ standard may adopt the C11 standard at
23  * which point it is expected that the symbols included here will
24  * become part of the C++ std namespace.
25  */
26 
27 #ifndef _ISO_STDLIB_C11_H
28 #define	_ISO_STDLIB_C11_H
29 
30 #include <sys/feature_tests.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #if __cplusplus >= 199711L
37 namespace std {
38 #endif
39 
40 /*
41  * The following have been added as a result of the ISO/IEC 9899:2011
42  * standard. For a strictly conforming C application, visibility is
43  * contingent on the value of __STDC_VERSION__ (see sys/feature_tests.h).
44  * For non-strictly conforming C applications, there are no restrictions
45  * on the C namespace.
46  */
47 
48 /*
49  * Work around fix-includes and other bad actors with using multiple headers.
50  */
51 #if !defined(_NORETURN_KYWD)
52 #if __STDC_VERSION__ - 0 >= 201112L
53 #define	_NORETURN_KYWD	_Noreturn
54 #else
55 #define	_NORETURN_KYWD
56 #endif	/* __STDC_VERSION__ - 0 >= 201112L */
57 #endif	/* !defined(_NORETURN_KYWD) */
58 
59 #if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11)
60 extern void *aligned_alloc(size_t, size_t);
61 #endif /* !_STRICT_SYMBOLS || _STDC_C11 */
62 
63 #if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11) || __cplusplus >= 201103L
64 extern int at_quick_exit(void (*)(void));
65 extern _NORETURN_KYWD void quick_exit(int);
66 #endif /* !_STRICT_SYMBOLS || _STDC_C11 || __cplusplus >= 201103L */
67 
68 #if __cplusplus >= 199711L
69 }
70 #endif
71 
72 /*
73  * ISO C11 Annex K functions are not allowed to be in the standard
74  * namespace; however, it is implementation-defined as to whether or
75  * not they are in the global namespace and we opt to make them
76  * available to software.
77  */
78 #if __EXT1_VISIBLE
79 
80 #ifndef	_ERRNO_T_DEFINED
81 #define	_ERRNO_T_DEFINED
82 typedef int errno_t;
83 #endif
84 
85 /* K.3.6 */
86 typedef void (*constraint_handler_t)(const char *_RESTRICT_KYWD,
87     void *_RESTRICT_KYWD, errno_t);
88 /* K.3.6.1.1 */
89 extern constraint_handler_t set_constraint_handler_s(constraint_handler_t);
90 /* K.3.6.1.2 */
91 extern _NORETURN_KYWD void abort_handler_s(const char *_RESTRICT_KYWD,
92     void *_RESTRICT_KYWD, errno_t);
93 /* K3.6.1.3 */
94 extern void ignore_handler_s(const char *_RESTRICT_KYWD, void *_RESTRICT_KYWD,
95     errno_t);
96 #endif	/* __EXT1_VISIBLE */
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif /* _ISO_STDLIB_C11_H */
103