Initial import from FreeBSD RELENG_4:
[dragonfly.git] / include / stdlib.h
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.5 (Berkeley) 5/19/95
34  * $FreeBSD: src/include/stdlib.h,v 1.16.2.5 2002/12/13 01:34:00 tjr Exp $
35  */
36
37 #ifndef _STDLIB_H_
38 #define _STDLIB_H_
39
40 #include <sys/cdefs.h>
41
42 #include <machine/ansi.h>
43
44 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
45 #ifdef  _BSD_RUNE_T_
46 typedef _BSD_RUNE_T_    rune_t;
47 #undef  _BSD_RUNE_T_
48 #endif
49 #endif
50
51 #ifdef  _BSD_SIZE_T_
52 typedef _BSD_SIZE_T_    size_t;
53 #undef  _BSD_SIZE_T_
54 #endif
55
56 #ifndef __cplusplus
57 #ifdef  _BSD_WCHAR_T_
58 typedef _BSD_WCHAR_T_   wchar_t;
59 #undef  _BSD_WCHAR_T_
60 #endif
61 #endif
62
63 typedef struct {
64         int quot;               /* quotient */
65         int rem;                /* remainder */
66 } div_t;
67
68 typedef struct {
69         long quot;              /* quotient */
70         long rem;               /* remainder */
71 } ldiv_t;
72
73 #ifndef NULL
74 #define NULL    0
75 #endif
76
77 #define EXIT_FAILURE    1
78 #define EXIT_SUCCESS    0
79
80 #define RAND_MAX        0x7fffffff
81
82 extern int __mb_cur_max;
83 #define MB_CUR_MAX      __mb_cur_max
84
85 __BEGIN_DECLS
86 void     abort __P((void)) __dead2;
87 int      abs __P((int)) __pure2;
88 int      atexit __P((void (*)(void)));
89 double   atof __P((const char *));
90 int      atoi __P((const char *));
91 long     atol __P((const char *));
92 void    *bsearch __P((const void *, const void *, size_t,
93             size_t, int (*)(const void *, const void *)));
94 void    *calloc __P((size_t, size_t));
95 div_t    div __P((int, int)) __pure2;
96 void     exit __P((int)) __dead2;
97 void     free __P((void *));
98 char    *getenv __P((const char *));
99 long     labs __P((long)) __pure2;
100 ldiv_t   ldiv __P((long, long)) __pure2;
101 void    *malloc __P((size_t));
102 void     qsort __P((void *, size_t, size_t,
103             int (*)(const void *, const void *)));
104 int      rand __P((void));
105 void    *realloc __P((void *, size_t));
106 void     srand __P((unsigned));
107 double   strtod __P((const char *, char **));
108 long     strtol __P((const char *, char **, int));
109 #ifdef __LONG_LONG_SUPPORTED
110 long long        
111          strtoll __P((const char *, char **, int));
112 #endif
113 unsigned long
114          strtoul __P((const char *, char **, int));
115 #ifdef __LONG_LONG_SUPPORTED
116 unsigned long long
117          strtoull __P((const char *, char **, int));
118 #endif
119 int      system __P((const char *));
120
121 int      mblen __P((const char *, size_t));
122 size_t   mbstowcs __P((wchar_t *, const char *, size_t));
123 int      wctomb __P((char *, wchar_t));
124 int      mbtowc __P((wchar_t *, const char *, size_t));
125 size_t   wcstombs __P((char *, const wchar_t *, size_t));
126
127 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
128 int      putenv __P((const char *));
129 int      setenv __P((const char *, const char *, int));
130
131 double   drand48 __P((void));
132 double   erand48 __P((unsigned short[3]));
133 long     jrand48 __P((unsigned short[3]));
134 void     lcong48 __P((unsigned short[7]));
135 long     lrand48 __P((void));
136 long     mrand48 __P((void));
137 long     nrand48 __P((unsigned short[3]));
138 unsigned short
139         *seed48 __P((unsigned short[3]));
140 void     srand48 __P((long));
141
142 void    *alloca __P((size_t));          /* built-in for gcc */
143                                         /* getcap(3) functions */
144 __uint32_t
145          arc4random __P((void));
146 void     arc4random_addrandom __P((unsigned char *dat, int datlen));
147 void     arc4random_stir __P((void));
148 char    *getbsize __P((int *, long *));
149 char    *cgetcap __P((char *, char *, int));
150 int      cgetclose __P((void));
151 int      cgetent __P((char **, char **, char *));
152 int      cgetfirst __P((char **, char **));
153 int      cgetmatch __P((char *, char *));
154 int      cgetnext __P((char **, char **));
155 int      cgetnum __P((char *, char *, long *));
156 int      cgetset __P((char *));
157 int      cgetstr __P((char *, char *, char **));
158 int      cgetustr __P((char *, char *, char **));
159
160 int      daemon __P((int, int));
161 char    *devname __P((int, int));
162 int      getloadavg __P((double [], int));
163 __const char *
164         getprogname __P((void));
165
166 char    *group_from_gid __P((unsigned long, int));
167 int      heapsort __P((void *, size_t, size_t,
168             int (*)(const void *, const void *)));
169 char    *initstate __P((unsigned long, char *, long));
170 int      mergesort __P((void *, size_t, size_t,
171             int (*)(const void *, const void *)));
172 int      radixsort __P((const unsigned char **, int, const unsigned char *,
173             unsigned));
174 int      sradixsort __P((const unsigned char **, int, const unsigned char *,
175             unsigned));
176 int      rand_r __P((unsigned *));
177 long     random __P((void));
178 void    *reallocf __P((void *, size_t));
179 char    *realpath __P((const char *, char resolved_path[]));
180 void     setprogname __P((const char *));
181 char    *setstate __P((char *));
182 void     srandom __P((unsigned long));
183 void     srandomdev __P((void));
184 char    *user_from_uid __P((unsigned long, int));
185 #ifndef __STRICT_ANSI__
186 __int64_t        strtoq __P((const char *, char **, int));
187 __uint64_t
188          strtouq __P((const char *, char **, int));
189 #endif
190 void     unsetenv __P((const char *));
191 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
192 __END_DECLS
193
194 #endif /* !_STDLIB_H_ */