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