stdlib.h revision 1.62 1 1.62 bjh21 /* $NetBSD: stdlib.h,v 1.62 2003/04/28 23:16:14 bjh21 Exp $ */
2 1.20 cgd
3 1.1 cgd /*-
4 1.30 perry * Copyright (c) 1990, 1993
5 1.30 perry * The Regents of the University of California. All rights reserved.
6 1.1 cgd *
7 1.1 cgd * Redistribution and use in source and binary forms, with or without
8 1.1 cgd * modification, are permitted provided that the following conditions
9 1.1 cgd * are met:
10 1.1 cgd * 1. Redistributions of source code must retain the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer.
12 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 cgd * notice, this list of conditions and the following disclaimer in the
14 1.1 cgd * documentation and/or other materials provided with the distribution.
15 1.1 cgd * 3. All advertising materials mentioning features or use of this software
16 1.1 cgd * must display the following acknowledgement:
17 1.1 cgd * This product includes software developed by the University of
18 1.1 cgd * California, Berkeley and its contributors.
19 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
20 1.1 cgd * may be used to endorse or promote products derived from this software
21 1.1 cgd * without specific prior written permission.
22 1.1 cgd *
23 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 cgd * SUCH DAMAGE.
34 1.1 cgd *
35 1.30 perry * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
36 1.1 cgd */
37 1.1 cgd
38 1.1 cgd #ifndef _STDLIB_H_
39 1.1 cgd #define _STDLIB_H_
40 1.6 jtc
41 1.37 mycroft #include <sys/cdefs.h>
42 1.32 kleink #include <sys/featuretest.h>
43 1.32 kleink
44 1.62 bjh21 #if defined(_NETBSD_SOURCE)
45 1.32 kleink #include <sys/types.h> /* for quad_t, etc. */
46 1.23 jtc #endif
47 1.23 jtc
48 1.30 perry #include <machine/ansi.h>
49 1.30 perry
50 1.16 cgd #ifdef _BSD_SIZE_T_
51 1.16 cgd typedef _BSD_SIZE_T_ size_t;
52 1.16 cgd #undef _BSD_SIZE_T_
53 1.6 jtc #endif
54 1.1 cgd
55 1.16 cgd #ifdef _BSD_WCHAR_T_
56 1.16 cgd typedef _BSD_WCHAR_T_ wchar_t;
57 1.16 cgd #undef _BSD_WCHAR_T_
58 1.1 cgd #endif
59 1.1 cgd
60 1.1 cgd typedef struct {
61 1.1 cgd int quot; /* quotient */
62 1.1 cgd int rem; /* remainder */
63 1.1 cgd } div_t;
64 1.23 jtc
65 1.1 cgd typedef struct {
66 1.1 cgd long quot; /* quotient */
67 1.1 cgd long rem; /* remainder */
68 1.1 cgd } ldiv_t;
69 1.10 jtc
70 1.45 kleink #if !defined(_ANSI_SOURCE) && \
71 1.62 bjh21 (defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \
72 1.62 bjh21 defined(_NETBSD_SOURCE))
73 1.45 kleink typedef struct {
74 1.45 kleink /* LONGLONG */
75 1.45 kleink long long int quot; /* quotient */
76 1.45 kleink /* LONGLONG */
77 1.45 kleink long long int rem; /* remainder */
78 1.45 kleink } lldiv_t;
79 1.45 kleink #endif
80 1.45 kleink
81 1.62 bjh21 #if defined(_NETBSD_SOURCE)
82 1.23 jtc typedef struct {
83 1.23 jtc quad_t quot; /* quotient */
84 1.23 jtc quad_t rem; /* remainder */
85 1.23 jtc } qdiv_t;
86 1.23 jtc #endif
87 1.23 jtc
88 1.23 jtc
89 1.44 kleink #include <sys/null.h>
90 1.1 cgd
91 1.1 cgd #define EXIT_FAILURE 1
92 1.1 cgd #define EXIT_SUCCESS 0
93 1.1 cgd
94 1.1 cgd #define RAND_MAX 0x7fffffff
95 1.1 cgd
96 1.47 kleink extern size_t __mb_cur_max;
97 1.30 perry #define MB_CUR_MAX __mb_cur_max
98 1.1 cgd
99 1.1 cgd __BEGIN_DECLS
100 1.58 bjh21 __dead void _Exit __P((int)) __attribute__((__noreturn__));
101 1.41 mycroft __dead void abort __P((void)) __attribute__((__noreturn__));
102 1.40 mycroft __pure int abs __P((int));
103 1.1 cgd int atexit __P((void (*)(void)));
104 1.1 cgd double atof __P((const char *));
105 1.1 cgd int atoi __P((const char *));
106 1.1 cgd long atol __P((const char *));
107 1.51 christos #ifndef __BSEARCH_DECLARED
108 1.51 christos #define __BSEARCH_DECLARED
109 1.51 christos /* also in search.h */
110 1.51 christos void *bsearch __P((const void *, const void *, size_t, size_t,
111 1.51 christos int (*)(const void *, const void *)));
112 1.51 christos #endif /* __BSEARCH_DECLARED */
113 1.1 cgd void *calloc __P((size_t, size_t));
114 1.1 cgd div_t div __P((int, int));
115 1.41 mycroft __dead void exit __P((int)) __attribute__((__noreturn__));
116 1.1 cgd void free __P((void *));
117 1.35 mycroft __aconst char *getenv __P((const char *));
118 1.30 perry __pure long
119 1.30 perry labs __P((long));
120 1.1 cgd ldiv_t ldiv __P((long, long));
121 1.1 cgd void *malloc __P((size_t));
122 1.1 cgd void qsort __P((void *, size_t, size_t,
123 1.1 cgd int (*)(const void *, const void *)));
124 1.1 cgd int rand __P((void));
125 1.1 cgd void *realloc __P((void *, size_t));
126 1.1 cgd void srand __P((unsigned));
127 1.54 kleink double strtod __P((const char * __restrict, char ** __restrict));
128 1.54 kleink long strtol __P((const char * __restrict, char ** __restrict, int));
129 1.1 cgd unsigned long
130 1.54 kleink strtoul __P((const char * __restrict, char ** __restrict, int));
131 1.1 cgd int system __P((const char *));
132 1.1 cgd
133 1.30 perry /* These are currently just stubs. */
134 1.1 cgd int mblen __P((const char *, size_t));
135 1.54 kleink size_t mbstowcs __P((wchar_t * __restrict, const char * __restrict, size_t));
136 1.1 cgd int wctomb __P((char *, wchar_t));
137 1.54 kleink int mbtowc __P((wchar_t * __restrict, const char * __restrict, size_t));
138 1.54 kleink size_t wcstombs __P((char * __restrict, const wchar_t * __restrict, size_t));
139 1.5 brezak
140 1.62 bjh21 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
141 1.62 bjh21 defined(_NETBSD_SOURCE)
142 1.32 kleink
143 1.32 kleink
144 1.33 kleink /*
145 1.33 kleink * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2
146 1.33 kleink */
147 1.62 bjh21 #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
148 1.62 bjh21 defined(_REENTRANT) || defined(_NETBSD_SOURCE)
149 1.33 kleink int rand_r __P((unsigned int *));
150 1.33 kleink #endif
151 1.32 kleink
152 1.32 kleink
153 1.33 kleink /*
154 1.33 kleink * X/Open Portability Guide >= Issue 4
155 1.33 kleink */
156 1.62 bjh21 #if (_XOPEN_SOURCE - 0) >= 4 || defined(_NETBSD_SOURCE)
157 1.32 kleink double drand48 __P((void));
158 1.32 kleink double erand48 __P((unsigned short[3]));
159 1.32 kleink long jrand48 __P((unsigned short[3]));
160 1.32 kleink void lcong48 __P((unsigned short[7]));
161 1.32 kleink long lrand48 __P((void));
162 1.32 kleink long mrand48 __P((void));
163 1.32 kleink long nrand48 __P((unsigned short[3]));
164 1.32 kleink unsigned short *
165 1.32 kleink seed48 __P((unsigned short[3]));
166 1.32 kleink void srand48 __P((long));
167 1.32 kleink
168 1.33 kleink int putenv __P((const char *));
169 1.33 kleink #endif
170 1.33 kleink
171 1.33 kleink
172 1.33 kleink /*
173 1.33 kleink * X/Open Portability Guide >= Issue 4 Version 2
174 1.33 kleink */
175 1.62 bjh21 #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
176 1.62 bjh21 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
177 1.33 kleink long a64l __P((const char *));
178 1.33 kleink char *l64a __P((long));
179 1.33 kleink
180 1.33 kleink char *initstate __P((unsigned long, char *, size_t));
181 1.33 kleink long random __P((void));
182 1.33 kleink char *setstate __P((char *));
183 1.33 kleink void srandom __P((unsigned long));
184 1.33 kleink
185 1.39 mycroft char *mkdtemp __P((char *));
186 1.33 kleink int mkstemp __P((char *));
187 1.36 mycroft #ifndef __AUDIT__
188 1.33 kleink char *mktemp __P((char *));
189 1.36 mycroft #endif
190 1.33 kleink
191 1.33 kleink int setkey __P((const char *));
192 1.33 kleink
193 1.33 kleink char *realpath __P((const char *, char *));
194 1.33 kleink
195 1.33 kleink int ttyslot __P((void));
196 1.33 kleink
197 1.33 kleink void *valloc __P((size_t)); /* obsoleted by malloc() */
198 1.33 kleink #endif
199 1.33 kleink
200 1.45 kleink /*
201 1.45 kleink * ISO C99
202 1.45 kleink */
203 1.62 bjh21 #if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \
204 1.62 bjh21 defined(_NETBSD_SOURCE)
205 1.45 kleink /* LONGLONG */
206 1.45 kleink long long int atoll __P((const char *));
207 1.45 kleink /* LONGLONG */
208 1.45 kleink long long int llabs __P((long long int));
209 1.45 kleink /* LONGLONG */
210 1.45 kleink lldiv_t lldiv __P((long long int, long long int));
211 1.45 kleink /* LONGLONG */
212 1.54 kleink long long int strtoll __P((const char * __restrict, char ** __restrict, int));
213 1.45 kleink /* LONGLONG */
214 1.54 kleink unsigned long long int
215 1.54 kleink strtoull __P((const char * __restrict, char ** __restrict,
216 1.54 kleink int));
217 1.45 kleink #endif
218 1.33 kleink
219 1.33 kleink /*
220 1.61 kleink * The Open Group Base Specifications, Issue 6; IEEE Std 1003.1-2001 (POSIX)
221 1.59 kleink */
222 1.62 bjh21 #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 || \
223 1.62 bjh21 defined(_NETBSD_SOURCE)
224 1.59 kleink int setenv __P((const char *, const char *, int));
225 1.59 kleink #ifdef __LIBC12_SOURCE__
226 1.59 kleink void unsetenv __P((const char *));
227 1.59 kleink int __unsetenv13 __P((const char *));
228 1.59 kleink #else
229 1.59 kleink int unsetenv __P((const char *)) __RENAME(__unsetenv13);
230 1.59 kleink #endif
231 1.59 kleink #endif
232 1.59 kleink
233 1.59 kleink /*
234 1.33 kleink * Implementation-defined extensions
235 1.33 kleink */
236 1.62 bjh21 #if defined(_NETBSD_SOURCE)
237 1.3 brezak #if defined(alloca) && (alloca == __builtin_alloca) && (__GNUC__ < 2)
238 1.27 mikel void *alloca __P((int)); /* built-in for gcc */
239 1.2 cgd #else
240 1.27 mikel void *alloca __P((size_t));
241 1.2 cgd #endif /* __GNUC__ */
242 1.11 cgd
243 1.56 itojun u_int32_t arc4random __P((void));
244 1.56 itojun void arc4random_stir __P((void));
245 1.56 itojun void arc4random_addrandom __P((u_char *, int));
246 1.13 cgd char *getbsize __P((int *, long *));
247 1.34 mycroft char *cgetcap __P((char *, const char *, int));
248 1.11 cgd int cgetclose __P((void));
249 1.34 mycroft int cgetent __P((char **, char **, const char *));
250 1.11 cgd int cgetfirst __P((char **, char **));
251 1.34 mycroft int cgetmatch __P((const char *, const char *));
252 1.11 cgd int cgetnext __P((char **, char **));
253 1.34 mycroft int cgetnum __P((char *, const char *, long *));
254 1.34 mycroft int cgetset __P((const char *));
255 1.34 mycroft int cgetstr __P((char *, const char *, char **));
256 1.34 mycroft int cgetustr __P((char *, const char *, char **));
257 1.18 deraadt
258 1.18 deraadt int daemon __P((int, int));
259 1.35 mycroft __aconst char *devname __P((dev_t, mode_t));
260 1.18 deraadt int getloadavg __P((double [], int));
261 1.8 jtc
262 1.7 jtc void cfree __P((void *));
263 1.7 jtc
264 1.1 cgd int heapsort __P((void *, size_t, size_t,
265 1.1 cgd int (*)(const void *, const void *)));
266 1.17 mycroft int mergesort __P((void *, size_t, size_t,
267 1.17 mycroft int (*)(const void *, const void *)));
268 1.17 mycroft int radixsort __P((const unsigned char **, int, const unsigned char *,
269 1.17 mycroft unsigned));
270 1.17 mycroft int sradixsort __P((const unsigned char **, int, const unsigned char *,
271 1.17 mycroft unsigned));
272 1.7 jtc
273 1.48 sommerfe void setproctitle __P((const char *, ...))
274 1.48 sommerfe __attribute__((__format__(__printf__, 1, 2)));
275 1.52 cgd const char *getprogname __P((void)) __attribute__((__const__));
276 1.52 cgd void setprogname __P((const char *));
277 1.19 jtc
278 1.24 jtc quad_t qabs __P((quad_t));
279 1.54 kleink quad_t strtoq __P((const char * __restrict, char ** __restrict, int));
280 1.54 kleink u_quad_t strtouq __P((const char * __restrict, char ** __restrict, int));
281 1.57 lukem
282 1.57 lukem /* LONGLONG */
283 1.57 lukem long long strsuftoll(const char *, const char *, long long, long long);
284 1.57 lukem /* LONGLONG */
285 1.57 lukem long long strsuftollx(const char *, const char *, long long, long long,
286 1.57 lukem char *, size_t);
287 1.42 kleink
288 1.42 kleink int l64a_r __P((long, char *, int));
289 1.53 cgd
290 1.53 cgd size_t shquote __P((const char *arg, char *buf, size_t bufsize));
291 1.53 cgd size_t shquotev __P((int argc, char * const * argv, char *buf,
292 1.53 cgd size_t bufsize));
293 1.62 bjh21 #endif /* _NETBSD_SOURCE */
294 1.62 bjh21 #endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */
295 1.55 kleink
296 1.62 bjh21 #if defined(_NETBSD_SOURCE)
297 1.55 kleink qdiv_t qdiv __P((quad_t, quad_t));
298 1.55 kleink #endif
299 1.1 cgd __END_DECLS
300 1.1 cgd
301 1.27 mikel #endif /* !_STDLIB_H_ */
302