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