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