]> git.saurik.com Git - apple/libc.git/blob - include/stdlib.h
485d0275402535717aa00b7c73bd8011627c7305
[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 #define NULL 0
114 #endif
115
116 #define EXIT_FAILURE 1
117 #define EXIT_SUCCESS 0
118
119 #define RAND_MAX 0x7fffffff
120
121 extern int __mb_cur_max;
122 #define MB_CUR_MAX __mb_cur_max
123
124 #include <sys/cdefs.h>
125
126 __BEGIN_DECLS
127 void abort(void) __dead2;
128 int abs(int) __pure2;
129 int atexit(void (*)(void));
130 double atof(const char *);
131 int atoi(const char *);
132 long atol(const char *);
133 void *bsearch(const void *, const void *, size_t,
134 size_t, int (*)(const void *, const void *));
135 void *calloc(size_t, size_t);
136 div_t div(int, int) __pure2;
137 void exit(int) __dead2;
138 void free(void *);
139 char *getenv(const char *);
140 long labs(long) __pure2;
141 ldiv_t ldiv(long, long) __pure2;
142 void *malloc(size_t);
143 int mblen(const char *, size_t);
144 size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
145 int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
146 void qsort(void *, size_t, size_t,
147 int (*)(const void *, const void *));
148 int rand(void);
149 void *realloc(void *, size_t);
150 void srand(unsigned);
151 double strtod(const char *, char **);
152 float strtof(const char *, char **);
153 long strtol(const char *, char **, int);
154 long double
155 strtold(const char *, char **);
156 unsigned long
157 strtoul(const char *, char **, int);
158 int system(const char *);
159 void *valloc(size_t);
160 int wctomb(char *, wchar_t);
161 size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
162
163 #ifndef _ANSI_SOURCE
164 int putenv(const char *);
165 int setenv(const char *, const char *, int);
166 #endif
167
168 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
169 u_int32_t
170 arc4random(void);
171 void arc4random_addrandom(unsigned char *dat, int datlen);
172 void arc4random_stir(void);
173 double drand48(void);
174 double erand48(unsigned short[3]);
175 long jrand48(unsigned short[3]);
176 void lcong48(unsigned short[7]);
177 long lrand48(void);
178 long mrand48(void);
179 long nrand48(unsigned short[3]);
180 unsigned short
181 *seed48(unsigned short[3]);
182 void srand48(long);
183
184 /* getcap(3) functions */
185 char *cgetcap(char *, const char *, int);
186 int cgetclose(void);
187 int cgetent(char **, char **, const char *);
188 int cgetfirst(char **, char **);
189 int cgetmatch(const char *, const char *);
190 int cgetnext(char **, char **);
191 int cgetnum(char *, const char *, long *);
192 int cgetset(const char *);
193 int cgetstr(char *, const char *, char **);
194 int cgetustr(char *, const char *, char **);
195
196 int daemon(int, int);
197 char *devname(int, int);
198 char *getbsize(int *, long *);
199 int getloadavg(double [], int);
200 const char
201 *getprogname(void);
202
203 long a64l(const char *);
204 char *l64a(long);
205
206 /* int grantpt(int); */
207 int heapsort(void *, size_t, size_t,
208 int (*)(const void *, const void *));
209 char *initstate(unsigned long, char *, long);
210 int mergesort(void *, size_t, size_t,
211 int (*)(const void *, const void *));
212 /* int posix_openpt(int); */
213 /* char *ptsname(int); */
214 void qsort_r(void *, size_t, size_t, void *,
215 int (*)(void *, const void *, const void *));
216 int radixsort(const unsigned char **, int, const unsigned char *,
217 unsigned);
218 void setprogname(const char *);
219 int sradixsort(const unsigned char **, int, const unsigned char *,
220 unsigned);
221 void sranddev(void);
222 void srandomdev(void);
223 int rand_r(unsigned *);
224 long random(void);
225 void *reallocf(void *, size_t);
226 char *realpath(const char *, char resolved_path[]);
227 char *setstate(char *);
228 void srandom(unsigned long);
229 /* int unlockpt(int); */
230 #ifndef __STRICT_ANSI__
231 typedef struct {
232 long long quot;
233 long long rem;
234 } lldiv_t;
235
236 long long
237 atoll(const char *);
238 long long
239 llabs(long long);
240 lldiv_t lldiv(long long, long long);
241 long long
242 strtoll(const char *, char **, int);
243 unsigned long long
244 strtoull(const char *, char **, int);
245 long long
246 strtoq(const char *, char **, int);
247 unsigned long long
248 strtouq(const char *, char **, int);
249 #endif
250 void unsetenv(const char *);
251 #endif
252 __END_DECLS
253
254 #endif /* _STDLIB_H_ */