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