]> git.saurik.com Git - apple/libc.git/blob - include/stdlib.h
08c9bc7e79887872feb183038ea2bba93e8ebab0
[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
66 #ifndef _BSD_SIZE_T_DEFINED_
67 #define _BSD_SIZE_T_DEFINED_
68 typedef _BSD_SIZE_T_ size_t;
69 #endif
70
71 #if !defined(_ANSI_SOURCE)
72 #ifndef _BSD_RUNE_T_DEFINED_
73 #define _BSD_RUNE_T_DEFINED_
74 typedef _BSD_WCHAR_T_ rune_t;
75 #endif
76 #endif
77
78 #ifndef _BSD_WCHAR_T_DEFINED_
79 #define _BSD_WCHAR_T_DEFINED_
80 typedef _BSD_WCHAR_T_ wchar_t;
81 #endif
82
83 typedef struct {
84 int quot; /* quotient */
85 int rem; /* remainder */
86 } div_t;
87
88 typedef struct {
89 long quot; /* quotient */
90 long rem; /* remainder */
91 } ldiv_t;
92
93 #ifndef NULL
94 #define NULL 0
95 #endif
96
97 #define EXIT_FAILURE 1
98 #define EXIT_SUCCESS 0
99
100 #define RAND_MAX 0x7fffffff
101
102 extern int __mb_cur_max;
103 #define MB_CUR_MAX __mb_cur_max
104
105 #include <sys/cdefs.h>
106
107 __BEGIN_DECLS
108 __dead void
109 abort __P((void));
110 __pure int
111 abs __P((int));
112 int atexit __P((void (*)(void)));
113 double atof __P((const char *));
114 int atoi __P((const char *));
115 long atol __P((const char *));
116 void *bsearch __P((const void *, const void *, size_t,
117 size_t, int (*)(const void *, const void *)));
118 void *calloc __P((size_t, size_t));
119 __pure div_t
120 div __P((int, int));
121 __dead void
122 exit __P((int));
123 void free __P((void *));
124 char *getenv __P((const char *));
125 __pure long
126 labs __P((long));
127 __pure ldiv_t
128 ldiv __P((long, long));
129 void *malloc __P((size_t));
130 void qsort __P((void *, size_t, size_t,
131 int (*)(const void *, const void *)));
132 int rand __P((void));
133 void *realloc __P((void *, size_t));
134 void srand __P((unsigned));
135 double strtod __P((const char *, char **));
136 long strtol __P((const char *, char **, int));
137 unsigned long
138 strtoul __P((const char *, char **, int));
139 int system __P((const char *));
140
141 /* These are currently just stubs. */
142 int mblen __P((const char *, size_t));
143 size_t mbstowcs __P((wchar_t *, const char *, size_t));
144 int wctomb __P((char *, wchar_t));
145 int mbtowc __P((wchar_t *, const char *, size_t));
146 size_t wcstombs __P((char *, const wchar_t *, size_t));
147
148 #ifndef _ANSI_SOURCE
149 int putenv __P((const char *));
150 int setenv __P((const char *, const char *, int));
151 #endif
152
153 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
154 double drand48 __P((void));
155 double erand48 __P((unsigned short[3]));
156 long jrand48 __P((unsigned short[3]));
157 void lcong48 __P((unsigned short[7]));
158 long lrand48 __P((void));
159 long mrand48 __P((void));
160 long nrand48 __P((unsigned short[3]));
161 unsigned short
162 *seed48 __P((unsigned short[3]));
163 void srand48 __P((long));
164
165 void *alloca __P((size_t)); /* built-in for gcc */
166 /* getcap(3) functions */
167 u_int32_t
168 arc4random __P((void));
169 void arc4random_addrandom __P((unsigned char *dat, int datlen));
170 void arc4random_stir __P((void));
171 char *getbsize __P((int *, long *));
172 char *cgetcap __P((char *, char *, int));
173 int cgetclose __P((void));
174 int cgetent __P((char **, char **, char *));
175 int cgetfirst __P((char **, char **));
176 int cgetmatch __P((char *, char *));
177 int cgetnext __P((char **, char **));
178 int cgetnum __P((char *, char *, long *));
179 int cgetset __P((char *));
180 int cgetstr __P((char *, char *, char **));
181 int cgetustr __P((char *, char *, char **));
182
183 int daemon __P((int, int));
184 char *devname __P((int, int));
185 int getloadavg __P((double [], int));
186
187 long a64l __P((const char *));
188 char *l64a __P((long));
189
190 char *group_from_gid __P((unsigned long, int));
191 int heapsort __P((void *, size_t, size_t,
192 int (*)(const void *, const void *)));
193 char *initstate __P((unsigned long, char *, long));
194 int mergesort __P((void *, size_t, size_t,
195 int (*)(const void *, const void *)));
196 int radixsort __P((const unsigned char **, int, const unsigned char *,
197 unsigned));
198 int sradixsort __P((const unsigned char **, int, const unsigned char *,
199 unsigned));
200 int rand_r __P((unsigned *));
201 long random __P((void));
202 void *reallocf __P((void *, size_t));
203 char *realpath __P((const char *, char resolved_path[]));
204 char *setstate __P((char *));
205 void srandom __P((unsigned long));
206 char *user_from_uid __P((unsigned long, int));
207 #ifndef __STRICT_ANSI__
208 long long
209 strtoll(const char *, char **, int);
210 unsigned long long
211 strtoull(const char *, char **, int);
212 long long
213 strtoq __P((const char *, char **, int));
214 unsigned long long
215 strtouq __P((const char *, char **, int));
216 #endif
217 void unsetenv __P((const char *));
218 #endif
219 __END_DECLS
220
221 #endif /* _STDLIB_H_ */