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