]> git.saurik.com Git - apple/libc.git/blame - include/stdlib.h
Libc-391.2.9.tar.gz
[apple/libc.git] / include / stdlib.h
CommitLineData
5b2abdfb 1/*
3d9156a7 2 * Copyright (c) 2000, 2005 Apple Computer, 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
3d9156a7
A
61#include <sys/cdefs.h>
62#include <_types.h>
63#if !defined(_ANSI_SOURCE)
64#include <sys/wait.h>
65#if !defined(_POSIX_C_SOURCE)
9385eb3d 66#include <alloca.h>
3d9156a7
A
67#endif /* !_POSIX_C_SOURCE */
68#endif /* !_ANSI_SOURCE */
5b2abdfb 69
3d9156a7
A
70#ifndef _SIZE_T
71#define _SIZE_T
72/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see:
73 * _GCC_SIZE_T */
74typedef __darwin_size_t size_t;
5b2abdfb
A
75#endif
76
3d9156a7
A
77#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE)
78#ifndef _CT_RUNE_T
79#define _CT_RUNE_T
80typedef __darwin_ct_rune_t ct_rune_t;
9385eb3d
A
81#endif
82
3d9156a7
A
83#ifndef _RUNE_T
84#define _RUNE_T
85typedef __darwin_rune_t rune_t;
5b2abdfb
A
86#endif
87#endif
88
9385eb3d 89#ifndef __cplusplus
3d9156a7
A
90#ifndef _WCHAR_T
91#define _WCHAR_T
92typedef __darwin_wchar_t wchar_t;
93#endif /* _WCHAR_T */
9385eb3d
A
94#endif /* __cplusplus */
95
5b2abdfb
A
96typedef struct {
97 int quot; /* quotient */
98 int rem; /* remainder */
99} div_t;
100
101typedef struct {
102 long quot; /* quotient */
103 long rem; /* remainder */
104} ldiv_t;
105
3d9156a7
A
106#if !__DARWIN_NO_LONG_LONG
107typedef struct {
108 long long quot;
109 long long rem;
110} lldiv_t;
111#endif /* !__DARWIN_NO_LONG_LONG */
112
5b2abdfb 113#ifndef NULL
3d9156a7 114#define NULL __DARWIN_NULL
59e0d9fe 115#endif /* ! NULL */
5b2abdfb
A
116
117#define EXIT_FAILURE 1
118#define EXIT_SUCCESS 0
119
120#define RAND_MAX 0x7fffffff
121
3d9156a7
A
122#ifdef _USE_EXTENDED_LOCALES_
123#include <_xlocale.h>
124#endif /* _USE_EXTENDED_LOCALES_ */
125
126#ifndef MB_CUR_MAX
127#ifdef _USE_EXTENDED_LOCALES_
128#define MB_CUR_MAX (___mb_cur_max())
129#ifndef MB_CUR_MAX_L
130#define MB_CUR_MAX_L(x) (___mb_cur_max_l(x))
131#endif /* !MB_CUR_MAX_L */
132#else /* !_USE_EXTENDED_LOCALES_ */
5b2abdfb
A
133extern int __mb_cur_max;
134#define MB_CUR_MAX __mb_cur_max
3d9156a7
A
135#endif /* _USE_EXTENDED_LOCALES_ */
136#endif /* MB_CUR_MAX */
5b2abdfb 137
3d9156a7
A
138#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \
139 && defined(_USE_EXTENDED_LOCALES_) && !defined(MB_CUR_MAX_L)
140#define MB_CUR_MAX_L(x) (___mb_cur_max_l(x))
141#endif
5b2abdfb
A
142
143__BEGIN_DECLS
9385eb3d
A
144void abort(void) __dead2;
145int abs(int) __pure2;
146int atexit(void (*)(void));
147double atof(const char *);
148int atoi(const char *);
149long atol(const char *);
3d9156a7
A
150#if !__DARWIN_NO_LONG_LONG
151long long
152 atoll(const char *);
153#endif /* !__DARWIN_NO_LONG_LONG */
9385eb3d
A
154void *bsearch(const void *, const void *, size_t,
155 size_t, int (*)(const void *, const void *));
156void *calloc(size_t, size_t);
157div_t div(int, int) __pure2;
158void exit(int) __dead2;
159void free(void *);
160char *getenv(const char *);
161long labs(long) __pure2;
162ldiv_t ldiv(long, long) __pure2;
3d9156a7
A
163#if !__DARWIN_NO_LONG_LONG
164long long
165 llabs(long long);
166lldiv_t lldiv(long long, long long);
167#endif /* !__DARWIN_NO_LONG_LONG */
9385eb3d
A
168void *malloc(size_t);
169int mblen(const char *, size_t);
170size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
171int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
172void qsort(void *, size_t, size_t,
173 int (*)(const void *, const void *));
174int rand(void);
175void *realloc(void *, size_t);
176void srand(unsigned);
177double strtod(const char *, char **);
178float strtof(const char *, char **);
179long strtol(const char *, char **, int);
180long double
3d9156a7
A
181 strtold(const char *, char **) __DARWIN_LDBL_COMPAT(strtold);
182#if !__DARWIN_NO_LONG_LONG
183long long
184 strtoll(const char *, char **, int);
185#endif /* !__DARWIN_NO_LONG_LONG */
5b2abdfb 186unsigned long
9385eb3d 187 strtoul(const char *, char **, int);
3d9156a7
A
188#if !__DARWIN_NO_LONG_LONG
189unsigned long long
190 strtoull(const char *, char **, int);
191#endif /* !__DARWIN_NO_LONG_LONG */
9385eb3d 192int system(const char *);
9385eb3d 193size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
3d9156a7 194int wctomb(char *, wchar_t);
5b2abdfb
A
195
196#ifndef _ANSI_SOURCE
3d9156a7
A
197void _Exit(int) __dead2;
198long a64l(const char *);
9385eb3d 199double drand48(void);
3d9156a7 200char *ecvt(double, int, int *__restrict, int *__restrict); /* LEGACY */
9385eb3d 201double erand48(unsigned short[3]);
3d9156a7
A
202char *fcvt(double, int, int *__restrict, int *__restrict); /* LEGACY */
203char *gcvt(double, int, char *); /* LEGACY */
204int getsubopt(char **, char * const *, char **);
205int grantpt(int);
206#if __DARWIN_UNIX03
207char *initstate(unsigned, char *, size_t); /* no __DARWIN_ALIAS needed */
208#else /* !__DARWIN_UNIX03 */
209char *initstate(unsigned long, char *, long);
210#endif /* __DARWIN_UNIX03 */
9385eb3d 211long jrand48(unsigned short[3]);
3d9156a7 212char *l64a(long);
9385eb3d
A
213void lcong48(unsigned short[7]);
214long lrand48(void);
3d9156a7
A
215char *mktemp(char *);
216int mkstemp(char *);
9385eb3d
A
217long mrand48(void);
218long nrand48(unsigned short[3]);
3d9156a7
A
219int posix_openpt(int);
220char *ptsname(int);
221int putenv(char *) __DARWIN_ALIAS(putenv);
222long random(void);
223char *realpath(const char *, char *resolved_path);
9385eb3d
A
224unsigned short
225 *seed48(unsigned short[3]);
3d9156a7
A
226int setenv(const char *, const char *, int) __DARWIN_ALIAS(setenv);
227#if __DARWIN_UNIX03
228void setkey(const char *) __DARWIN_ALIAS(setkey);
229#else /* !__DARWIN_UNIX03 */
230int setkey(const char *);
231#endif /* __DARWIN_UNIX03 */
232char *setstate(const char *);
9385eb3d 233void srand48(long);
3d9156a7
A
234#if __DARWIN_UNIX03
235void srandom(unsigned);
236#else /* !__DARWIN_UNIX03 */
237void srandom(unsigned long);
238#endif /* __DARWIN_UNIX03 */
239int unlockpt(int);
240#if __DARWIN_UNIX03
241int unsetenv(const char *) __DARWIN_ALIAS(unsetenv);
242#else /* !__DARWIN_UNIX03 */
243void unsetenv(const char *);
244#endif /* __DARWIN_UNIX03 */
245#endif
246
247#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE)
248#include <machine/types.h>
249
250#ifndef _DEV_T
251typedef __darwin_dev_t dev_t;
252#define _DEV_T
253#endif
254
255#ifndef _MODE_T
256typedef __darwin_mode_t mode_t;
257#define _MODE_T
258#endif
259
260u_int32_t
261 arc4random(void);
262void arc4random_addrandom(unsigned char *dat, int datlen);
263void arc4random_stir(void);
9385eb3d
A
264
265 /* getcap(3) functions */
266char *cgetcap(char *, const char *, int);
267int cgetclose(void);
268int cgetent(char **, char **, const char *);
269int cgetfirst(char **, char **);
270int cgetmatch(const char *, const char *);
271int cgetnext(char **, char **);
272int cgetnum(char *, const char *, long *);
273int cgetset(const char *);
274int cgetstr(char *, const char *, char **);
275int cgetustr(char *, const char *, char **);
276
277int daemon(int, int);
3d9156a7
A
278char *devname(dev_t, mode_t);
279char *devname_r(dev_t, mode_t, char *buf, int len);
9385eb3d
A
280char *getbsize(int *, long *);
281int getloadavg(double [], int);
282const char
283 *getprogname(void);
284
9385eb3d
A
285int heapsort(void *, size_t, size_t,
286 int (*)(const void *, const void *));
9385eb3d
A
287int mergesort(void *, size_t, size_t,
288 int (*)(const void *, const void *));
9385eb3d
A
289void qsort_r(void *, size_t, size_t, void *,
290 int (*)(void *, const void *, const void *));
291int radixsort(const unsigned char **, int, const unsigned char *,
292 unsigned);
293void setprogname(const char *);
294int sradixsort(const unsigned char **, int, const unsigned char *,
295 unsigned);
296void sranddev(void);
297void srandomdev(void);
298int rand_r(unsigned *);
9385eb3d 299void *reallocf(void *, size_t);
3d9156a7 300#if !__DARWIN_NO_LONG_LONG
5b2abdfb 301long long
9385eb3d 302 strtoq(const char *, char **, int);
5b2abdfb 303unsigned long long
9385eb3d 304 strtouq(const char *, char **, int);
3d9156a7
A
305#endif /* !__DARWIN_NO_LONG_LONG */
306extern char *suboptarg; /* getsubopt(3) external variable */
307void *valloc(size_t);
5b2abdfb
A
308#endif
309__END_DECLS
310
3d9156a7
A
311#ifdef _USE_EXTENDED_LOCALES_
312#include <xlocale/_stdlib.h>
313#endif /* _USE_EXTENDED_LOCALES_ */
314
5b2abdfb 315#endif /* _STDLIB_H_ */