MFC: Document -f.
[dragonfly.git] / include / stdlib.h
blob12a22fc37810c1f8c502361fb877cfa49fd7a9bb
1 /*-
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
7 * are met:
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
31 * SUCH DAMAGE.
33 * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
34 * $FreeBSD: src/include/stdlib.h,v 1.16.2.5 2002/12/13 01:34:00 tjr Exp $
35 * $DragonFly: src/include/stdlib.h,v 1.22 2008/06/05 17:53:10 swildner Exp $
38 #ifndef _STDLIB_H_
39 #define _STDLIB_H_
41 #include <sys/cdefs.h>
42 #include <sys/types.h>
44 #ifndef _SYS_STDINT_H_
45 #include <sys/stdint.h>
46 #endif
48 #ifndef __cplusplus
49 #ifndef _WCHAR_T_DECLARED
50 #define _WCHAR_T_DECLARED
51 typedef __wchar_t wchar_t;
52 #endif
53 #endif
55 #ifndef _SIZE_T_DECLARED
56 #define _SIZE_T_DECLARED
57 typedef __size_t size_t;
58 #endif
60 typedef struct {
61 int quot; /* quotient */
62 int rem; /* remainder */
63 } div_t;
65 typedef struct {
66 long quot; /* quotient */
67 long rem; /* remainder */
68 } ldiv_t;
70 #if __ISO_C_VISIBLE >= 1999
71 typedef struct {
72 long long quot;
73 long long rem;
74 } lldiv_t;
75 #endif
77 #include <sys/_null.h>
79 #define EXIT_FAILURE 1
80 #define EXIT_SUCCESS 0
82 #define RAND_MAX 0x7fffffff
84 extern int __mb_cur_max;
85 #define MB_CUR_MAX __mb_cur_max
87 __BEGIN_DECLS
88 void _Exit(int) __dead2;
89 void abort(void) __dead2;
90 int abs(int) __pure2;
91 int atexit(void (*)(void));
92 double atof(const char *);
93 int atoi(const char *);
94 long atol(const char *);
95 void *bsearch(const void *, const void *, size_t,
96 size_t, int (*)(const void *, const void *));
97 void *calloc(size_t, size_t);
98 div_t div(int, int) __pure2;
99 void exit(int) __dead2;
100 void free(void *);
101 char *getenv(const char *);
102 long labs(long) __pure2;
103 ldiv_t ldiv(long, long) __pure2;
104 #if __ISO_C_VISIBLE >= 1999
105 lldiv_t lldiv(long long, long long) __pure2;
106 #endif
107 void *malloc(size_t);
108 void qsort(void *, size_t, size_t, int(*)(const void *, const void *));
109 int rand(void);
110 void *realloc(void *, size_t);
111 void srand(unsigned);
112 double strtod(const char *, char **);
113 #ifdef __LONG_LONG_SUPPORTED
114 long long int atoll(const char *);
115 long long llabs(long long) __pure2;
116 long long strtoll(const char *, char **, int);
117 unsigned long long strtoull(const char *, char **, int);
118 #endif
119 int system(const char *);
121 #if !defined(_KERNEL_VIRTUAL)
122 long strtol(const char *, char **, int);
123 unsigned long strtoul(const char *, char **, int);
124 #endif
126 int mblen(const char *, size_t);
127 size_t mbstowcs(wchar_t *, const char *, size_t);
128 int wctomb(char *, wchar_t);
129 int mbtowc(wchar_t *, const char *, size_t);
130 size_t wcstombs(char *, const wchar_t *, size_t);
132 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
133 int putenv(const char *);
134 int setenv(const char *, const char *, int);
136 double drand48(void);
137 double erand48(unsigned short[3]);
138 long jrand48(unsigned short[3]);
139 void lcong48(unsigned short[7]);
140 long lrand48(void);
141 long mrand48(void);
142 long nrand48(unsigned short[3]);
143 unsigned short *seed48(unsigned short[3]);
144 void srand48(long);
146 void *alloca(size_t); /* built-in for gcc */
147 /* getcap(3) functions */
148 __uint32_t arc4random(void);
149 void arc4random_addrandom(__uint8_t *, size_t);
150 void arc4random_stir(void);
151 char *getbsize(int *, long *);
152 char *cgetcap(char *, char *, int);
153 int cgetclose(void);
154 int cgetent(char **, char **, char *);
155 int cgetfirst(char **, char **);
156 int cgetmatch(char *, char *);
157 int cgetnext(char **, char **);
158 int cgetnum(char *, char *, long *);
159 int cgetset(char *);
160 int cgetstr(char *, char *, char **);
161 int cgetustr(char *, char *, char **);
163 int daemon(int, int);
164 char *devname(dev_t, mode_t);
165 char *devname_r(dev_t, mode_t, char *, size_t);
166 int getloadavg(double [], int);
167 const char *getprogname(void);
169 char *group_from_gid(gid_t, int);
170 int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
171 char *initstate(unsigned long, char *, long);
172 int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
173 int radixsort(const unsigned char **, int, const unsigned char *,
174 unsigned int);
175 int sradixsort(const unsigned char **, int, const unsigned char *,
176 unsigned int);
177 int rand_r(unsigned *);
178 long random(void);
179 void *reallocf(void *, size_t);
180 char *realpath(const char *, char []);
181 void setprogname(const char *);
182 char *setstate(char *);
183 void srandom(unsigned long);
184 void srandomdev(void);
185 char *user_from_uid(uid_t, int);
187 #if !defined(__STRICT_ANSI__) && !defined(_KERNEL_VIRTUAL)
188 __int64_t strtoq(const char *, char **, int);
189 __uint64_t strtouq(const char *, char **, int);
190 #endif
192 #ifndef __STRICT_ANSI__
193 #ifdef __LONG_LONG_SUPPORTED
194 long long
195 strtonum(const char *, long long, long long, const char **);
196 #endif
197 #endif
198 void unsetenv(const char *);
199 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
200 __END_DECLS
202 #endif /* !_STDLIB_H_ */