stdlib.h revision 99404
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 99404 2002-07-04 11:07:48Z markm $
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#ifdef	_BSD_WCHAR_T_
57typedef	_BSD_WCHAR_T_	wchar_t;
58#undef	_BSD_WCHAR_T_
59#endif
60
61typedef struct {
62	int quot;		/* quotient */
63	int rem;		/* remainder */
64} div_t;
65
66typedef struct {
67	long quot;		/* quotient */
68	long rem;		/* remainder */
69} ldiv_t;
70
71#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
72#ifdef __LONG_LONG_SUPPORTED
73/* LONGLONG */
74typedef struct {
75	long long quot;
76	long long rem;
77} lldiv_t;
78#endif
79#endif
80
81#ifndef NULL
82#define	NULL	0
83#endif
84
85#define	EXIT_FAILURE	1
86#define	EXIT_SUCCESS	0
87
88#define	RAND_MAX	0x7fffffff
89
90extern int __mb_cur_max;
91#define	MB_CUR_MAX	__mb_cur_max
92
93__BEGIN_DECLS
94void	 abort(void) __dead2;
95int	 abs(int) __pure2;
96int	 atexit(void (*)(void));
97double	 atof(const char *);
98int	 atoi(const char *);
99long	 atol(const char *);
100void	*bsearch(const void *, const void *, size_t,
101	    size_t, int (*)(const void *, const void *));
102void	*calloc(size_t, size_t);
103div_t	 div(int, int) __pure2;
104void	 exit(int) __dead2;
105void	 free(void *);
106char	*getenv(const char *);
107long	 labs(long) __pure2;
108ldiv_t	 ldiv(long, long) __pure2;
109void	*malloc(size_t);
110void	 qsort(void *, size_t, size_t,
111	    int (*)(const void *, const void *));
112int	 rand(void);
113void	*realloc(void *, size_t);
114void	 srand(unsigned);
115double	 strtod(const char *, char **);
116long	 strtol(const char *, char **, int);
117unsigned long
118	 strtoul(const char *, char **, int);
119int	 system(const char *);
120
121int	 mblen(const char *, size_t);
122size_t	 mbstowcs(wchar_t *, const char *, size_t);
123int	 wctomb(char *, wchar_t);
124int	 mbtowc(wchar_t *, const char *, size_t);
125size_t	 wcstombs(char *, const wchar_t *, size_t);
126
127#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
128extern const char *_malloc_options;
129extern void (*_malloc_message)(const char *p1, const char *p2, const char *p3, const char *p4);
130
131int	 putenv(const char *);
132int	 setenv(const char *, const char *, int);
133
134double	 drand48(void);
135double	 erand48(unsigned short[3]);
136long	 jrand48(unsigned short[3]);
137void	 lcong48(unsigned short[7]);
138long	 lrand48(void);
139long	 mrand48(void);
140long	 nrand48(unsigned short[3]);
141unsigned short
142	*seed48(unsigned short[3]);
143void	 srand48(long);
144
145void	*alloca(size_t);		/* built-in for gcc */
146					/* getcap(3) functions */
147__uint32_t
148	 arc4random(void);
149void	 arc4random_addrandom(unsigned char *dat, int datlen);
150void	 arc4random_stir(void);
151#ifdef __LONG_LONG_SUPPORTED
152/* LONGLONG */
153long long
154	 atoll(const char *);
155#endif
156char	*getbsize(int *, long *);
157char	*cgetcap(char *, const char *, int);
158int	 cgetclose(void);
159int	 cgetent(char **, char **, const char *);
160int	 cgetfirst(char **, char **);
161int	 cgetmatch(const char *, const char *);
162int	 cgetnext(char **, char **);
163int	 cgetnum(char *, const char *, long *);
164int	 cgetset(const char *);
165int	 cgetstr(char *, const char *, char **);
166int	 cgetustr(char *, const char *, char **);
167
168int	 daemon(int, int);
169char	*devname(int, int);
170int	 getloadavg(double [], int);
171__const char *
172	 getprogname(void);
173
174int	 heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
175char	*initstate(unsigned long, char *, long);
176#ifdef __LONG_LONG_SUPPORTED
177/* LONGLONG */
178long long
179	 llabs(long long) __pure2;
180lldiv_t	 lldiv(long long, long long) __pure2;
181#endif
182int	 mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
183int	 radixsort(const unsigned char **, int, const unsigned char *,
184	    unsigned);
185int	 sradixsort(const unsigned char **, int, const unsigned char *,
186	    unsigned);
187int	 rand_r(unsigned *);
188long	 random(void);
189void    *reallocf(void *, size_t);
190char	*realpath(const char *, char resolved_path[]);
191void	 setprogname(const char *);
192char	*setstate(char *);
193void	 sranddev(void);
194void	 srandom(unsigned long);
195void	 srandomdev(void);
196#ifdef __LONG_LONG_SUPPORTED
197/* LONGLONG */
198long long
199	 strtoll(const char *, char **, int);
200#endif
201__int64_t	 strtoq(const char *, char **, int);
202#ifdef __LONG_LONG_SUPPORTED
203/* LONGLONG */
204unsigned long long
205	 strtoull(const char *, char **, int);
206#endif
207__uint64_t
208	 strtouq(const char *, char **, int);
209void	 unsetenv(const char *);
210#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
211__END_DECLS
212
213#endif /* !_STDLIB_H_ */
214