2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
40 #include <sys/cdefs.h>
41 #include <sys/_types.h>
44 #ifndef _RUNE_T_DECLARED
45 typedef __rune_t rune_t;
46 #define _RUNE_T_DECLARED
50 #ifndef _SIZE_T_DECLARED
51 typedef __size_t size_t;
52 #define _SIZE_T_DECLARED
56 #ifndef _WCHAR_T_DECLARED
57 typedef __wchar_t wchar_t;
58 #define _WCHAR_T_DECLARED
63 int quot; /* quotient */
64 int rem; /* remainder */
76 #define EXIT_FAILURE 1
77 #define EXIT_SUCCESS 0
79 #define RAND_MAX 0x7fffffff
81 extern int __mb_cur_max;
82 #define MB_CUR_MAX __mb_cur_max
85 void abort(void) __dead2;
87 int atexit(void (*)(void));
88 double atof(const char *);
89 int atoi(const char *);
90 long atol(const char *);
91 void *bsearch(const void *, const void *, size_t,
92 size_t, int (*)(const void *, const void *));
93 void *calloc(size_t, size_t);
94 div_t div(int, int) __pure2;
95 void exit(int) __dead2;
97 char *getenv(const char *);
98 long labs(long) __pure2;
99 ldiv_t ldiv(long, long) __pure2;
100 void *malloc(size_t);
101 int mblen(const char *, size_t);
102 size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
103 int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
104 void qsort(void *, size_t, size_t,
105 int (*)(const void *, const void *));
107 void *realloc(void *, size_t);
108 void srand(unsigned);
109 double strtod(const char * __restrict, char ** __restrict);
110 /* float strtof(const char * __restrict, char ** __restrict); */
111 long strtol(const char * __restrict, char ** __restrict, int);
113 strtold(const char * __restrict, char ** __restrict); */
115 strtoul(const char * __restrict, char ** __restrict, int);
116 int system(const char *);
117 int wctomb(char *, wchar_t);
118 size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
121 * Functions added in C99 which we make conditionally available in the
122 * BSD^C89 namespace if the compiler supports `long long'.
123 * The #if test is more complicated than it ought to be because
124 * __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long'
125 * is not supported in the compilation environment (which therefore means
126 * that it can't really be ISO C99).
128 * (The only other extension made by C99 in thie header is _Exit().)
130 #if __ISO_C_VISIBLE >= 1999
131 #ifdef __LONG_LONG_SUPPORTED
143 llabs(long long) __pure2;
145 lldiv_t lldiv(long long, long long) __pure2;
148 strtoll(const char * __restrict, char ** __restrict, int);
151 strtoull(const char * __restrict, char ** __restrict, int);
152 #endif /* __LONG_LONG_SUPPORTED */
154 void _Exit(int) __dead2;
155 #endif /* __ISO_C_VISIBLE >= 1999 */
158 * Extensions made by POSIX relative to C. We don't know yet which edition
159 * of POSIX made these extensions, so assume they've always been there until
160 * research can be done.
162 #if __POSIX_VISIBLE /* >= ??? */
163 /* int posix_memalign(void **, size_t, size_t); (ADV) */
164 int rand_r(unsigned *); /* (TSF) */
165 int setenv(const char *, const char *, int);
166 void unsetenv(const char *);
170 * The only changes to the XSI namespace in revision 6 were the deletion
171 * of the ttyslot() and valloc() functions, which FreeBSD never declared
172 * in this header. For revision 7, ecvt(), fcvt(), and gcvt(), which
173 * FreeBSD also does not have, and mktemp(), are to be deleted.
176 /* XXX XSI requires pollution from <sys/wait.h> here. We'd rather not. */
177 /* long a64l(const char *); */
178 double drand48(void);
179 /* char *ecvt(double, int, int * __restrict, int * __restrict); */
180 double erand48(unsigned short[3]);
181 /* char *fcvt(double, int, int * __restrict, int * __restrict); */
182 /* char *gcvt(double, int, int * __restrict, int * __restrict); */
183 #ifndef _GETSUBOPT_DECLARED
184 int getsubopt(char **, char *const *, char **);
185 #define _GETSUBOPT_DECLARED
187 /* int grantpt(int); */
188 char *initstate(unsigned long /* XSI requires u_int */, char *, long);
189 long jrand48(unsigned short[3]);
190 /* char *l64a(long); */
191 void lcong48(unsigned short[7]);
193 #ifndef _MKSTEMP_DECLARED
195 #define _MKSTEMP_DECLARED
197 #ifndef _MKTEMP_DECLARED
198 char *mktemp(char *);
199 #define _MKTEMP_DECLARED
202 long nrand48(unsigned short[3]);
203 /* int posix_openpt(int); */
204 /* char *ptsname(int); */
205 int putenv(const char *);
207 char *realpath(const char *, char resolved_path[]);
209 *seed48(unsigned short[3]);
210 #ifndef _SETKEY_DECLARED
211 int setkey(const char *);
212 #define _SETKEY_DECLARED
214 char *setstate(/* const */ char *);
216 void srandom(unsigned long);
217 /* int unlockpt(int); */
218 #endif /* __XSI_VISIBLE */
221 extern const char *_malloc_options;
222 extern void (*_malloc_message)(const char *, const char *, const char *,
225 void *alloca(size_t); /* built-in for gcc */
228 void arc4random_addrandom(unsigned char *dat, int datlen);
229 void arc4random_stir(void);
230 char *getbsize(int *, long *);
231 /* getcap(3) functions */
232 char *cgetcap(char *, const char *, int);
234 int cgetent(char **, char **, const char *);
235 int cgetfirst(char **, char **);
236 int cgetmatch(const char *, const char *);
237 int cgetnext(char **, char **);
238 int cgetnum(char *, const char *, long *);
239 int cgetset(const char *);
240 int cgetstr(char *, const char *, char **);
241 int cgetustr(char *, const char *, char **);
243 int daemon(int, int);
244 char *devname(int, int);
245 int getloadavg(double [], int);
249 int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
250 int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
251 void qsort_r(void *, size_t, size_t, void *,
252 int (*)(void *, const void *, const void *));
253 int radixsort(const unsigned char **, int, const unsigned char *,
255 void *reallocf(void *, size_t);
256 void setprogname(const char *);
257 int sradixsort(const unsigned char **, int, const unsigned char *,
260 void srandomdev(void);
262 /* Deprecated interfaces, to be removed in FreeBSD 6.0. */
264 strtoq(const char *, char **, int);
266 strtouq(const char *, char **, int);
267 #endif /* __BSD_VISIBLE */
270 #endif /* !_STDLIB_H_ */