xref: /freebsd/include/stdlib.h (revision 8252a465b9bb7c2df6954163de046ceb4ac383dd)
159deaec5SRodney W. Grimes /*-
259deaec5SRodney W. Grimes  * Copyright (c) 1990, 1993
359deaec5SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
459deaec5SRodney W. Grimes  *
559deaec5SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
659deaec5SRodney W. Grimes  * modification, are permitted provided that the following conditions
759deaec5SRodney W. Grimes  * are met:
859deaec5SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
959deaec5SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
1059deaec5SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
1159deaec5SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
1259deaec5SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
1359deaec5SRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
1459deaec5SRodney W. Grimes  *    must display the following acknowledgement:
1559deaec5SRodney W. Grimes  *	This product includes software developed by the University of
1659deaec5SRodney W. Grimes  *	California, Berkeley and its contributors.
1759deaec5SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
1859deaec5SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
1959deaec5SRodney W. Grimes  *    without specific prior written permission.
2059deaec5SRodney W. Grimes  *
2159deaec5SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2259deaec5SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2359deaec5SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2459deaec5SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2559deaec5SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2659deaec5SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2759deaec5SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2859deaec5SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2959deaec5SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3059deaec5SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3159deaec5SRodney W. Grimes  * SUCH DAMAGE.
3259deaec5SRodney W. Grimes  *
33c59376afSPeter Wemm  *	@(#)stdlib.h	8.5 (Berkeley) 5/19/95
3459deaec5SRodney W. Grimes  */
3559deaec5SRodney W. Grimes 
3659deaec5SRodney W. Grimes #ifndef _STDLIB_H_
3759deaec5SRodney W. Grimes #define	_STDLIB_H_
3859deaec5SRodney W. Grimes 
3985b46962SBruce Evans #include <sys/cdefs.h>
4085b46962SBruce Evans 
4159deaec5SRodney W. Grimes #include <machine/ansi.h>
4259deaec5SRodney W. Grimes 
43cdd84b02SBruce Evans #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
44cdd84b02SBruce Evans #ifdef	_BSD_RUNE_T_
45cdd84b02SBruce Evans typedef	_BSD_RUNE_T_	rune_t;
46cdd84b02SBruce Evans #undef	_BSD_RUNE_T_
47cdd84b02SBruce Evans #endif
48cdd84b02SBruce Evans #endif
49cdd84b02SBruce Evans 
5059deaec5SRodney W. Grimes #ifdef	_BSD_SIZE_T_
5159deaec5SRodney W. Grimes typedef	_BSD_SIZE_T_	size_t;
5259deaec5SRodney W. Grimes #undef	_BSD_SIZE_T_
5359deaec5SRodney W. Grimes #endif
5459deaec5SRodney W. Grimes 
5559deaec5SRodney W. Grimes #ifdef	_BSD_WCHAR_T_
5659deaec5SRodney W. Grimes typedef	_BSD_WCHAR_T_	wchar_t;
5759deaec5SRodney W. Grimes #undef	_BSD_WCHAR_T_
5859deaec5SRodney W. Grimes #endif
5959deaec5SRodney W. Grimes 
6059deaec5SRodney W. Grimes typedef struct {
6159deaec5SRodney W. Grimes 	int quot;		/* quotient */
6259deaec5SRodney W. Grimes 	int rem;		/* remainder */
6359deaec5SRodney W. Grimes } div_t;
6459deaec5SRodney W. Grimes 
6559deaec5SRodney W. Grimes typedef struct {
6659deaec5SRodney W. Grimes 	long quot;		/* quotient */
6759deaec5SRodney W. Grimes 	long rem;		/* remainder */
6859deaec5SRodney W. Grimes } ldiv_t;
6959deaec5SRodney W. Grimes 
7059deaec5SRodney W. Grimes #ifndef NULL
7159deaec5SRodney W. Grimes #define	NULL	0
7259deaec5SRodney W. Grimes #endif
7359deaec5SRodney W. Grimes 
7459deaec5SRodney W. Grimes #define	EXIT_FAILURE	1
7559deaec5SRodney W. Grimes #define	EXIT_SUCCESS	0
7659deaec5SRodney W. Grimes 
7759deaec5SRodney W. Grimes #define	RAND_MAX	0x7fffffff
7859deaec5SRodney W. Grimes 
7959deaec5SRodney W. Grimes extern int __mb_cur_max;
8059deaec5SRodney W. Grimes #define	MB_CUR_MAX	__mb_cur_max
8159deaec5SRodney W. Grimes 
8259deaec5SRodney W. Grimes __BEGIN_DECLS
83eaa86f9dSBruce Evans void	 abort __P((void)) __dead2;
84eaa86f9dSBruce Evans int	 abs __P((int)) __pure2;
8559deaec5SRodney W. Grimes int	 atexit __P((void (*)(void)));
8659deaec5SRodney W. Grimes double	 atof __P((const char *));
8759deaec5SRodney W. Grimes int	 atoi __P((const char *));
8859deaec5SRodney W. Grimes long	 atol __P((const char *));
8959deaec5SRodney W. Grimes void	*bsearch __P((const void *, const void *, size_t,
9059deaec5SRodney W. Grimes 	    size_t, int (*)(const void *, const void *)));
9159deaec5SRodney W. Grimes void	*calloc __P((size_t, size_t));
92eaa86f9dSBruce Evans div_t	 div __P((int, int)) __pure2;
93eaa86f9dSBruce Evans void	 exit __P((int)) __dead2;
9459deaec5SRodney W. Grimes void	 free __P((void *));
9559deaec5SRodney W. Grimes char	*getenv __P((const char *));
96eaa86f9dSBruce Evans long	 labs __P((long)) __pure2;
97eaa86f9dSBruce Evans ldiv_t	 ldiv __P((long, long)) __pure2;
9859deaec5SRodney W. Grimes void	*malloc __P((size_t));
9959deaec5SRodney W. Grimes void	 qsort __P((void *, size_t, size_t,
10059deaec5SRodney W. Grimes 	    int (*)(const void *, const void *)));
10159deaec5SRodney W. Grimes int	 rand __P((void));
10259deaec5SRodney W. Grimes void	*realloc __P((void *, size_t));
10359deaec5SRodney W. Grimes void	 srand __P((unsigned));
10459deaec5SRodney W. Grimes double	 strtod __P((const char *, char **));
10559deaec5SRodney W. Grimes long	 strtol __P((const char *, char **, int));
10659deaec5SRodney W. Grimes unsigned long
10759deaec5SRodney W. Grimes 	 strtoul __P((const char *, char **, int));
10859deaec5SRodney W. Grimes int	 system __P((const char *));
10959deaec5SRodney W. Grimes 
11059deaec5SRodney W. Grimes int	 mblen __P((const char *, size_t));
11159deaec5SRodney W. Grimes size_t	 mbstowcs __P((wchar_t *, const char *, size_t));
11259deaec5SRodney W. Grimes int	 wctomb __P((char *, wchar_t));
11359deaec5SRodney W. Grimes int	 mbtowc __P((wchar_t *, const char *, size_t));
11459deaec5SRodney W. Grimes size_t	 wcstombs __P((char *, const wchar_t *, size_t));
11559deaec5SRodney W. Grimes 
11667c54240SBruce Evans #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
11759deaec5SRodney W. Grimes int	 putenv __P((const char *));
11859deaec5SRodney W. Grimes int	 setenv __P((const char *, const char *, int));
11959deaec5SRodney W. Grimes 
120f8f6d0dcSAndreas Schulz double	 drand48 __P((void));
121f8f6d0dcSAndreas Schulz double	 erand48 __P((unsigned short[3]));
122f8f6d0dcSAndreas Schulz long	 jrand48 __P((unsigned short[3]));
123f8f6d0dcSAndreas Schulz void	 lcong48 __P((unsigned short[7]));
12467c54240SBruce Evans long	 lrand48 __P((void));
12567c54240SBruce Evans long	 mrand48 __P((void));
12667c54240SBruce Evans long	 nrand48 __P((unsigned short[3]));
12767c54240SBruce Evans unsigned short
12867c54240SBruce Evans 	*seed48 __P((unsigned short[3]));
12967c54240SBruce Evans void	 srand48 __P((long));
130f8f6d0dcSAndreas Schulz 
13159deaec5SRodney W. Grimes void	*alloca __P((size_t));		/* built-in for gcc */
13259deaec5SRodney W. Grimes 					/* getcap(3) functions */
1338252a465SDmitrij Tejblum __uint32_t
134b24d5f1dSAndrey A. Chernov 	 arc4random __P((void));
135b24d5f1dSAndrey A. Chernov void	 arc4random_addrandom __P((unsigned char *dat, int datlen));
136439c8bdaSAndrey A. Chernov void	 arc4random_stir __P((void));
13759deaec5SRodney W. Grimes char	*getbsize __P((int *, long *));
13859deaec5SRodney W. Grimes char	*cgetcap __P((char *, char *, int));
13959deaec5SRodney W. Grimes int	 cgetclose __P((void));
14059deaec5SRodney W. Grimes int	 cgetent __P((char **, char **, char *));
14159deaec5SRodney W. Grimes int	 cgetfirst __P((char **, char **));
14259deaec5SRodney W. Grimes int	 cgetmatch __P((char *, char *));
14359deaec5SRodney W. Grimes int	 cgetnext __P((char **, char **));
14459deaec5SRodney W. Grimes int	 cgetnum __P((char *, char *, long *));
14559deaec5SRodney W. Grimes int	 cgetset __P((char *));
14659deaec5SRodney W. Grimes int	 cgetstr __P((char *, char *, char **));
14759deaec5SRodney W. Grimes int	 cgetustr __P((char *, char *, char **));
14859deaec5SRodney W. Grimes 
14959deaec5SRodney W. Grimes int	 daemon __P((int, int));
15059deaec5SRodney W. Grimes char	*devname __P((int, int));
15159deaec5SRodney W. Grimes int	 getloadavg __P((double [], int));
15259deaec5SRodney W. Grimes 
15359deaec5SRodney W. Grimes char	*group_from_gid __P((unsigned long, int));
15459deaec5SRodney W. Grimes int	 heapsort __P((void *, size_t, size_t,
15559deaec5SRodney W. Grimes 	    int (*)(const void *, const void *)));
156c59376afSPeter Wemm char	*initstate __P((unsigned long, char *, long));
15759deaec5SRodney W. Grimes int	 mergesort __P((void *, size_t, size_t,
15859deaec5SRodney W. Grimes 	    int (*)(const void *, const void *)));
15959deaec5SRodney W. Grimes int	 radixsort __P((const unsigned char **, int, const unsigned char *,
16059deaec5SRodney W. Grimes 	    unsigned));
16159deaec5SRodney W. Grimes int	 sradixsort __P((const unsigned char **, int, const unsigned char *,
16259deaec5SRodney W. Grimes 	    unsigned));
16359deaec5SRodney W. Grimes long	 random __P((void));
16494ad719cSWarner Losh void    *reallocf __P((void *, size_t));
16559deaec5SRodney W. Grimes char	*realpath __P((const char *, char resolved_path[]));
16659deaec5SRodney W. Grimes char	*setstate __P((char *));
167c59376afSPeter Wemm void	 srandom __P((unsigned long));
16896c31b26SAndrey A. Chernov void	 srandomdev __P((void));
16959deaec5SRodney W. Grimes char	*user_from_uid __P((unsigned long, int));
17059deaec5SRodney W. Grimes #ifndef __STRICT_ANSI__
1718252a465SDmitrij Tejblum __int64_t	 strtoq __P((const char *, char **, int));
1728252a465SDmitrij Tejblum __uint64_t
17359deaec5SRodney W. Grimes 	 strtouq __P((const char *, char **, int));
17459deaec5SRodney W. Grimes #endif
17559deaec5SRodney W. Grimes void	 unsetenv __P((const char *));
17667c54240SBruce Evans #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
17759deaec5SRodney W. Grimes __END_DECLS
17859deaec5SRodney W. Grimes 
17967c54240SBruce Evans #endif /* !_STDLIB_H_ */
180