]> git.saurik.com Git - apple/libc.git/blob - include/stdlib.h
165c87c3854eb6961a85d0abbf6b906f58422ad7
[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 * 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
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
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
61 #include <machine/ansi.h>
62 #include <machine/types.h>
63 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
64 #include <alloca.h>
65 #endif
66
67 #ifndef _BSD_SIZE_T_DEFINED_
68 #define _BSD_SIZE_T_DEFINED_
69 typedef _BSD_SIZE_T_ size_t;
70 #endif
71
72 #if !defined(_ANSI_SOURCE)
73 #ifndef _BSD_CT_RUNE_T_DEFINED_
74 #define _BSD_CT_RUNE_T_DEFINED_
75 typedef _BSD_CT_RUNE_T_ ct_rune_t;
76 #endif
77
78 #ifndef _BSD_RUNE_T_DEFINED_
79 #define _BSD_RUNE_T_DEFINED_
80 typedef _BSD_RUNE_T_ rune_t;
81 #endif
82 #endif
83
84 #ifndef __cplusplus
85 #ifndef _BSD_WCHAR_T_DEFINED_
86 #define _BSD_WCHAR_T_DEFINED_
87 #ifdef __WCHAR_TYPE__
88 typedef __WCHAR_TYPE__ wchar_t;
89 #else /* ! __WCHAR_TYPE__ */
90 typedef _BSD_WCHAR_T_ wchar_t;
91 #endif /* __WCHAR_TYPE__ */
92 #endif /* _BSD_WCHAR_T_DEFINED_ */
93 #endif /* __cplusplus */
94
95 #ifndef _BSD_WINT_T_DEFINED_
96 #define _BSD_WINT_T_DEFINED_
97 typedef _BSD_WINT_T_ wint_t;
98 #endif
99
100 typedef struct {
101 int quot; /* quotient */
102 int rem; /* remainder */
103 } div_t;
104
105 typedef struct {
106 long quot; /* quotient */
107 long rem; /* remainder */
108 } ldiv_t;
109
110 #ifndef NULL
111 #define NULL 0
112 #endif
113
114 #define EXIT_FAILURE 1
115 #define EXIT_SUCCESS 0
116
117 #define RAND_MAX 0x7fffffff
118
119 extern int __mb_cur_max;
120 #define MB_CUR_MAX __mb_cur_max
121
122 #include <sys/cdefs.h>
123
124 __BEGIN_DECLS
125 void abort(void) __dead2;
126 int abs(int) __pure2;
127 int atexit(void (*)(void));
128 double atof(const char *);
129 int atoi(const char *);
130 long atol(const char *);
131 void *bsearch(const void *, const void *, size_t,
132 size_t, int (*)(const void *, const void *));
133 void *calloc(size_t, size_t);
134 div_t div(int, int) __pure2;
135 void exit(int) __dead2;
136 void free(void *);
137 char *getenv(const char *);
138 long labs(long) __pure2;
139 ldiv_t ldiv(long, long) __pure2;
140 void *malloc(size_t);
141 int mblen(const char *, size_t);
142 size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
143 int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
144 void qsort(void *, size_t, size_t,
145 int (*)(const void *, const void *));
146 int rand(void);
147 void *realloc(void *, size_t);
148 void srand(unsigned);
149 double strtod(const char *, char **);
150 float strtof(const char *, char **);
151 long strtol(const char *, char **, int);
152 long double
153 strtold(const char *, char **);
154 unsigned long
155 strtoul(const char *, char **, int);
156 int system(const char *);
157 void *valloc(size_t);
158 int wctomb(char *, wchar_t);
159 size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
160
161 #ifndef _ANSI_SOURCE
162 int putenv(const char *);
163 int setenv(const char *, const char *, int);
164 #endif
165
166 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
167 u_int32_t
168 arc4random(void);
169 void arc4random_addrandom(unsigned char *dat, int datlen);
170 void arc4random_stir(void);
171 double drand48(void);
172 double erand48(unsigned short[3]);
173 long jrand48(unsigned short[3]);
174 void lcong48(unsigned short[7]);
175 long lrand48(void);
176 long mrand48(void);
177 long nrand48(unsigned short[3]);
178 unsigned short
179 *seed48(unsigned short[3]);
180 void srand48(long);
181
182 /* getcap(3) functions */
183 char *cgetcap(char *, const char *, int);
184 int cgetclose(void);
185 int cgetent(char **, char **, const char *);
186 int cgetfirst(char **, char **);
187 int cgetmatch(const char *, const char *);
188 int cgetnext(char **, char **);
189 int cgetnum(char *, const char *, long *);
190 int cgetset(const char *);
191 int cgetstr(char *, const char *, char **);
192 int cgetustr(char *, const char *, char **);
193
194 int daemon(int, int);
195 char *devname(int, int);
196 char *getbsize(int *, long *);
197 int getloadavg(double [], int);
198 const char
199 *getprogname(void);
200
201 long a64l(const char *);
202 char *l64a(long);
203
204 /* int grantpt(int); */
205 int heapsort(void *, size_t, size_t,
206 int (*)(const void *, const void *));
207 char *initstate(unsigned long, char *, long);
208 int mergesort(void *, size_t, size_t,
209 int (*)(const void *, const void *));
210 /* int posix_openpt(int); */
211 /* char *ptsname(int); */
212 void qsort_r(void *, size_t, size_t, void *,
213 int (*)(void *, const void *, const void *));
214 int radixsort(const unsigned char **, int, const unsigned char *,
215 unsigned);
216 void setprogname(const char *);
217 int sradixsort(const unsigned char **, int, const unsigned char *,
218 unsigned);
219 void sranddev(void);
220 void srandomdev(void);
221 int rand_r(unsigned *);
222 long random(void);
223 void *reallocf(void *, size_t);
224 char *realpath(const char *, char resolved_path[]);
225 char *setstate(char *);
226 void srandom(unsigned long);
227 /* int unlockpt(int); */
228 #ifndef __STRICT_ANSI__
229 typedef struct {
230 long long quot;
231 long long rem;
232 } lldiv_t;
233
234 long long
235 atoll(const char *);
236 long long
237 llabs(long long);
238 lldiv_t lldiv(long long, long long);
239 long long
240 strtoll(const char *, char **, int);
241 unsigned long long
242 strtoull(const char *, char **, int);
243 long long
244 strtoq(const char *, char **, int);
245 unsigned long long
246 strtouq(const char *, char **, int);
247 #endif
248 void unsetenv(const char *);
249 #endif
250 __END_DECLS
251
252 #endif /* _STDLIB_H_ */