stdlib.h revision 15483
1/*-
2 * Copyright (c) 1990, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 *    must display the following acknowledgement:
15 *	This product includes software developed by the University of
16 *	California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 *    may be used to endorse or promote products derived from this software
19 *    without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 *	@(#)stdlib.h	8.3 (Berkeley) 2/16/94
34 */
35
36#ifndef _STDLIB_H_
37#define	_STDLIB_H_
38
39#include <machine/ansi.h>
40
41#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
42#ifdef	_BSD_RUNE_T_
43typedef	_BSD_RUNE_T_	rune_t;
44#undef	_BSD_RUNE_T_
45#endif
46#endif
47
48#ifdef	_BSD_SIZE_T_
49typedef	_BSD_SIZE_T_	size_t;
50#undef	_BSD_SIZE_T_
51#endif
52
53#ifdef	_BSD_WCHAR_T_
54typedef	_BSD_WCHAR_T_	wchar_t;
55#undef	_BSD_WCHAR_T_
56#endif
57
58typedef struct {
59	int quot;		/* quotient */
60	int rem;		/* remainder */
61} div_t;
62
63typedef struct {
64	long quot;		/* quotient */
65	long rem;		/* remainder */
66} ldiv_t;
67
68#ifndef NULL
69#define	NULL	0
70#endif
71
72#define	EXIT_FAILURE	1
73#define	EXIT_SUCCESS	0
74
75#define	RAND_MAX	0x7fffffff
76
77extern int __mb_cur_max;
78#define	MB_CUR_MAX	__mb_cur_max
79
80#include <sys/cdefs.h>
81
82__BEGIN_DECLS
83__dead void
84	 abort __P((void)) __dead2;
85__pure int
86	 abs __P((int)) __pure2;
87int	 atexit __P((void (*)(void)));
88double	 atof __P((const char *));
89int	 atoi __P((const char *));
90long	 atol __P((const char *));
91void	*bsearch __P((const void *, const void *, size_t,
92	    size_t, int (*)(const void *, const void *)));
93void	*calloc __P((size_t, size_t));
94__pure div_t
95	 div __P((int, int)) __pure2;
96__dead void
97	 exit __P((int)) __dead2;
98void	 free __P((void *));
99char	*getenv __P((const char *));
100__pure long
101	 labs __P((long)) __pure2;
102__pure ldiv_t
103	 ldiv __P((long, long)) __pure2;
104void	*malloc __P((size_t));
105void	 qsort __P((void *, size_t, size_t,
106	    int (*)(const void *, const void *)));
107int	 rand __P((void));
108void	*realloc __P((void *, size_t));
109void	 srand __P((unsigned));
110double	 strtod __P((const char *, char **));
111long	 strtol __P((const char *, char **, int));
112unsigned long
113	 strtoul __P((const char *, char **, int));
114int	 system __P((const char *));
115
116int	 mblen __P((const char *, size_t));
117size_t	 mbstowcs __P((wchar_t *, const char *, size_t));
118int	 wctomb __P((char *, wchar_t));
119int	 mbtowc __P((wchar_t *, const char *, size_t));
120size_t	 wcstombs __P((char *, const wchar_t *, size_t));
121
122#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
123int	 putenv __P((const char *));
124int	 setenv __P((const char *, const char *, int));
125
126double	 drand48 __P((void));
127double	 erand48 __P((unsigned short[3]));
128long	 jrand48 __P((unsigned short[3]));
129void	 lcong48 __P((unsigned short[7]));
130long	 lrand48 __P((void));
131long	 mrand48 __P((void));
132long	 nrand48 __P((unsigned short[3]));
133unsigned short
134	*seed48 __P((unsigned short[3]));
135void	 srand48 __P((long));
136
137void	*alloca __P((size_t));		/* built-in for gcc */
138					/* getcap(3) functions */
139char	*getbsize __P((int *, long *));
140char	*cgetcap __P((char *, char *, int));
141int	 cgetclose __P((void));
142int	 cgetent __P((char **, char **, char *));
143int	 cgetfirst __P((char **, char **));
144int	 cgetmatch __P((char *, char *));
145int	 cgetnext __P((char **, char **));
146int	 cgetnum __P((char *, char *, long *));
147int	 cgetset __P((char *));
148int	 cgetstr __P((char *, char *, char **));
149int	 cgetustr __P((char *, char *, char **));
150
151int	 daemon __P((int, int));
152char	*devname __P((int, int));
153int	 getloadavg __P((double [], int));
154
155extern char *optarg;			/* getopt(3) external variables */
156extern int opterr, optind, optopt;
157int	 getopt __P((int, char * const *, const char *));
158
159extern char *suboptarg;			/* getsubopt(3) external variable */
160int	 getsubopt __P((char **, char * const *, char **));
161
162char	*group_from_gid __P((unsigned long, int));
163int	 heapsort __P((void *, size_t, size_t,
164	    int (*)(const void *, const void *)));
165char	*initstate __P((unsigned, char *, int));
166int	 mergesort __P((void *, size_t, size_t,
167	    int (*)(const void *, const void *)));
168int	 radixsort __P((const unsigned char **, int, const unsigned char *,
169	    unsigned));
170int	 sradixsort __P((const unsigned char **, int, const unsigned char *,
171	    unsigned));
172long	 random __P((void));
173char	*realpath __P((const char *, char resolved_path[]));
174char	*setstate __P((char *));
175void	 srandom __P((unsigned));
176char	*user_from_uid __P((unsigned long, int));
177#ifndef __STRICT_ANSI__
178long long
179	 strtoq __P((const char *, char **, int));
180unsigned long long
181	 strtouq __P((const char *, char **, int));
182#endif
183void	 unsetenv __P((const char *));
184#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
185__END_DECLS
186
187#endif /* !_STDLIB_H_ */
188