stdlib.h revision 1.22 1 /* $NetBSD: stdlib.h,v 1.22 1994/12/17 04:19:06 jtc Exp $ */
2
3 /*-
4 * Copyright (c) 1990 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)stdlib.h 5.13 (Berkeley) 6/4/91
36 */
37
38 #ifndef _STDLIB_H_
39 #define _STDLIB_H_
40 #include <machine/ansi.h>
41
42 #ifdef _BSD_SIZE_T_
43 typedef _BSD_SIZE_T_ size_t;
44 #undef _BSD_SIZE_T_
45 #endif
46
47 #ifdef _BSD_WCHAR_T_
48 typedef _BSD_WCHAR_T_ wchar_t;
49 #undef _BSD_WCHAR_T_
50 #endif
51
52 typedef struct {
53 int quot; /* quotient */
54 int rem; /* remainder */
55 } div_t;
56 typedef struct {
57 long quot; /* quotient */
58 long rem; /* remainder */
59 } ldiv_t;
60
61 #ifndef NULL
62 #define NULL 0
63 #endif
64
65 #define EXIT_FAILURE 1
66 #define EXIT_SUCCESS 0
67
68 #define RAND_MAX 0x7fffffff
69
70 #define MB_CUR_MAX 1 /* XXX */
71
72 #include <sys/cdefs.h>
73
74 __BEGIN_DECLS
75 void abort __P((void));
76 int abs __P((int));
77 int atexit __P((void (*)(void)));
78 double atof __P((const char *));
79 int atoi __P((const char *));
80 long atol __P((const char *));
81 void *bsearch __P((const void *, const void *, size_t,
82 size_t, int (*)(const void *, const void *)));
83 void *calloc __P((size_t, size_t));
84 div_t div __P((int, int));
85 void exit __P((int));
86 void free __P((void *));
87 char *getenv __P((const char *));
88 long labs __P((long));
89 ldiv_t ldiv __P((long, long));
90 void *malloc __P((size_t));
91 void qsort __P((void *, size_t, size_t,
92 int (*)(const void *, const void *)));
93 int rand __P((void));
94 void *realloc __P((void *, size_t));
95 void srand __P((unsigned));
96 double strtod __P((const char *, char **));
97 long strtol __P((const char *, char **, int));
98 unsigned long
99 strtoul __P((const char *, char **, int));
100 int system __P((const char *));
101
102 /* these are currently just stubs */
103 int mblen __P((const char *, size_t));
104 size_t mbstowcs __P((wchar_t *, const char *, size_t));
105 int wctomb __P((char *, wchar_t));
106 int mbtowc __P((wchar_t *, const char *, size_t));
107 size_t wcstombs __P((char *, const wchar_t *, size_t));
108
109 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
110 #include <sys/types.h>
111
112 #if defined(alloca) && (alloca == __builtin_alloca) && (__GNUC__ < 2)
113 void *alloca __P((int)); /* built-in for gcc */
114 #else
115 void *alloca __P((size_t));
116 #endif /* __GNUC__ */
117
118 char *getbsize __P((int *, long *));
119 char *cgetcap __P((char *, char *, int));
120 int cgetclose __P((void));
121 int cgetent __P((char **, char **, char *));
122 int cgetfirst __P((char **, char **));
123 int cgetmatch __P((char *, char *));
124 int cgetnext __P((char **, char **));
125 int cgetnum __P((char *, char *, long *));
126 int cgetset __P((char *));
127 int cgetstr __P((char *, char *, char **));
128 int cgetustr __P((char *, char *, char **));
129
130 int daemon __P((int, int));
131 char *devname __P((int, int));
132 int getloadavg __P((double [], int));
133
134 long a64l __P((const char *));
135 char *l64a __P((long));
136
137 void cfree __P((void *));
138
139 int getopt __P((int, char * const *, const char *));
140 extern char *optarg; /* getopt(3) external variables */
141 extern int opterr;
142 extern int optind;
143 extern int optopt;
144 extern int optreset;
145 int getsubopt __P((char **, char * const *, char **));
146 extern char *suboptarg; /* getsubopt(3) external variable */
147
148 int heapsort __P((void *, size_t, size_t,
149 int (*)(const void *, const void *)));
150 int mergesort __P((void *, size_t, size_t,
151 int (*)(const void *, const void *)));
152 int radixsort __P((const unsigned char **, int, const unsigned char *,
153 unsigned));
154 int sradixsort __P((const unsigned char **, int, const unsigned char *,
155 unsigned));
156
157 char *initstate __P((unsigned, char *, int));
158 long random __P((void));
159 char *realpath __P((const char *, char *));
160 char *setstate __P((char *));
161 void srandom __P((unsigned));
162
163 int putenv __P((const char *));
164 int setenv __P((const char *, const char *, int));
165 void unsetenv __P((const char *));
166 void setproctitle __P((const char *, ...));
167
168 quad_t strtoq __P((const char *, char **, int));
169 u_quad_t strtouq __P((const char *, char **, int));
170
171 double drand48 __P((void));
172 double erand48 __P((unsigned short[3]));
173 long jrand48 __P((unsigned short[3]));
174 void lcong48 __P((unsigned short[7]));
175 long lrand48 __P((void));
176 long mrand48 __P((void));
177 long nrand48 __P((unsigned short[3]));
178 unsigned short *seed48 __P((unsigned short[3]));
179 void srand48 __P((long));
180 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
181
182 __END_DECLS
183
184 #endif /* _STDLIB_H_ */
185