]> git.saurik.com Git - apple/libc.git/blob - include/stdlib.h
4d622b243d27411314e650f7ccef5f61196c290d
[apple/libc.git] / include / stdlib.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*-
26 * Copyright (c) 1990, 1993
27 * The Regents of the University of California. All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 * 1. Redistributions of source code must retain the above copyright
33 * notice, this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in the
36 * documentation and/or other materials provided with the distribution.
37 * 3. All advertising materials mentioning features or use of this software
38 * must display the following acknowledgement:
39 * This product includes software developed by the University of
40 * California, Berkeley and its contributors.
41 * 4. Neither the name of the University nor the names of its contributors
42 * may be used to endorse or promote products derived from this software
43 * without specific prior written permission.
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE.
56 *
57 * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
58 */
59
60 #ifndef _STDLIB_H_
61 #define _STDLIB_H_
62
63 #include <machine/ansi.h>
64 #include <machine/types.h>
65 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
66 #include <alloca.h>
67 #endif
68
69 #ifndef _BSD_SIZE_T_DEFINED_
70 #define _BSD_SIZE_T_DEFINED_
71 typedef _BSD_SIZE_T_ size_t;
72 #endif
73
74 #if !defined(_ANSI_SOURCE)
75 #ifndef _BSD_CT_RUNE_T_DEFINED_
76 #define _BSD_CT_RUNE_T_DEFINED_
77 typedef _BSD_CT_RUNE_T_ ct_rune_t;
78 #endif
79
80 #ifndef _BSD_RUNE_T_DEFINED_
81 #define _BSD_RUNE_T_DEFINED_
82 typedef _BSD_RUNE_T_ rune_t;
83 #endif
84 #endif
85
86 #ifndef __cplusplus
87 #ifndef _BSD_WCHAR_T_DEFINED_
88 #define _BSD_WCHAR_T_DEFINED_
89 #ifdef __WCHAR_TYPE__
90 typedef __WCHAR_TYPE__ wchar_t;
91 #else /* ! __WCHAR_TYPE__ */
92 typedef _BSD_WCHAR_T_ wchar_t;
93 #endif /* __WCHAR_TYPE__ */
94 #endif /* _BSD_WCHAR_T_DEFINED_ */
95 #endif /* __cplusplus */
96
97 #ifndef _BSD_WINT_T_DEFINED_
98 #define _BSD_WINT_T_DEFINED_
99 typedef _BSD_WINT_T_ wint_t;
100 #endif
101
102 typedef struct {
103 int quot; /* quotient */
104 int rem; /* remainder */
105 } div_t;
106
107 typedef struct {
108 long quot; /* quotient */
109 long rem; /* remainder */
110 } ldiv_t;
111
112 #ifndef NULL
113 #ifdef __GNUG__
114 #define NULL __null
115 #else /* ! __GNUG__ */
116 #ifndef __cplusplus
117 #define NULL ((void *)0)
118 #else /* __cplusplus */
119 #define NULL 0
120 #endif /* ! __cplusplus */
121 #endif /* __GNUG__ */
122 #endif /* ! NULL */
123
124 #define EXIT_FAILURE 1
125 #define EXIT_SUCCESS 0
126
127 #define RAND_MAX 0x7fffffff
128
129 extern int __mb_cur_max;
130 #define MB_CUR_MAX __mb_cur_max
131
132 #include <sys/cdefs.h>
133
134 __BEGIN_DECLS
135 void abort(void) __dead2;
136 int abs(int) __pure2;
137 int atexit(void (*)(void));
138 double atof(const char *);
139 int atoi(const char *);
140 long atol(const char *);
141 void *bsearch(const void *, const void *, size_t,
142 size_t, int (*)(const void *, const void *));
143 void *calloc(size_t, size_t);
144 div_t div(int, int) __pure2;
145 void exit(int) __dead2;
146 void free(void *);
147 char *getenv(const char *);
148 long labs(long) __pure2;
149 ldiv_t ldiv(long, long) __pure2;
150 void *malloc(size_t);
151 int mblen(const char *, size_t);
152 size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
153 int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
154 void qsort(void *, size_t, size_t,
155 int (*)(const void *, const void *));
156 int rand(void);
157 void *realloc(void *, size_t);
158 void srand(unsigned);
159 double strtod(const char *, char **);
160 float strtof(const char *, char **);
161 long strtol(const char *, char **, int);
162 long double
163 strtold(const char *, char **);
164 unsigned long
165 strtoul(const char *, char **, int);
166 int system(const char *);
167 void *valloc(size_t);
168 int wctomb(char *, wchar_t);
169 size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
170
171 #ifndef _ANSI_SOURCE
172 int putenv(const char *);
173 int setenv(const char *, const char *, int);
174 #endif
175
176 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
177 u_int32_t
178 arc4random(void);
179 void arc4random_addrandom(unsigned char *dat, int datlen);
180 void arc4random_stir(void);
181 double drand48(void);
182 double erand48(unsigned short[3]);
183 long jrand48(unsigned short[3]);
184 void lcong48(unsigned short[7]);
185 long lrand48(void);
186 long mrand48(void);
187 long nrand48(unsigned short[3]);
188 unsigned short
189 *seed48(unsigned short[3]);
190 void srand48(long);
191
192 /* getcap(3) functions */
193 char *cgetcap(char *, const char *, int);
194 int cgetclose(void);
195 int cgetent(char **, char **, const char *);
196 int cgetfirst(char **, char **);
197 int cgetmatch(const char *, const char *);
198 int cgetnext(char **, char **);
199 int cgetnum(char *, const char *, long *);
200 int cgetset(const char *);
201 int cgetstr(char *, const char *, char **);
202 int cgetustr(char *, const char *, char **);
203
204 int daemon(int, int);
205 char *devname(int, int);
206 char *getbsize(int *, long *);
207 int getloadavg(double [], int);
208 const char
209 *getprogname(void);
210
211 long a64l(const char *);
212 char *l64a(long);
213
214 /* int grantpt(int); */
215 int heapsort(void *, size_t, size_t,
216 int (*)(const void *, const void *));
217 char *initstate(unsigned long, char *, long);
218 int mergesort(void *, size_t, size_t,
219 int (*)(const void *, const void *));
220 /* int posix_openpt(int); */
221 /* char *ptsname(int); */
222 void qsort_r(void *, size_t, size_t, void *,
223 int (*)(void *, const void *, const void *));
224 int radixsort(const unsigned char **, int, const unsigned char *,
225 unsigned);
226 void setprogname(const char *);
227 int sradixsort(const unsigned char **, int, const unsigned char *,
228 unsigned);
229 void sranddev(void);
230 void srandomdev(void);
231 int rand_r(unsigned *);
232 long random(void);
233 void *reallocf(void *, size_t);
234 char *realpath(const char *, char resolved_path[]);
235 char *setstate(char *);
236 void srandom(unsigned long);
237 /* int unlockpt(int); */
238 #ifndef __STRICT_ANSI__
239 typedef struct {
240 long long quot;
241 long long rem;
242 } lldiv_t;
243
244 long long
245 atoll(const char *);
246 long long
247 llabs(long long);
248 lldiv_t lldiv(long long, long long);
249 long long
250 strtoll(const char *, char **, int);
251 unsigned long long
252 strtoull(const char *, char **, int);
253 long long
254 strtoq(const char *, char **, int);
255 unsigned long long
256 strtouq(const char *, char **, int);
257 #endif
258 void unsetenv(const char *);
259 #endif
260 __END_DECLS
261
262 #endif /* _STDLIB_H_ */