Print this page
9545 Global visibility of C11 functions in C++11 and C++17
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/stdlib.h
+++ new/usr/src/head/stdlib.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 2014 Garrett D'Amore <garrett@damore.org>
24 24 * Copyright (c) 2013 Gary Mills
25 25 *
26 26 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
27 27 */
28 28
29 29 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
30 30
31 31 /* Copyright (c) 1988 AT&T */
32 32 /* All Rights Reserved */
33 33
34 34 #ifndef _STDLIB_H
35 35 #define _STDLIB_H
36 36
37 37 #include <iso/stdlib_iso.h>
38 38 #include <iso/stdlib_c99.h>
39 39 #include <iso/stdlib_c11.h>
40 40
41 41 #if defined(__EXTENSIONS__) || defined(_XPG4)
42 42 #include <sys/wait.h>
43 43 #endif
44 44
45 45 /*
46 46 * Allow global visibility for symbols defined in
47 47 * C++ "std" namespace in <iso/stdlib_iso.h>.
48 48 */
49 49 #if __cplusplus >= 199711L
50 50 using std::div_t;
51 51 using std::ldiv_t;
52 52 using std::size_t;
53 53 using std::abort;
54 54 using std::abs;
55 55 using std::atexit;
56 56 using std::atof;
57 57 using std::atoi;
58 58 using std::atol;
59 59 using std::bsearch;
60 60 using std::calloc;
61 61 using std::div;
62 62 using std::exit;
63 63 using std::free;
64 64 using std::getenv;
65 65 using std::labs;
66 66 using std::ldiv;
67 67 using std::malloc;
68 68 using std::mblen;
69 69 using std::mbstowcs;
70 70 using std::mbtowc;
71 71 using std::qsort;
72 72 using std::rand;
↓ open down ↓ |
72 lines elided |
↑ open up ↑ |
73 73 using std::realloc;
74 74 using std::srand;
75 75 using std::strtod;
76 76 using std::strtol;
77 77 using std::strtoul;
78 78 using std::system;
79 79 using std::wcstombs;
80 80 using std::wctomb;
81 81 #endif
82 82
83 +/*
84 + * Allow global visibility for symbols defined in
85 + * C++ "std" namespace in <iso/stdlib_c11.h>.
86 + */
87 +#if __cplusplus >= 201103L
88 +using std::at_quick_exit;
89 +using std::quick_exit;
90 +#endif
91 +#if __cplusplus >= 201703L
92 +using std::aligned_alloc;
93 +#endif
94 +
83 95 #ifdef __cplusplus
84 96 extern "C" {
85 97 #endif
86 98
87 99 #ifndef _UID_T
88 100 #define _UID_T
89 101 typedef unsigned int uid_t; /* UID type */
90 102 #endif /* !_UID_T */
91 103
92 104 /* large file compilation environment setup */
93 105 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
94 106
95 107 #ifdef __PRAGMA_REDEFINE_EXTNAME
96 108 #pragma redefine_extname mkstemp mkstemp64
97 109 #pragma redefine_extname mkstemps mkstemps64
98 110 #pragma redefine_extname mkostemp mkostemp64
99 111 #pragma redefine_extname mkostemps mkostemps64
100 112 #else /* __PRAGMA_REDEFINE_EXTNAME */
101 113 #define mkstemp mkstemp64
102 114 #define mkstemps mkstemps64
103 115 #define mkostemp mkostemp64
104 116 #define mkostemps mkostemps64
105 117 #endif /* __PRAGMA_REDEFINE_EXTNAME */
106 118
107 119 #endif /* _FILE_OFFSET_BITS == 64 */
108 120
109 121 /* In the LP64 compilation environment, all APIs are already large file */
110 122 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
111 123
112 124 #ifdef __PRAGMA_REDEFINE_EXTNAME
113 125 #pragma redefine_extname mkstemp64 mkstemp
114 126 #pragma redefine_extname mkstemps64 mkstemps
115 127 #pragma redefine_extname mkostemp64 mkostemp
116 128 #pragma redefine_extname mkostemps64 mkostemps
117 129 #else /* __PRAGMA_REDEFINE_EXTNAME */
118 130 #define mkstemp64 mkstemp
119 131 #define mkstemps64 mkstemps
120 132 #define mkostemp64 mkostemp
121 133 #define mkostemps64 mkostemps
122 134 #endif /* __PRAGMA_REDEFINE_EXTNAME */
123 135
124 136 #endif /* _LP64 && _LARGEFILE64_SOURCE */
125 137
126 138 #if defined(__EXTENSIONS__) || \
127 139 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
128 140 (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
129 141 extern int rand_r(unsigned int *);
130 142 #endif
131 143
132 144 extern void _exithandle(void);
133 145
134 146 #if defined(__EXTENSIONS__) || \
135 147 (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
136 148 defined(_XPG4)
137 149 extern double drand48(void);
138 150 extern double erand48(unsigned short *);
139 151 extern long jrand48(unsigned short *);
140 152 extern void lcong48(unsigned short *);
141 153 extern long lrand48(void);
142 154 extern long mrand48(void);
143 155 extern long nrand48(unsigned short *);
144 156 extern unsigned short *seed48(unsigned short *);
145 157 extern void srand48(long);
146 158 extern int putenv(char *);
147 159 extern void setkey(const char *);
148 160 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
149 161
150 162 /*
151 163 * swab() has historically been in <stdlib.h> as delivered from AT&T
152 164 * and continues to be visible in the default compilation environment.
153 165 * As of Issue 4 of the X/Open Portability Guides, swab() was declared
154 166 * in <unistd.h>. As a result, with respect to X/Open namespace the
155 167 * swab() declaration in this header is only visible for the XPG3
156 168 * environment.
157 169 */
158 170 #if (defined(__EXTENSIONS__) || \
159 171 (!defined(_STRICT_STDC__) && !defined(_POSIX_C_SOURCE))) && \
160 172 (!defined(_XOPEN_SOURCE) || (defined(_XPG3) && !defined(_XPG4)))
161 173 #ifndef _SSIZE_T
162 174 #define _SSIZE_T
163 175 #if defined(_LP64) || defined(_I32LPx)
164 176 typedef long ssize_t; /* size of something in bytes or -1 */
165 177 #else
166 178 typedef int ssize_t; /* (historical version) */
167 179 #endif
168 180 #endif /* !_SSIZE_T */
169 181
170 182 extern void swab(const char *, char *, ssize_t);
171 183 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
172 184
173 185 #if defined(__EXTENSIONS__) || \
174 186 !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
175 187 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64)
176 188 extern int mkstemp(char *);
177 189 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
178 190 extern int mkstemps(char *, int);
179 191 #endif
180 192 #endif /* defined(__EXTENSIONS__) ... */
181 193
182 194 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
183 195 !defined(__PRAGMA_REDEFINE_EXTNAME))
184 196 extern int mkstemp64(char *);
185 197 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
186 198 extern int mkstemps64(char *, int);
187 199 #endif
188 200 #endif /* _LARGEFILE64_SOURCE... */
189 201
190 202 #if !defined(_STRICT_SYMBOLS) || defined(_XPG7)
191 203 extern char *mkdtemp(char *);
192 204 #endif /* !defined(_STRICT_SYMBOLS) || defined(_XPG7) */
193 205
194 206 #if !defined(_STRICT_SYMBOLS)
195 207 extern int mkostemp(char *, int);
196 208 extern int mkostemps(char *, int, int);
197 209 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
198 210 !defined(__PRAGMA_REDEFINE_EXTNAME))
199 211 extern int mkostemp64(char *, int);
200 212 extern int mkostemps64(char *, int, int);
201 213 #endif /* defined(_LARGEFILE64_SOURCE) || !((_FILE_OFFSET_BITS == 64) ... */
202 214 #endif /* !defined(_STRICT_SYMBOLS) */
203 215
204 216 #if defined(__EXTENSIONS__) || \
205 217 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
206 218 defined(_XPG4_2)
207 219 extern long a64l(const char *);
208 220 extern char *ecvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
209 221 extern char *fcvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
210 222 extern char *gcvt(double, int, char *);
211 223 extern int getsubopt(char **, char *const *, char **);
212 224 extern int grantpt(int);
213 225 extern char *initstate(unsigned, char *, size_t);
214 226 extern char *l64a(long);
215 227 extern char *mktemp(char *);
216 228 extern char *ptsname(int);
217 229 extern long random(void);
218 230 extern char *realpath(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
219 231 extern char *setstate(const char *);
220 232 extern void srandom(unsigned);
221 233 extern int unlockpt(int);
222 234 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
223 235 #if !defined(_XPG6) || defined(__EXTENSIONS__)
224 236 extern int ttyslot(void);
225 237 extern void *valloc(size_t);
226 238 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
227 239 #endif /* defined(__EXTENSIONS__) || ... || defined(_XPG4_2) */
228 240
229 241 #if defined(__EXTENSIONS__) || \
230 242 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
231 243 defined(_XPG6)
232 244 extern int posix_memalign(void **, size_t, size_t);
233 245 extern int posix_openpt(int);
234 246 extern int setenv(const char *, const char *, int);
235 247 extern int unsetenv(const char *);
236 248 #endif
237 249
238 250 #if defined(__EXTENSIONS__) || \
239 251 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
240 252 extern char *canonicalize_file_name(const char *);
241 253 extern int clearenv(void);
242 254 extern void closefrom(int);
243 255 extern int daemon(int, int);
244 256 extern int dup2(int, int);
245 257 extern int dup3(int, int, int);
246 258 extern int fdwalk(int (*)(void *, int), void *);
247 259 extern char *qecvt(long double, int, int *, int *);
248 260 extern char *qfcvt(long double, int, int *, int *);
249 261 extern char *qgcvt(long double, int, char *);
250 262 extern char *getcwd(char *, size_t);
251 263 extern const char *getexecname(void);
252 264
253 265 #ifndef __GETLOGIN_DEFINED /* Avoid duplicate in unistd.h */
254 266 #define __GETLOGIN_DEFINED
255 267 #ifndef __USE_LEGACY_LOGNAME__
256 268 #ifdef __PRAGMA_REDEFINE_EXTNAME
257 269 #pragma redefine_extname getlogin getloginx
258 270 #else /* __PRAGMA_REDEFINE_EXTNAME */
259 271 extern char *getloginx(void);
260 272 #define getlogin getloginx
261 273 #endif /* __PRAGMA_REDEFINE_EXTNAME */
262 274 #endif /* __USE_LEGACY_LOGNAME__ */
263 275 extern char *getlogin(void);
264 276 #endif /* __GETLOGIN_DEFINED */
265 277
266 278 extern int getopt(int, char *const *, const char *);
267 279 extern char *optarg;
268 280 extern int optind, opterr, optopt;
269 281 extern char *getpass(const char *);
270 282 extern char *getpassphrase(const char *);
271 283 extern int getpw(uid_t, char *);
272 284 extern int isatty(int);
273 285 extern void *memalign(size_t, size_t);
274 286 extern char *ttyname(int);
275 287 extern char *mkdtemp(char *);
276 288 extern const char *getprogname(void);
277 289 extern void setprogname(const char *);
278 290
279 291 #if !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE)
280 292 extern char *lltostr(long long, char *);
281 293 extern char *ulltostr(unsigned long long, char *);
282 294 #endif /* !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE) */
283 295
284 296 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
285 297
286 298 /* OpenBSD compatibility functions */
287 299 #if !defined(_STRICT_SYMBOLS)
288 300
289 301 #include <inttypes.h>
290 302 extern uint32_t arc4random(void);
291 303 extern void arc4random_buf(void *, size_t);
292 304 extern uint32_t arc4random_uniform(uint32_t);
293 305 extern void freezero(void *, size_t);
294 306 extern void *reallocarray(void *, size_t, size_t);
295 307 extern void *recallocarray(void *, size_t, size_t, size_t);
296 308 extern long long strtonum(const char *, long long, long long, const char **);
297 309
298 310 #endif /* !_STRICT_SYBMOLS */
299 311
300 312
301 313 #ifdef __cplusplus
302 314 }
303 315 #endif
304 316
305 317 #endif /* _STDLIB_H */
↓ open down ↓ |
213 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX