]>
Commit | Line | Data |
---|---|---|
5b2abdfb | 1 | /* |
b5d655f7 | 2 | * Copyright (c) 2000, 2002 - 2008 Apple Inc. All rights reserved. |
5b2abdfb A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
734aad71 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
5b2abdfb A |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
734aad71 A |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
5b2abdfb A |
20 | * |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | /*- | |
24 | * Copyright (c) 1990, 1993 | |
25 | * The Regents of the University of California. All rights reserved. | |
26 | * | |
27 | * Redistribution and use in source and binary forms, with or without | |
28 | * modification, are permitted provided that the following conditions | |
29 | * are met: | |
30 | * 1. Redistributions of source code must retain the above copyright | |
31 | * notice, this list of conditions and the following disclaimer. | |
32 | * 2. Redistributions in binary form must reproduce the above copyright | |
33 | * notice, this list of conditions and the following disclaimer in the | |
34 | * documentation and/or other materials provided with the distribution. | |
35 | * 3. All advertising materials mentioning features or use of this software | |
36 | * must display the following acknowledgement: | |
37 | * This product includes software developed by the University of | |
38 | * California, Berkeley and its contributors. | |
39 | * 4. Neither the name of the University nor the names of its contributors | |
40 | * may be used to endorse or promote products derived from this software | |
41 | * without specific prior written permission. | |
42 | * | |
43 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
44 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
45 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
46 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
47 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
48 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
49 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
50 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
51 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
52 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
53 | * SUCH DAMAGE. | |
54 | * | |
55 | * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 | |
56 | */ | |
57 | ||
58 | #ifndef _STDLIB_H_ | |
59 | #define _STDLIB_H_ | |
60 | ||
b5d655f7 | 61 | #include <Availability.h> |
224c7076 | 62 | |
3d9156a7 A |
63 | #include <_types.h> |
64 | #if !defined(_ANSI_SOURCE) | |
65 | #include <sys/wait.h> | |
224c7076 | 66 | #if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) |
9385eb3d | 67 | #include <alloca.h> |
224c7076 | 68 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
3d9156a7 | 69 | #endif /* !_ANSI_SOURCE */ |
5b2abdfb | 70 | |
3d9156a7 A |
71 | #ifndef _SIZE_T |
72 | #define _SIZE_T | |
73 | /* DO NOT REMOVE THIS COMMENT: fixincludes needs to see: | |
74 | * _GCC_SIZE_T */ | |
75 | typedef __darwin_size_t size_t; | |
5b2abdfb A |
76 | #endif |
77 | ||
224c7076 | 78 | #if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) |
3d9156a7 A |
79 | #ifndef _CT_RUNE_T |
80 | #define _CT_RUNE_T | |
81 | typedef __darwin_ct_rune_t ct_rune_t; | |
9385eb3d A |
82 | #endif |
83 | ||
3d9156a7 A |
84 | #ifndef _RUNE_T |
85 | #define _RUNE_T | |
86 | typedef __darwin_rune_t rune_t; | |
5b2abdfb | 87 | #endif |
224c7076 | 88 | #endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
5b2abdfb | 89 | |
9385eb3d | 90 | #ifndef __cplusplus |
3d9156a7 A |
91 | #ifndef _WCHAR_T |
92 | #define _WCHAR_T | |
93 | typedef __darwin_wchar_t wchar_t; | |
94 | #endif /* _WCHAR_T */ | |
9385eb3d A |
95 | #endif /* __cplusplus */ |
96 | ||
5b2abdfb A |
97 | typedef struct { |
98 | int quot; /* quotient */ | |
99 | int rem; /* remainder */ | |
100 | } div_t; | |
101 | ||
102 | typedef struct { | |
103 | long quot; /* quotient */ | |
104 | long rem; /* remainder */ | |
105 | } ldiv_t; | |
106 | ||
3d9156a7 A |
107 | #if !__DARWIN_NO_LONG_LONG |
108 | typedef struct { | |
109 | long long quot; | |
110 | long long rem; | |
111 | } lldiv_t; | |
112 | #endif /* !__DARWIN_NO_LONG_LONG */ | |
113 | ||
5b2abdfb | 114 | #ifndef NULL |
3d9156a7 | 115 | #define NULL __DARWIN_NULL |
59e0d9fe | 116 | #endif /* ! NULL */ |
5b2abdfb A |
117 | |
118 | #define EXIT_FAILURE 1 | |
119 | #define EXIT_SUCCESS 0 | |
120 | ||
121 | #define RAND_MAX 0x7fffffff | |
122 | ||
3d9156a7 A |
123 | #ifdef _USE_EXTENDED_LOCALES_ |
124 | #include <_xlocale.h> | |
125 | #endif /* _USE_EXTENDED_LOCALES_ */ | |
126 | ||
127 | #ifndef MB_CUR_MAX | |
128 | #ifdef _USE_EXTENDED_LOCALES_ | |
129 | #define MB_CUR_MAX (___mb_cur_max()) | |
130 | #ifndef MB_CUR_MAX_L | |
131 | #define MB_CUR_MAX_L(x) (___mb_cur_max_l(x)) | |
132 | #endif /* !MB_CUR_MAX_L */ | |
133 | #else /* !_USE_EXTENDED_LOCALES_ */ | |
5b2abdfb A |
134 | extern int __mb_cur_max; |
135 | #define MB_CUR_MAX __mb_cur_max | |
3d9156a7 A |
136 | #endif /* _USE_EXTENDED_LOCALES_ */ |
137 | #endif /* MB_CUR_MAX */ | |
5b2abdfb | 138 | |
224c7076 | 139 | #if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) \ |
3d9156a7 A |
140 | && defined(_USE_EXTENDED_LOCALES_) && !defined(MB_CUR_MAX_L) |
141 | #define MB_CUR_MAX_L(x) (___mb_cur_max_l(x)) | |
142 | #endif | |
5b2abdfb A |
143 | |
144 | __BEGIN_DECLS | |
9385eb3d A |
145 | void abort(void) __dead2; |
146 | int abs(int) __pure2; | |
147 | int atexit(void (*)(void)); | |
148 | double atof(const char *); | |
149 | int atoi(const char *); | |
150 | long atol(const char *); | |
3d9156a7 A |
151 | #if !__DARWIN_NO_LONG_LONG |
152 | long long | |
153 | atoll(const char *); | |
154 | #endif /* !__DARWIN_NO_LONG_LONG */ | |
9385eb3d A |
155 | void *bsearch(const void *, const void *, size_t, |
156 | size_t, int (*)(const void *, const void *)); | |
157 | void *calloc(size_t, size_t); | |
158 | div_t div(int, int) __pure2; | |
159 | void exit(int) __dead2; | |
160 | void free(void *); | |
161 | char *getenv(const char *); | |
162 | long labs(long) __pure2; | |
163 | ldiv_t ldiv(long, long) __pure2; | |
3d9156a7 A |
164 | #if !__DARWIN_NO_LONG_LONG |
165 | long long | |
166 | llabs(long long); | |
167 | lldiv_t lldiv(long long, long long); | |
168 | #endif /* !__DARWIN_NO_LONG_LONG */ | |
9385eb3d A |
169 | void *malloc(size_t); |
170 | int mblen(const char *, size_t); | |
171 | size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t); | |
172 | int mbtowc(wchar_t * __restrict, const char * __restrict, size_t); | |
173 | void qsort(void *, size_t, size_t, | |
174 | int (*)(const void *, const void *)); | |
175 | int rand(void); | |
176 | void *realloc(void *, size_t); | |
177 | void srand(unsigned); | |
224c7076 A |
178 | double strtod(const char *, char **) __DARWIN_ALIAS(strtod); |
179 | float strtof(const char *, char **) __DARWIN_ALIAS(strtof); | |
9385eb3d A |
180 | long strtol(const char *, char **, int); |
181 | long double | |
3d9156a7 A |
182 | strtold(const char *, char **) __DARWIN_LDBL_COMPAT(strtold); |
183 | #if !__DARWIN_NO_LONG_LONG | |
184 | long long | |
185 | strtoll(const char *, char **, int); | |
186 | #endif /* !__DARWIN_NO_LONG_LONG */ | |
5b2abdfb | 187 | unsigned long |
9385eb3d | 188 | strtoul(const char *, char **, int); |
3d9156a7 A |
189 | #if !__DARWIN_NO_LONG_LONG |
190 | unsigned long long | |
191 | strtoull(const char *, char **, int); | |
192 | #endif /* !__DARWIN_NO_LONG_LONG */ | |
224c7076 A |
193 | //Begin-Libc |
194 | #ifndef LIBC_ALIAS_SYSTEM | |
195 | //End-Libc | |
196 | int system(const char *) __DARWIN_ALIAS_C(system); | |
197 | //Begin-Libc | |
198 | #else /* LIBC_ALIAS_SYSTEM */ | |
199 | int system(const char *) LIBC_ALIAS_C(system); | |
200 | #endif /* !LIBC_ALIAS_SYSTEM */ | |
201 | //End-Libc | |
9385eb3d | 202 | size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t); |
3d9156a7 | 203 | int wctomb(char *, wchar_t); |
5b2abdfb A |
204 | |
205 | #ifndef _ANSI_SOURCE | |
3d9156a7 A |
206 | void _Exit(int) __dead2; |
207 | long a64l(const char *); | |
9385eb3d | 208 | double drand48(void); |
3d9156a7 | 209 | char *ecvt(double, int, int *__restrict, int *__restrict); /* LEGACY */ |
9385eb3d | 210 | double erand48(unsigned short[3]); |
3d9156a7 A |
211 | char *fcvt(double, int, int *__restrict, int *__restrict); /* LEGACY */ |
212 | char *gcvt(double, int, char *); /* LEGACY */ | |
213 | int getsubopt(char **, char * const *, char **); | |
214 | int grantpt(int); | |
215 | #if __DARWIN_UNIX03 | |
216 | char *initstate(unsigned, char *, size_t); /* no __DARWIN_ALIAS needed */ | |
217 | #else /* !__DARWIN_UNIX03 */ | |
218 | char *initstate(unsigned long, char *, long); | |
219 | #endif /* __DARWIN_UNIX03 */ | |
9385eb3d | 220 | long jrand48(unsigned short[3]); |
3d9156a7 | 221 | char *l64a(long); |
9385eb3d A |
222 | void lcong48(unsigned short[7]); |
223 | long lrand48(void); | |
3d9156a7 A |
224 | char *mktemp(char *); |
225 | int mkstemp(char *); | |
9385eb3d A |
226 | long mrand48(void); |
227 | long nrand48(unsigned short[3]); | |
3d9156a7 A |
228 | int posix_openpt(int); |
229 | char *ptsname(int); | |
224c7076 A |
230 | //Begin-Libc |
231 | #ifndef LIBC_ALIAS_PUTENV | |
232 | //End-Libc | |
3d9156a7 | 233 | int putenv(char *) __DARWIN_ALIAS(putenv); |
224c7076 A |
234 | //Begin-Libc |
235 | #else /* LIBC_ALIAS_PUTENV */ | |
236 | int putenv(char *) LIBC_ALIAS(putenv); | |
237 | #endif /* !LIBC_ALIAS_PUTENV */ | |
238 | //End-Libc | |
3d9156a7 | 239 | long random(void); |
224c7076 A |
240 | int rand_r(unsigned *); |
241 | //Begin-Libc | |
242 | #ifdef __LIBC__ | |
243 | #ifndef LIBC_ALIAS_REALPATH | |
244 | char *realpath(const char * __restrict, char * __restrict) __DARWIN_EXTSN(realpath); | |
245 | #else /* LIBC_ALIAS_REALPATH */ | |
246 | #ifdef VARIANT_DARWINEXTSN | |
247 | char *realpath(const char * __restrict, char * __restrict) LIBC_EXTSN(realpath); | |
248 | #else /* !VARIANT_DARWINEXTSN */ | |
249 | char *realpath(const char * __restrict, char * __restrict) LIBC_ALIAS(realpath); | |
250 | #endif /* VARIANT_DARWINEXTSN */ | |
251 | #endif /* !LIBC_ALIAS_REALPATH */ | |
252 | #else /* !__LIBC__ */ | |
253 | //End-Libc | |
254 | #if (__DARWIN_UNIX03 && !defined(_POSIX_C_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(_DARWIN_BETTER_REALPATH) | |
255 | char *realpath(const char * __restrict, char * __restrict) __DARWIN_EXTSN(realpath); | |
256 | #else /* (!__DARWIN_UNIX03 || _POSIX_C_SOURCE) && !_DARWIN_C_SOURCE && !_DARWIN_BETTER_REALPATH */ | |
257 | char *realpath(const char * __restrict, char * __restrict) __DARWIN_ALIAS(realpath); | |
258 | #endif /* (__DARWIN_UNIX03 && _POSIX_C_SOURCE) || _DARWIN_C_SOURCE || _DARWIN_BETTER_REALPATH */ | |
259 | //Begin-Libc | |
260 | #endif /* __LIBC__ */ | |
261 | //End-Libc | |
9385eb3d A |
262 | unsigned short |
263 | *seed48(unsigned short[3]); | |
224c7076 A |
264 | //Begin-Libc |
265 | #ifndef LIBC_ALIAS_SETENV | |
266 | //End-Libc | |
3d9156a7 | 267 | int setenv(const char *, const char *, int) __DARWIN_ALIAS(setenv); |
224c7076 A |
268 | //Begin-Libc |
269 | #else /* LIBC_ALIAS_SETENV */ | |
270 | int setenv(const char *, const char *, int) LIBC_ALIAS(setenv); | |
271 | #endif /* !LIBC_ALIAS_SETENV */ | |
272 | //End-Libc | |
3d9156a7 | 273 | #if __DARWIN_UNIX03 |
224c7076 A |
274 | //Begin-Libc |
275 | #ifndef LIBC_ALIAS_SETKEY | |
276 | //End-Libc | |
3d9156a7 | 277 | void setkey(const char *) __DARWIN_ALIAS(setkey); |
224c7076 A |
278 | //Begin-Libc |
279 | #else /* LIBC_ALIAS_SETKEY */ | |
280 | void setkey(const char *) LIBC_ALIAS(setkey); | |
281 | #endif /* !LIBC_ALIAS_SETKEY */ | |
282 | //End-Libc | |
3d9156a7 A |
283 | #else /* !__DARWIN_UNIX03 */ |
284 | int setkey(const char *); | |
285 | #endif /* __DARWIN_UNIX03 */ | |
286 | char *setstate(const char *); | |
9385eb3d | 287 | void srand48(long); |
3d9156a7 A |
288 | #if __DARWIN_UNIX03 |
289 | void srandom(unsigned); | |
290 | #else /* !__DARWIN_UNIX03 */ | |
291 | void srandom(unsigned long); | |
292 | #endif /* __DARWIN_UNIX03 */ | |
293 | int unlockpt(int); | |
294 | #if __DARWIN_UNIX03 | |
224c7076 A |
295 | //Begin-Libc |
296 | #ifndef LIBC_ALIAS_UNSETENV | |
297 | //End-Libc | |
3d9156a7 | 298 | int unsetenv(const char *) __DARWIN_ALIAS(unsetenv); |
224c7076 A |
299 | //Begin-Libc |
300 | #else /* LIBC_ALIAS_UNSETENV */ | |
301 | int unsetenv(const char *) LIBC_ALIAS(unsetenv); | |
302 | #endif /* !LIBC_ALIAS_UNSETENV */ | |
303 | //End-Libc | |
3d9156a7 A |
304 | #else /* !__DARWIN_UNIX03 */ |
305 | void unsetenv(const char *); | |
306 | #endif /* __DARWIN_UNIX03 */ | |
224c7076 | 307 | #endif /* !_ANSI_SOURCE */ |
3d9156a7 | 308 | |
224c7076 | 309 | #if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) |
3d9156a7 A |
310 | #include <machine/types.h> |
311 | ||
312 | #ifndef _DEV_T | |
313 | typedef __darwin_dev_t dev_t; | |
314 | #define _DEV_T | |
315 | #endif | |
316 | ||
317 | #ifndef _MODE_T | |
318 | typedef __darwin_mode_t mode_t; | |
319 | #define _MODE_T | |
320 | #endif | |
321 | ||
322 | u_int32_t | |
323 | arc4random(void); | |
324 | void arc4random_addrandom(unsigned char *dat, int datlen); | |
325 | void arc4random_stir(void); | |
9385eb3d A |
326 | |
327 | /* getcap(3) functions */ | |
328 | char *cgetcap(char *, const char *, int); | |
329 | int cgetclose(void); | |
330 | int cgetent(char **, char **, const char *); | |
331 | int cgetfirst(char **, char **); | |
332 | int cgetmatch(const char *, const char *); | |
333 | int cgetnext(char **, char **); | |
334 | int cgetnum(char *, const char *, long *); | |
335 | int cgetset(const char *); | |
336 | int cgetstr(char *, const char *, char **); | |
337 | int cgetustr(char *, const char *, char **); | |
338 | ||
b5d655f7 | 339 | int daemon(int, int) __DARWIN_1050(daemon) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_2_0,__IPHONE_2_0); |
3d9156a7 A |
340 | char *devname(dev_t, mode_t); |
341 | char *devname_r(dev_t, mode_t, char *buf, int len); | |
9385eb3d A |
342 | char *getbsize(int *, long *); |
343 | int getloadavg(double [], int); | |
344 | const char | |
345 | *getprogname(void); | |
346 | ||
9385eb3d A |
347 | int heapsort(void *, size_t, size_t, |
348 | int (*)(const void *, const void *)); | |
9385eb3d A |
349 | int mergesort(void *, size_t, size_t, |
350 | int (*)(const void *, const void *)); | |
9385eb3d A |
351 | void qsort_r(void *, size_t, size_t, void *, |
352 | int (*)(void *, const void *, const void *)); | |
353 | int radixsort(const unsigned char **, int, const unsigned char *, | |
354 | unsigned); | |
355 | void setprogname(const char *); | |
356 | int sradixsort(const unsigned char **, int, const unsigned char *, | |
357 | unsigned); | |
358 | void sranddev(void); | |
359 | void srandomdev(void); | |
9385eb3d | 360 | void *reallocf(void *, size_t); |
3d9156a7 | 361 | #if !__DARWIN_NO_LONG_LONG |
5b2abdfb | 362 | long long |
9385eb3d | 363 | strtoq(const char *, char **, int); |
5b2abdfb | 364 | unsigned long long |
9385eb3d | 365 | strtouq(const char *, char **, int); |
3d9156a7 A |
366 | #endif /* !__DARWIN_NO_LONG_LONG */ |
367 | extern char *suboptarg; /* getsubopt(3) external variable */ | |
368 | void *valloc(size_t); | |
224c7076 A |
369 | #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ |
370 | ||
371 | /* Poison the following routines if -fshort-wchar is set */ | |
372 | #if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU | |
373 | #pragma GCC poison mbstowcs mbtowc wcstombs wctomb | |
5b2abdfb A |
374 | #endif |
375 | __END_DECLS | |
376 | ||
3d9156a7 A |
377 | #ifdef _USE_EXTENDED_LOCALES_ |
378 | #include <xlocale/_stdlib.h> | |
379 | #endif /* _USE_EXTENDED_LOCALES_ */ | |
380 | ||
5b2abdfb | 381 | #endif /* _STDLIB_H_ */ |