stdlib.h revision 15483
11539Srgrimes/*-
21539Srgrimes * Copyright (c) 1990, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes *
51539Srgrimes * Redistribution and use in source and binary forms, with or without
61539Srgrimes * modification, are permitted provided that the following conditions
71539Srgrimes * are met:
81539Srgrimes * 1. Redistributions of source code must retain the above copyright
91539Srgrimes *    notice, this list of conditions and the following disclaimer.
101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111539Srgrimes *    notice, this list of conditions and the following disclaimer in the
121539Srgrimes *    documentation and/or other materials provided with the distribution.
131539Srgrimes * 3. All advertising materials mentioning features or use of this software
141539Srgrimes *    must display the following acknowledgement:
151539Srgrimes *	This product includes software developed by the University of
161539Srgrimes *	California, Berkeley and its contributors.
171539Srgrimes * 4. Neither the name of the University nor the names of its contributors
181539Srgrimes *    may be used to endorse or promote products derived from this software
191539Srgrimes *    without specific prior written permission.
201539Srgrimes *
211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311539Srgrimes * SUCH DAMAGE.
321539Srgrimes *
331539Srgrimes *	@(#)stdlib.h	8.3 (Berkeley) 2/16/94
341539Srgrimes */
351539Srgrimes
361539Srgrimes#ifndef _STDLIB_H_
377865Sbde#define	_STDLIB_H_
381539Srgrimes
391539Srgrimes#include <machine/ansi.h>
401539Srgrimes
4115483Sbde#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
4215483Sbde#ifdef	_BSD_RUNE_T_
4315483Sbdetypedef	_BSD_RUNE_T_	rune_t;
4415483Sbde#undef	_BSD_RUNE_T_
4515483Sbde#endif
4615483Sbde#endif
4715483Sbde
481539Srgrimes#ifdef	_BSD_SIZE_T_
491539Srgrimestypedef	_BSD_SIZE_T_	size_t;
501539Srgrimes#undef	_BSD_SIZE_T_
511539Srgrimes#endif
521539Srgrimes
531539Srgrimes#ifdef	_BSD_WCHAR_T_
541539Srgrimestypedef	_BSD_WCHAR_T_	wchar_t;
551539Srgrimes#undef	_BSD_WCHAR_T_
561539Srgrimes#endif
571539Srgrimes
581539Srgrimestypedef struct {
591539Srgrimes	int quot;		/* quotient */
601539Srgrimes	int rem;		/* remainder */
611539Srgrimes} div_t;
621539Srgrimes
631539Srgrimestypedef struct {
641539Srgrimes	long quot;		/* quotient */
651539Srgrimes	long rem;		/* remainder */
661539Srgrimes} ldiv_t;
671539Srgrimes
681539Srgrimes#ifndef NULL
691539Srgrimes#define	NULL	0
701539Srgrimes#endif
711539Srgrimes
721539Srgrimes#define	EXIT_FAILURE	1
731539Srgrimes#define	EXIT_SUCCESS	0
741539Srgrimes
751539Srgrimes#define	RAND_MAX	0x7fffffff
761539Srgrimes
771539Srgrimesextern int __mb_cur_max;
781539Srgrimes#define	MB_CUR_MAX	__mb_cur_max
791539Srgrimes
801539Srgrimes#include <sys/cdefs.h>
811539Srgrimes
821539Srgrimes__BEGIN_DECLS
831539Srgrimes__dead void
842572Sbde	 abort __P((void)) __dead2;
851539Srgrimes__pure int
867865Sbde	 abs __P((int)) __pure2;
871539Srgrimesint	 atexit __P((void (*)(void)));
881539Srgrimesdouble	 atof __P((const char *));
891539Srgrimesint	 atoi __P((const char *));
901539Srgrimeslong	 atol __P((const char *));
911539Srgrimesvoid	*bsearch __P((const void *, const void *, size_t,
921539Srgrimes	    size_t, int (*)(const void *, const void *)));
931539Srgrimesvoid	*calloc __P((size_t, size_t));
941539Srgrimes__pure div_t
957865Sbde	 div __P((int, int)) __pure2;
961539Srgrimes__dead void
972572Sbde	 exit __P((int)) __dead2;
981539Srgrimesvoid	 free __P((void *));
991539Srgrimeschar	*getenv __P((const char *));
1001539Srgrimes__pure long
1017865Sbde	 labs __P((long)) __pure2;
1021539Srgrimes__pure ldiv_t
1037865Sbde	 ldiv __P((long, long)) __pure2;
1041539Srgrimesvoid	*malloc __P((size_t));
1051539Srgrimesvoid	 qsort __P((void *, size_t, size_t,
1061539Srgrimes	    int (*)(const void *, const void *)));
1071539Srgrimesint	 rand __P((void));
1081539Srgrimesvoid	*realloc __P((void *, size_t));
1091539Srgrimesvoid	 srand __P((unsigned));
1101539Srgrimesdouble	 strtod __P((const char *, char **));
1111539Srgrimeslong	 strtol __P((const char *, char **, int));
1121539Srgrimesunsigned long
1131539Srgrimes	 strtoul __P((const char *, char **, int));
1141539Srgrimesint	 system __P((const char *));
1151539Srgrimes
1161539Srgrimesint	 mblen __P((const char *, size_t));
1171539Srgrimessize_t	 mbstowcs __P((wchar_t *, const char *, size_t));
1181539Srgrimesint	 wctomb __P((char *, wchar_t));
1191539Srgrimesint	 mbtowc __P((wchar_t *, const char *, size_t));
1201539Srgrimessize_t	 wcstombs __P((char *, const wchar_t *, size_t));
1211539Srgrimes
1227865Sbde#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
1231539Srgrimesint	 putenv __P((const char *));
1241539Srgrimesint	 setenv __P((const char *, const char *, int));
1251539Srgrimes
1267865Sbdedouble	 drand48 __P((void));
1277865Sbdedouble	 erand48 __P((unsigned short[3]));
1287865Sbdelong	 jrand48 __P((unsigned short[3]));
1297865Sbdevoid	 lcong48 __P((unsigned short[7]));
1307865Sbdelong	 lrand48 __P((void));
1317865Sbdelong	 mrand48 __P((void));
1327865Sbdelong	 nrand48 __P((unsigned short[3]));
1337865Sbdeunsigned short
1347865Sbde	*seed48 __P((unsigned short[3]));
1357865Sbdevoid	 srand48 __P((long));
1364749Sats
1371539Srgrimesvoid	*alloca __P((size_t));		/* built-in for gcc */
1381539Srgrimes					/* getcap(3) functions */
1391539Srgrimeschar	*getbsize __P((int *, long *));
1401539Srgrimeschar	*cgetcap __P((char *, char *, int));
1411539Srgrimesint	 cgetclose __P((void));
1421539Srgrimesint	 cgetent __P((char **, char **, char *));
1431539Srgrimesint	 cgetfirst __P((char **, char **));
1441539Srgrimesint	 cgetmatch __P((char *, char *));
1451539Srgrimesint	 cgetnext __P((char **, char **));
1461539Srgrimesint	 cgetnum __P((char *, char *, long *));
1471539Srgrimesint	 cgetset __P((char *));
1481539Srgrimesint	 cgetstr __P((char *, char *, char **));
1491539Srgrimesint	 cgetustr __P((char *, char *, char **));
1501539Srgrimes
1511539Srgrimesint	 daemon __P((int, int));
1521539Srgrimeschar	*devname __P((int, int));
1531539Srgrimesint	 getloadavg __P((double [], int));
1541539Srgrimes
1551539Srgrimesextern char *optarg;			/* getopt(3) external variables */
1561539Srgrimesextern int opterr, optind, optopt;
1571539Srgrimesint	 getopt __P((int, char * const *, const char *));
1581539Srgrimes
1591539Srgrimesextern char *suboptarg;			/* getsubopt(3) external variable */
1601539Srgrimesint	 getsubopt __P((char **, char * const *, char **));
1611539Srgrimes
1621539Srgrimeschar	*group_from_gid __P((unsigned long, int));
1631539Srgrimesint	 heapsort __P((void *, size_t, size_t,
1641539Srgrimes	    int (*)(const void *, const void *)));
1651539Srgrimeschar	*initstate __P((unsigned, char *, int));
1661539Srgrimesint	 mergesort __P((void *, size_t, size_t,
1671539Srgrimes	    int (*)(const void *, const void *)));
1681539Srgrimesint	 radixsort __P((const unsigned char **, int, const unsigned char *,
1691539Srgrimes	    unsigned));
1701539Srgrimesint	 sradixsort __P((const unsigned char **, int, const unsigned char *,
1711539Srgrimes	    unsigned));
1721539Srgrimeslong	 random __P((void));
1731539Srgrimeschar	*realpath __P((const char *, char resolved_path[]));
1741539Srgrimeschar	*setstate __P((char *));
1751539Srgrimesvoid	 srandom __P((unsigned));
1761539Srgrimeschar	*user_from_uid __P((unsigned long, int));
1771539Srgrimes#ifndef __STRICT_ANSI__
1781539Srgrimeslong long
1791539Srgrimes	 strtoq __P((const char *, char **, int));
1801539Srgrimesunsigned long long
1811539Srgrimes	 strtouq __P((const char *, char **, int));
1821539Srgrimes#endif
1831539Srgrimesvoid	 unsetenv __P((const char *));
1847865Sbde#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
1851539Srgrimes__END_DECLS
1861539Srgrimes
1877865Sbde#endif /* !_STDLIB_H_ */
188