stdlib.h revision 93032
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 *
3323657Speter *	@(#)stdlib.h	8.5 (Berkeley) 5/19/95
3455031Sbde * $FreeBSD: head/include/stdlib.h 93032 2002-03-23 17:24:55Z imp $
351539Srgrimes */
361539Srgrimes
371539Srgrimes#ifndef _STDLIB_H_
387865Sbde#define	_STDLIB_H_
391539Srgrimes
4033861Sbde#include <sys/cdefs.h>
4133861Sbde
421539Srgrimes#include <machine/ansi.h>
4326636Sache
4426636Sache#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
4515483Sbde#ifdef	_BSD_RUNE_T_
4615483Sbdetypedef	_BSD_RUNE_T_	rune_t;
4715483Sbde#undef	_BSD_RUNE_T_
4815483Sbde#endif
4915483Sbde#endif
5015483Sbde
511539Srgrimes#ifdef	_BSD_SIZE_T_
521539Srgrimestypedef	_BSD_SIZE_T_	size_t;
531539Srgrimes#undef	_BSD_SIZE_T_
541539Srgrimes#endif
551539Srgrimes
561539Srgrimes#ifdef	_BSD_WCHAR_T_
571539Srgrimestypedef	_BSD_WCHAR_T_	wchar_t;
581539Srgrimes#undef	_BSD_WCHAR_T_
591539Srgrimes#endif
601539Srgrimes
611539Srgrimestypedef struct {
621539Srgrimes	int quot;		/* quotient */
631539Srgrimes	int rem;		/* remainder */
641539Srgrimes} div_t;
651539Srgrimes
661539Srgrimestypedef struct {
671539Srgrimes	long quot;		/* quotient */
681539Srgrimes	long rem;		/* remainder */
691539Srgrimes} ldiv_t;
701539Srgrimes
7187071Sbde#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
7286368Smike#ifdef __LONG_LONG_SUPPORTED
7386368Smiketypedef struct {
7486368Smike	long long quot;
7586368Smike	long long rem;
7686368Smike} lldiv_t;
7786368Smike#endif
7887071Sbde#endif
7986368Smike
801539Srgrimes#ifndef NULL
811539Srgrimes#define	NULL	0
821539Srgrimes#endif
831539Srgrimes
841539Srgrimes#define	EXIT_FAILURE	1
851539Srgrimes#define	EXIT_SUCCESS	0
861539Srgrimes
871539Srgrimes#define	RAND_MAX	0x7fffffff
881539Srgrimes
891539Srgrimesextern int __mb_cur_max;
901539Srgrimes#define	MB_CUR_MAX	__mb_cur_max
911539Srgrimes
921539Srgrimes__BEGIN_DECLS
9393032Simpvoid	 abort(void) __dead2;
9493032Simpint	 abs(int) __pure2;
9593032Simpint	 atexit(void (*)(void));
9693032Simpdouble	 atof(const char *);
9793032Simpint	 atoi(const char *);
9893032Simplong	 atol(const char *);
9993032Simpvoid	*bsearch(const void *, const void *, size_t,
10093032Simp	    size_t, int (*)(const void *, const void *));
10193032Simpvoid	*calloc(size_t, size_t);
10293032Simpdiv_t	 div(int, int) __pure2;
10393032Simpvoid	 exit(int) __dead2;
10493032Simpvoid	 free(void *);
10593032Simpchar	*getenv(const char *);
10693032Simplong	 labs(long) __pure2;
10793032Simpldiv_t	 ldiv(long, long) __pure2;
10893032Simpvoid	*malloc(size_t);
10993032Simpvoid	 qsort(void *, size_t, size_t,
11093032Simp	    int (*)(const void *, const void *));
11193032Simpint	 rand(void);
11293032Simpvoid	*realloc(void *, size_t);
11393032Simpvoid	 srand(unsigned);
11493032Simpdouble	 strtod(const char *, char **);
11593032Simplong	 strtol(const char *, char **, int);
1161539Srgrimesunsigned long
11793032Simp	 strtoul(const char *, char **, int);
11893032Simpint	 system(const char *);
1191539Srgrimes
12093032Simpint	 mblen(const char *, size_t);
12193032Simpsize_t	 mbstowcs(wchar_t *, const char *, size_t);
12293032Simpint	 wctomb(char *, wchar_t);
12393032Simpint	 mbtowc(wchar_t *, const char *, size_t);
12493032Simpsize_t	 wcstombs(char *, const wchar_t *, size_t);
1251539Srgrimes
1267865Sbde#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
12769201Sphkextern char *_malloc_options;
12893032Simpextern void (*_malloc_message)(char *p1, char *p2, char *p3, char *p4);
12969201Sphk
13093032Simpint	 putenv(const char *);
13193032Simpint	 setenv(const char *, const char *, int);
1321539Srgrimes
13393032Simpdouble	 drand48(void);
13493032Simpdouble	 erand48(unsigned short[3]);
13593032Simplong	 jrand48(unsigned short[3]);
13693032Simpvoid	 lcong48(unsigned short[7]);
13793032Simplong	 lrand48(void);
13893032Simplong	 mrand48(void);
13993032Simplong	 nrand48(unsigned short[3]);
1407865Sbdeunsigned short
14193032Simp	*seed48(unsigned short[3]);
14293032Simpvoid	 srand48(long);
1434749Sats
14493032Simpvoid	*alloca(size_t);		/* built-in for gcc */
1451539Srgrimes					/* getcap(3) functions */
14641927Sdt__uint32_t
14793032Simp	 arc4random(void);
14893032Simpvoid	 arc4random_addrandom(unsigned char *dat, int datlen);
14993032Simpvoid	 arc4random_stir(void);
15087086Sbde#ifdef __LONG_LONG_SUPPORTED
15187086Sbdelong long
15293032Simp	 atoll(const char *);
15387086Sbde#endif
15493032Simpchar	*getbsize(int *, long *);
15593032Simpchar	*cgetcap(char *, const char *, int);
15693032Simpint	 cgetclose(void);
15793032Simpint	 cgetent(char **, char **, const char *);
15893032Simpint	 cgetfirst(char **, char **);
15993032Simpint	 cgetmatch(const char *, const char *);
16093032Simpint	 cgetnext(char **, char **);
16193032Simpint	 cgetnum(char *, const char *, long *);
16293032Simpint	 cgetset(const char *);
16393032Simpint	 cgetstr(char *, const char *, char **);
16493032Simpint	 cgetustr(char *, const char *, char **);
1651539Srgrimes
16693032Simpint	 daemon(int, int);
16793032Simpchar	*devname(int, int);
16893032Simpint	 getloadavg(double [], int);
16988399Smike__const char *
17093032Simp	 getprogname(void);
1711539Srgrimes
17293032Simpint	 heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
17393032Simpchar	*initstate(unsigned long, char *, long);
17487071Sbde#ifdef __LONG_LONG_SUPPORTED
17587071Sbdelong long
17693032Simp	 llabs(long long) __pure2;
17793032Simplldiv_t	 lldiv(long long, long long) __pure2;
17887071Sbde#endif
17993032Simpint	 mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
18093032Simpint	 radixsort(const unsigned char **, int, const unsigned char *,
18193032Simp	    unsigned);
18293032Simpint	 sradixsort(const unsigned char **, int, const unsigned char *,
18393032Simp	    unsigned);
18493032Simpint	 rand_r(unsigned *);
18593032Simplong	 random(void);
18693032Simpvoid    *reallocf(void *, size_t);
18793032Simpchar	*realpath(const char *, char resolved_path[]);
18893032Simpvoid	 setprogname(const char *);
18993032Simpchar	*setstate(char *);
19093032Simpvoid	 sranddev(void);
19193032Simpvoid	 srandom(unsigned long);
19293032Simpvoid	 srandomdev(void);
19387071Sbde#ifdef __LONG_LONG_SUPPORTED
19487071Sbdelong long
19593032Simp	 strtoll(const char *, char **, int);
19687071Sbde#endif
19793032Simp__int64_t	 strtoq(const char *, char **, int);
19887071Sbde#ifdef __LONG_LONG_SUPPORTED
19987071Sbdeunsigned long long
20093032Simp	 strtoull(const char *, char **, int);
20187071Sbde#endif
20241927Sdt__uint64_t
20393032Simp	 strtouq(const char *, char **, int);
20493032Simpvoid	 unsetenv(const char *);
2057865Sbde#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
2061539Srgrimes__END_DECLS
2071539Srgrimes
2087865Sbde#endif /* !_STDLIB_H_ */
209