stdlib.h revision 1.32
1/*	$NetBSD: stdlib.h,v 1.32 1998/05/11 12:00:27 kleink Exp $	*/
2
3/*-
4 * Copyright (c) 1990, 1993
5 *	The Regents of the University of California.  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	8.5 (Berkeley) 5/19/95
36 */
37
38#ifndef _STDLIB_H_
39#define _STDLIB_H_
40
41#include <sys/featuretest.h>
42
43#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
44    !defined(_XOPEN_SOURCE)
45#include <sys/types.h>		/* for quad_t, etc. */
46#endif
47
48#include <machine/ansi.h>
49
50#ifdef	_BSD_SIZE_T_
51typedef	_BSD_SIZE_T_	size_t;
52#undef	_BSD_SIZE_T_
53#endif
54
55#ifdef	_BSD_WCHAR_T_
56typedef	_BSD_WCHAR_T_	wchar_t;
57#undef	_BSD_WCHAR_T_
58#endif
59
60typedef struct {
61	int quot;		/* quotient */
62	int rem;		/* remainder */
63} div_t;
64
65typedef struct {
66	long quot;		/* quotient */
67	long rem;		/* remainder */
68} ldiv_t;
69
70#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) && \
71    !defined(_XOPEN_SOURCE)
72typedef struct {
73	quad_t quot;		/* quotient */
74	quad_t rem;		/* remainder */
75} qdiv_t;
76#endif
77
78
79#ifndef	NULL
80#define	NULL	0
81#endif
82
83#define	EXIT_FAILURE	1
84#define	EXIT_SUCCESS	0
85
86#define	RAND_MAX	0x7fffffff
87
88#if 0	/* no wide char stuff (yet) */
89extern int __mb_cur_max;
90#define	MB_CUR_MAX	__mb_cur_max
91#else
92#define	MB_CUR_MAX	1	/* XXX */
93#endif
94
95#include <sys/cdefs.h>
96
97__BEGIN_DECLS
98__dead void
99	 abort __P((void));
100__pure int
101	 abs __P((int));
102int	 atexit __P((void (*)(void)));
103double	 atof __P((const char *));
104int	 atoi __P((const char *));
105long	 atol __P((const char *));
106void	*bsearch __P((const void *, const void *, size_t,
107	    size_t, int (*)(const void *, const void *)));
108void	*calloc __P((size_t, size_t));
109div_t	 div __P((int, int));
110__dead void
111	 exit __P((int));
112void	 free __P((void *));
113char	*getenv __P((const char *));
114__pure long
115	 labs __P((long));
116ldiv_t	 ldiv __P((long, long));
117void	*malloc __P((size_t));
118void	 qsort __P((void *, size_t, size_t,
119	    int (*)(const void *, const void *)));
120int	 rand __P((void));
121int	 rand_r __P((unsigned int *));
122void	*realloc __P((void *, size_t));
123void	 srand __P((unsigned));
124double	 strtod __P((const char *, char **));
125long	 strtol __P((const char *, char **, int));
126unsigned long
127	 strtoul __P((const char *, char **, int));
128int	 system __P((const char *));
129
130/* These are currently just stubs. */
131int	 mblen __P((const char *, size_t));
132size_t	 mbstowcs __P((wchar_t *, const char *, size_t));
133int	 wctomb __P((char *, wchar_t));
134int	 mbtowc __P((wchar_t *, const char *, size_t));
135size_t	 wcstombs __P((char *, const wchar_t *, size_t));
136
137#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) || \
138    defined(_XOPEN_SOURCE)
139long	 a64l __P((const char *));
140char	*l64a __P((long));
141
142char	*initstate __P((unsigned long, char *, size_t));
143long	 random __P((void));
144char	*setstate __P((char *));
145void	 srandom __P((unsigned long));
146
147char	*realpath __P((const char *, char *));
148
149int	 putenv __P((const char *));
150
151double	 drand48 __P((void));
152double	 erand48 __P((unsigned short[3]));
153long	 jrand48 __P((unsigned short[3]));
154void	 lcong48 __P((unsigned short[7]));
155long	 lrand48 __P((void));
156long	 mrand48 __P((void));
157long	 nrand48 __P((unsigned short[3]));
158unsigned short *
159	 seed48 __P((unsigned short[3]));
160void	 srand48 __P((long));
161#endif /* !_ANSI_SOURCE && !_POSIX_C_SOURCE || _XOPEN_SOURCE */
162
163#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) && \
164    !defined(_XOPEN_SOURCE)
165#if defined(alloca) && (alloca == __builtin_alloca) && (__GNUC__ < 2)
166void	*alloca __P((int));     /* built-in for gcc */
167#else
168void	*alloca __P((size_t));
169#endif /* __GNUC__ */
170
171char	*getbsize __P((int *, long *));
172char	*cgetcap __P((char *, char *, int));
173int	 cgetclose __P((void));
174int	 cgetent __P((char **, char **, char *));
175int	 cgetfirst __P((char **, char **));
176int	 cgetmatch __P((char *, char *));
177int	 cgetnext __P((char **, char **));
178int	 cgetnum __P((char *, char *, long *));
179int	 cgetset __P((char *));
180int	 cgetstr __P((char *, char *, char **));
181int	 cgetustr __P((char *, char *, char **));
182
183int	 daemon __P((int, int));
184char	*devname __P((dev_t, mode_t));
185int	 getloadavg __P((double [], int));
186
187void	 cfree __P((void *));
188
189int	 heapsort __P((void *, size_t, size_t,
190	    int (*)(const void *, const void *)));
191int	 mergesort __P((void *, size_t, size_t,
192	    int (*)(const void *, const void *)));
193int	 radixsort __P((const unsigned char **, int, const unsigned char *,
194	    unsigned));
195int	 sradixsort __P((const unsigned char **, int, const unsigned char *,
196	    unsigned));
197
198int	 setenv __P((const char *, const char *, int));
199void	 unsetenv __P((const char *));
200void	 setproctitle __P((const char *, ...));
201
202quad_t	 qabs __P((quad_t));
203qdiv_t	 qdiv __P((quad_t, quad_t));
204quad_t	 strtoq __P((const char *, char **, int));
205u_quad_t strtouq __P((const char *, char **, int));
206#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE && !_XOPEN_SOURCE */
207__END_DECLS
208
209#endif /* !_STDLIB_H_ */
210