stdlib.h revision 7865
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
411539Srgrimes#ifdef	_BSD_SIZE_T_
421539Srgrimestypedef	_BSD_SIZE_T_	size_t;
431539Srgrimes#undef	_BSD_SIZE_T_
441539Srgrimes#endif
451539Srgrimes
461539Srgrimes#ifdef	_BSD_WCHAR_T_
477865Sbde#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
481539Srgrimestypedef	_BSD_WCHAR_T_	rune_t;
491539Srgrimes#endif
501539Srgrimestypedef	_BSD_WCHAR_T_	wchar_t;
511539Srgrimes#undef	_BSD_WCHAR_T_
521539Srgrimes#endif
531539Srgrimes
541539Srgrimestypedef struct {
551539Srgrimes	int quot;		/* quotient */
561539Srgrimes	int rem;		/* remainder */
571539Srgrimes} div_t;
581539Srgrimes
591539Srgrimestypedef struct {
601539Srgrimes	long quot;		/* quotient */
611539Srgrimes	long rem;		/* remainder */
621539Srgrimes} ldiv_t;
631539Srgrimes
641539Srgrimes#ifndef NULL
651539Srgrimes#define	NULL	0
661539Srgrimes#endif
671539Srgrimes
681539Srgrimes#define	EXIT_FAILURE	1
691539Srgrimes#define	EXIT_SUCCESS	0
701539Srgrimes
711539Srgrimes#define	RAND_MAX	0x7fffffff
721539Srgrimes
731539Srgrimesextern int __mb_cur_max;
741539Srgrimes#define	MB_CUR_MAX	__mb_cur_max
751539Srgrimes
761539Srgrimes#include <sys/cdefs.h>
771539Srgrimes
781539Srgrimes__BEGIN_DECLS
791539Srgrimes__dead void
802572Sbde	 abort __P((void)) __dead2;
811539Srgrimes__pure int
827865Sbde	 abs __P((int)) __pure2;
831539Srgrimesint	 atexit __P((void (*)(void)));
841539Srgrimesdouble	 atof __P((const char *));
851539Srgrimesint	 atoi __P((const char *));
861539Srgrimeslong	 atol __P((const char *));
871539Srgrimesvoid	*bsearch __P((const void *, const void *, size_t,
881539Srgrimes	    size_t, int (*)(const void *, const void *)));
891539Srgrimesvoid	*calloc __P((size_t, size_t));
901539Srgrimes__pure div_t
917865Sbde	 div __P((int, int)) __pure2;
921539Srgrimes__dead void
932572Sbde	 exit __P((int)) __dead2;
941539Srgrimesvoid	 free __P((void *));
951539Srgrimeschar	*getenv __P((const char *));
961539Srgrimes__pure long
977865Sbde	 labs __P((long)) __pure2;
981539Srgrimes__pure ldiv_t
997865Sbde	 ldiv __P((long, long)) __pure2;
1001539Srgrimesvoid	*malloc __P((size_t));
1011539Srgrimesvoid	 qsort __P((void *, size_t, size_t,
1021539Srgrimes	    int (*)(const void *, const void *)));
1031539Srgrimesint	 rand __P((void));
1041539Srgrimesvoid	*realloc __P((void *, size_t));
1051539Srgrimesvoid	 srand __P((unsigned));
1061539Srgrimesdouble	 strtod __P((const char *, char **));
1071539Srgrimeslong	 strtol __P((const char *, char **, int));
1081539Srgrimesunsigned long
1091539Srgrimes	 strtoul __P((const char *, char **, int));
1101539Srgrimesint	 system __P((const char *));
1111539Srgrimes
1121539Srgrimesint	 mblen __P((const char *, size_t));
1131539Srgrimessize_t	 mbstowcs __P((wchar_t *, const char *, size_t));
1141539Srgrimesint	 wctomb __P((char *, wchar_t));
1151539Srgrimesint	 mbtowc __P((wchar_t *, const char *, size_t));
1161539Srgrimessize_t	 wcstombs __P((char *, const wchar_t *, size_t));
1171539Srgrimes
1187865Sbde#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
1191539Srgrimesint	 putenv __P((const char *));
1201539Srgrimesint	 setenv __P((const char *, const char *, int));
1211539Srgrimes
1227865Sbdedouble	 drand48 __P((void));
1237865Sbdedouble	 erand48 __P((unsigned short[3]));
1247865Sbdelong	 jrand48 __P((unsigned short[3]));
1257865Sbdevoid	 lcong48 __P((unsigned short[7]));
1267865Sbdelong	 lrand48 __P((void));
1277865Sbdelong	 mrand48 __P((void));
1287865Sbdelong	 nrand48 __P((unsigned short[3]));
1297865Sbdeunsigned short
1307865Sbde	*seed48 __P((unsigned short[3]));
1317865Sbdevoid	 srand48 __P((long));
1324749Sats
1331539Srgrimesvoid	*alloca __P((size_t));		/* built-in for gcc */
1341539Srgrimes					/* getcap(3) functions */
1351539Srgrimeschar	*getbsize __P((int *, long *));
1361539Srgrimeschar	*cgetcap __P((char *, char *, int));
1371539Srgrimesint	 cgetclose __P((void));
1381539Srgrimesint	 cgetent __P((char **, char **, char *));
1391539Srgrimesint	 cgetfirst __P((char **, char **));
1401539Srgrimesint	 cgetmatch __P((char *, char *));
1411539Srgrimesint	 cgetnext __P((char **, char **));
1421539Srgrimesint	 cgetnum __P((char *, char *, long *));
1431539Srgrimesint	 cgetset __P((char *));
1441539Srgrimesint	 cgetstr __P((char *, char *, char **));
1451539Srgrimesint	 cgetustr __P((char *, char *, char **));
1461539Srgrimes
1471539Srgrimesint	 daemon __P((int, int));
1481539Srgrimeschar	*devname __P((int, int));
1491539Srgrimesint	 getloadavg __P((double [], int));
1501539Srgrimes
1511539Srgrimesextern char *optarg;			/* getopt(3) external variables */
1521539Srgrimesextern int opterr, optind, optopt;
1531539Srgrimesint	 getopt __P((int, char * const *, const char *));
1541539Srgrimes
1551539Srgrimesextern char *suboptarg;			/* getsubopt(3) external variable */
1561539Srgrimesint	 getsubopt __P((char **, char * const *, char **));
1571539Srgrimes
1581539Srgrimeschar	*group_from_gid __P((unsigned long, int));
1591539Srgrimesint	 heapsort __P((void *, size_t, size_t,
1601539Srgrimes	    int (*)(const void *, const void *)));
1611539Srgrimeschar	*initstate __P((unsigned, char *, int));
1621539Srgrimesint	 mergesort __P((void *, size_t, size_t,
1631539Srgrimes	    int (*)(const void *, const void *)));
1641539Srgrimesint	 radixsort __P((const unsigned char **, int, const unsigned char *,
1651539Srgrimes	    unsigned));
1661539Srgrimesint	 sradixsort __P((const unsigned char **, int, const unsigned char *,
1671539Srgrimes	    unsigned));
1681539Srgrimeslong	 random __P((void));
1691539Srgrimeschar	*realpath __P((const char *, char resolved_path[]));
1701539Srgrimeschar	*setstate __P((char *));
1711539Srgrimesvoid	 srandom __P((unsigned));
1721539Srgrimeschar	*user_from_uid __P((unsigned long, int));
1731539Srgrimes#ifndef __STRICT_ANSI__
1741539Srgrimeslong long
1751539Srgrimes	 strtoq __P((const char *, char **, int));
1761539Srgrimesunsigned long long
1771539Srgrimes	 strtouq __P((const char *, char **, int));
1781539Srgrimes#endif
1791539Srgrimesvoid	 unsetenv __P((const char *));
1807865Sbde#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
1811539Srgrimes__END_DECLS
1821539Srgrimes
1837865Sbde#endif /* !_STDLIB_H_ */
184