stdlib.h revision 75859
1323124Sdes/*-
260573Skris * Copyright (c) 1990, 1993
392555Sdes *	The Regents of the University of California.  All rights reserved.
460573Skris *
560573Skris * Redistribution and use in source and binary forms, with or without
660573Skris * modification, are permitted provided that the following conditions
760573Skris * are met:
860573Skris * 1. Redistributions of source code must retain the above copyright
960573Skris *    notice, this list of conditions and the following disclaimer.
1060573Skris * 2. Redistributions in binary form must reproduce the above copyright
1160573Skris *    notice, this list of conditions and the following disclaimer in the
1260573Skris *    documentation and/or other materials provided with the distribution.
1360573Skris * 3. All advertising materials mentioning features or use of this software
1460573Skris *    must display the following acknowledgement:
1560573Skris *	This product includes software developed by the University of
1660573Skris *	California, Berkeley and its contributors.
1760573Skris * 4. Neither the name of the University nor the names of its contributors
1860573Skris *    may be used to endorse or promote products derived from this software
1960573Skris *    without specific prior written permission.
2060573Skris *
2160573Skris * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2260573Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2360573Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2460573Skris * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2560573Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2660573Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2760573Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28295367Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29162852Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30162852Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31162852Sdes * SUCH DAMAGE.
32162852Sdes *
33162852Sdes *	@(#)stdlib.h	8.5 (Berkeley) 5/19/95
34162852Sdes * $FreeBSD: head/include/stdlib.h 75859 2001-04-23 09:32:06Z ache $
35162852Sdes */
36295367Sdes
3776259Sgreen#ifndef _STDLIB_H_
38323124Sdes#define	_STDLIB_H_
39295367Sdes
4076259Sgreen#include <sys/cdefs.h>
4160573Skris
4261209Skris#include <machine/ansi.h>
4360573Skris
4476259Sgreen#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
45295367Sdes#ifdef	_BSD_RUNE_T_
4660573Skristypedef	_BSD_RUNE_T_	rune_t;
4776259Sgreen#undef	_BSD_RUNE_T_
4876259Sgreen#endif
4976259Sgreen#endif
50295367Sdes
5176259Sgreen#ifdef	_BSD_SIZE_T_
5298675Sdestypedef	_BSD_SIZE_T_	size_t;
53295367Sdes#undef	_BSD_SIZE_T_
54295367Sdes#endif
55295367Sdes
56262566Sdes#ifdef	_BSD_WCHAR_T_
5760573Skristypedef	_BSD_WCHAR_T_	wchar_t;
58162852Sdes#undef	_BSD_WCHAR_T_
59162852Sdes#endif
60162852Sdes
61162852Sdestypedef struct {
62162852Sdes	int quot;		/* quotient */
63162852Sdes	int rem;		/* remainder */
64162852Sdes} div_t;
65162852Sdes
6692555Sdestypedef struct {
67295367Sdes	long quot;		/* quotient */
68295367Sdes	long rem;		/* remainder */
6976259Sgreen} ldiv_t;
70296781Sdes
71296781Sdes#ifndef NULL
72296781Sdes#define	NULL	0
73296781Sdes#endif
74296781Sdes
75296781Sdes#define	EXIT_FAILURE	1
76296781Sdes#define	EXIT_SUCCESS	0
77296781Sdes
78296781Sdes#define	RAND_MAX	0x7fffffff
79296781Sdes
80296781Sdesextern int __mb_cur_max;
81296781Sdes#define	MB_CUR_MAX	__mb_cur_max
82296781Sdes
83255767Sdes__BEGIN_DECLS
84255767Sdesvoid	 abort __P((void)) __dead2;
85295367Sdesint	 abs __P((int)) __pure2;
86255767Sdesint	 atexit __P((void (*)(void)));
87262566Sdesdouble	 atof __P((const char *));
88255767Sdesint	 atoi __P((const char *));
89255767Sdeslong	 atol __P((const char *));
90295367Sdesvoid	*bsearch __P((const void *, const void *, size_t,
91262566Sdes	    size_t, int (*)(const void *, const void *)));
92323124Sdesvoid	*calloc __P((size_t, size_t));
93323124Sdesdiv_t	 div __P((int, int)) __pure2;
94323124Sdesvoid	 exit __P((int)) __dead2;
95323124Sdesvoid	 free __P((void *));
96262566Sdeschar	*getenv __P((const char *));
97255767Sdeslong	 labs __P((long)) __pure2;
98262566Sdesldiv_t	 ldiv __P((long, long)) __pure2;
99295367Sdesvoid	*malloc __P((size_t));
100255767Sdesvoid	 qsort __P((void *, size_t, size_t,
101262566Sdes	    int (*)(const void *, const void *)));
102262566Sdesint	 rand __P((void));
103262566Sdesvoid	*realloc __P((void *, size_t));
104262566Sdesvoid	 srand __P((unsigned));
105262566Sdesdouble	 strtod __P((const char *, char **));
106262566Sdeslong	 strtol __P((const char *, char **, int));
107262566Sdeslong long
108295367Sdes	 strtoll __P((const char *, char **, int));
109295367Sdesunsigned long
110295367Sdes	 strtoul __P((const char *, char **, int));
111295367Sdesunsigned long long
112262566Sdes	 strtoull __P((const char *, char **, int));
113295367Sdesint	 system __P((const char *));
114262566Sdes
115255767Sdesint	 mblen __P((const char *, size_t));
116255767Sdessize_t	 mbstowcs __P((wchar_t *, const char *, size_t));
117255767Sdesint	 wctomb __P((char *, wchar_t));
118262566Sdesint	 mbtowc __P((wchar_t *, const char *, size_t));
119255767Sdessize_t	 wcstombs __P((char *, const wchar_t *, size_t));
120295367Sdes
121255767Sdes#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
122255767Sdesextern char *_malloc_options;
123255767Sdesextern void (*_malloc_message)__P((char *p1, char *p2, char *p3, char *p4));
124255767Sdes
125255767Sdesint	 putenv __P((const char *));
126262566Sdesint	 setenv __P((const char *, const char *, int));
127255767Sdes
128295367Sdesdouble	 drand48 __P((void));
129295367Sdesdouble	 erand48 __P((unsigned short[3]));
130295367Sdeslong	 jrand48 __P((unsigned short[3]));
131295367Sdesvoid	 lcong48 __P((unsigned short[7]));
132295367Sdeslong	 lrand48 __P((void));
133255767Sdeslong	 mrand48 __P((void));
134255767Sdeslong	 nrand48 __P((unsigned short[3]));
135255767Sdesunsigned short
136255767Sdes	*seed48 __P((unsigned short[3]));
137255767Sdesvoid	 srand48 __P((long));
138255767Sdes
139255767Sdesvoid	*alloca __P((size_t));		/* built-in for gcc */
140255767Sdes					/* getcap(3) functions */
141255767Sdes__uint32_t
142255767Sdes	 arc4random __P((void));
143255767Sdesvoid	 arc4random_addrandom __P((unsigned char *dat, int datlen));
144255767Sdesvoid	 arc4random_stir __P((void));
145255767Sdeschar	*getbsize __P((int *, long *));
146255767Sdeschar	*cgetcap __P((char *, char *, int));
147255767Sdesint	 cgetclose __P((void));
148255767Sdesint	 cgetent __P((char **, char **, char *));
149255767Sdesint	 cgetfirst __P((char **, char **));
150255767Sdesint	 cgetmatch __P((char *, char *));
151221420Sdesint	 cgetnext __P((char **, char **));
152221420Sdesint	 cgetnum __P((char *, char *, long *));
153221420Sdesint	 cgetset __P((char *));
154221420Sdesint	 cgetstr __P((char *, char *, char **));
155221420Sdesint	 cgetustr __P((char *, char *, char **));
156221420Sdes
157221420Sdesint	 daemon __P((int, int));
158221420Sdeschar	*devname __P((int, int));
159295367Sdesint	 getloadavg __P((double [], int));
160295367Sdes
161221420Sdeschar	*group_from_gid __P((unsigned long, int));
162221420Sdesint	 heapsort __P((void *, size_t, size_t,
163255767Sdes	    int (*)(const void *, const void *)));
164221420Sdeschar	*initstate __P((unsigned long, char *, long));
165255767Sdesint	 mergesort __P((void *, size_t, size_t,
166221420Sdes	    int (*)(const void *, const void *)));
167221420Sdesint	 radixsort __P((const unsigned char **, int, const unsigned char *,
168221420Sdes	    unsigned));
169221420Sdesint	 sradixsort __P((const unsigned char **, int, const unsigned char *,
170255767Sdes	    unsigned));
171221420Sdesint	 rand_r __P((unsigned *));
172221420Sdeslong	 random __P((void));
173221420Sdesvoid    *reallocf __P((void *, size_t));
174295367Sdeschar	*realpath __P((const char *, char resolved_path[]));
175295367Sdeschar	*setstate __P((char *));
176295367Sdesvoid	 srandom __P((unsigned long));
177295367Sdesvoid	 sranddev __P((void));
178295367Sdesvoid	 srandomdev __P((void));
179295367Sdeschar	*user_from_uid __P((unsigned long, int));
180295367Sdes#ifndef __STRICT_ANSI__
181295367Sdes__int64_t	 strtoq __P((const char *, char **, int));
182295367Sdes__uint64_t
183295367Sdes	 strtouq __P((const char *, char **, int));
184295367Sdes#endif
185295367Sdesvoid	 unsetenv __P((const char *));
186295367Sdes#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
187295367Sdes__END_DECLS
188295367Sdes
189295367Sdes#endif /* !_STDLIB_H_ */
190295367Sdes