Annotation of src/include/stdlib.h, Revision 1.34
1.34 ! millert 1: /* $OpenBSD: stdlib.h,v 1.33 2005/05/11 18:44:12 espie Exp $ */
1.2 deraadt 2: /* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */
1.1 deraadt 3:
4: /*-
5: * Copyright (c) 1990 The Regents of the University of California.
6: * All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
1.25 millert 16: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 17: * may be used to endorse or promote products derived from this software
18: * without specific prior written permission.
19: *
20: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30: * SUCH DAMAGE.
31: *
32: * @(#)stdlib.h 5.13 (Berkeley) 6/4/91
33: */
34:
35: #ifndef _STDLIB_H_
36: #define _STDLIB_H_
37: #include <machine/ansi.h>
38:
39: #if !defined(_ANSI_SOURCE) /* for quad_t, etc. */
40: #include <sys/types.h>
41: #endif
42:
43: #ifdef _BSD_SIZE_T_
44: typedef _BSD_SIZE_T_ size_t;
45: #undef _BSD_SIZE_T_
46: #endif
47:
48: #ifdef _BSD_WCHAR_T_
1.11 espie 49: /* in C++, wchar_t is a built-in type */
50: #ifndef __cplusplus
1.1 deraadt 51: typedef _BSD_WCHAR_T_ wchar_t;
1.11 espie 52: #endif
1.1 deraadt 53: #undef _BSD_WCHAR_T_
54: #endif
55:
56: typedef struct {
57: int quot; /* quotient */
58: int rem; /* remainder */
59: } div_t;
60:
61: typedef struct {
62: long quot; /* quotient */
63: long rem; /* remainder */
64: } ldiv_t;
65:
66: #if !defined(_ANSI_SOURCE)
67: typedef struct {
68: quad_t quot; /* quotient */
69: quad_t rem; /* remainder */
70: } qdiv_t;
71: #endif
72:
73:
74: #ifndef NULL
1.10 espie 75: #ifdef __GNUG__
76: #define NULL __null
77: #else
1.21 millert 78: #define NULL 0L
1.10 espie 79: #endif
1.1 deraadt 80: #endif
81:
82: #define EXIT_FAILURE 1
83: #define EXIT_SUCCESS 0
84:
85: #define RAND_MAX 0x7fffffff
86:
1.33 espie 87: extern size_t __mb_cur_max;
88: #define MB_CUR_MAX __mb_cur_max
1.1 deraadt 89:
90: #include <sys/cdefs.h>
91:
1.18 millert 92: /*
93: * Some header files may define an abs macro.
94: * If defined, undef it to prevent a syntax error and issue a warning.
95: */
96: #ifdef abs
97: #undef abs
98: #warning abs macro collides with abs() prototype, undefining
99: #endif
100:
1.1 deraadt 101: __BEGIN_DECLS
1.16 millert 102: __dead void abort(void);
103: int abs(int);
1.17 millert 104: int atexit(void (*)(void));
1.16 millert 105: double atof(const char *);
106: int atoi(const char *);
107: long atol(const char *);
1.22 millert 108: long long atoll(const char *);
1.17 millert 109: void *bsearch(const void *, const void *, size_t, size_t,
110: int (*)(const void *, const void *));
1.16 millert 111: void *calloc(size_t, size_t);
112: div_t div(int, int);
1.23 millert 113: char *ecvt(double, int, int *, int *);
1.16 millert 114: __dead void exit(int);
1.30 millert 115: __dead void _Exit(int);
1.23 millert 116: char *fcvt(double, int, int *, int *);
1.16 millert 117: void free(void *);
1.23 millert 118: char *gcvt(double, int, char *);
1.16 millert 119: char *getenv(const char *);
120: long labs(long);
121: ldiv_t ldiv(long, long);
1.29 millert 122: long long
123: llabs(long long);
1.16 millert 124: void *malloc(size_t);
1.34 ! millert 125: char *mkdtemp(char *);
! 126: int mkstemp(char *);
! 127: int mkstemps(char *, int);
! 128: char *mktemp(char *);
1.17 millert 129: void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
1.16 millert 130: int rand(void);
131: int rand_r(unsigned int *);
132: void *realloc(void *, size_t);
133: void srand(unsigned);
134: double strtod(const char *, char **);
135: long strtol(const char *, char **, int);
1.20 millert 136: long long
137: strtoll(const char *, char **, int);
1.32 millert 138: long long
139: strtonum(const char *, long long, long long, const char **);
1.1 deraadt 140: unsigned long
1.16 millert 141: strtoul(const char *, char **, int);
1.20 millert 142: unsigned long long
143: strtoull(const char *, char **, int);
1.16 millert 144: int system(const char *);
1.1 deraadt 145:
146: /* these are currently just stubs */
1.16 millert 147: int mblen(const char *, size_t);
148: size_t mbstowcs(wchar_t *, const char *, size_t);
149: int wctomb(char *, wchar_t);
150: int mbtowc(wchar_t *, const char *, size_t);
151: size_t wcstombs(char *, const wchar_t *, size_t);
1.1 deraadt 152:
153: #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
154: #if defined(alloca) && (alloca == __builtin_alloca) && (__GNUC__ < 2)
1.16 millert 155: void *alloca(int); /* built-in for gcc */
1.1 deraadt 156: #else
1.16 millert 157: void *alloca(size_t);
1.1 deraadt 158: #endif /* __GNUC__ */
159:
1.16 millert 160: char *getbsize(int *, long *);
161: char *cgetcap(char *, const char *, int);
162: int cgetclose(void);
163: int cgetent(char **, char **, const char *);
164: int cgetfirst(char **, char **);
165: int cgetmatch(char *, const char *);
166: int cgetnext(char **, char **);
167: int cgetnum(char *, const char *, long *);
168: int cgetset(const char *);
169: int cgetusedb(int);
170: int cgetstr(char *, const char *, char **);
171: int cgetustr(char *, const char *, char **);
172:
173: int daemon(int, int);
174: char *devname(int, int);
175: int getloadavg(double [], int);
1.1 deraadt 176:
1.16 millert 177: long a64l(const char *);
178: char *l64a(long);
1.1 deraadt 179:
1.16 millert 180: void cfree(void *);
1.1 deraadt 181:
1.24 millert 182: #ifndef _GETOPT_DEFINED_
183: #define _GETOPT_DEFINED_
1.16 millert 184: int getopt(int, char * const *, const char *);
1.1 deraadt 185: extern char *optarg; /* getopt(3) external variables */
186: extern int opterr;
187: extern int optind;
188: extern int optopt;
189: extern int optreset;
1.16 millert 190: int getsubopt(char **, char * const *, char **);
1.1 deraadt 191: extern char *suboptarg; /* getsubopt(3) external variable */
1.24 millert 192: #endif /* _GETOPT_DEFINED_ */
1.1 deraadt 193:
1.17 millert 194: int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
195: int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
196: int radixsort(const unsigned char **, int, const unsigned char *,
197: unsigned);
198: int sradixsort(const unsigned char **, int, const unsigned char *,
199: unsigned);
1.1 deraadt 200:
1.28 avsm 201: char *initstate(unsigned int, char *, size_t)
202: __attribute__((__bounded__ (__string__,2,3)));
1.16 millert 203: long random(void);
204: char *realpath(const char *, char *);
205: char *setstate(const char *);
206: void srandom(unsigned int);
207: void srandomdev(void);
208:
209: int putenv(const char *);
210: int setenv(const char *, const char *, int);
211: void unsetenv(const char *);
212: void setproctitle(const char *, ...)
1.15 krw 213: __attribute__((__format__ (__printf__, 1, 2)));
1.1 deraadt 214:
1.16 millert 215: quad_t qabs(quad_t);
216: qdiv_t qdiv(quad_t, quad_t);
217: quad_t strtoq(const char *, char **, int);
218: u_quad_t strtouq(const char *, char **, int);
219:
220: double drand48(void);
221: double erand48(unsigned short[3]);
222: long jrand48(unsigned short[3]);
223: void lcong48(unsigned short[7]);
224: long lrand48(void);
225: long mrand48(void);
226: long nrand48(unsigned short[3]);
227: unsigned short *seed48(unsigned short[3]);
228: void srand48(long);
229:
230: u_int32_t arc4random(void);
231: void arc4random_stir(void);
1.28 avsm 232: void arc4random_addrandom(unsigned char *, int)
233: __attribute__((__bounded__ (__string__,1,2)));
1.1 deraadt 234: #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
235:
236: __END_DECLS
237:
238: #endif /* _STDLIB_H_ */