comm: add -Wall
[unleashed.git] / include / stdlib.h
blob0cff437f0dabd55180653bcd02e580cd980830f0
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 * Copyright (c) 2013 Gary Mills
26 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
29 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
31 /* Copyright (c) 1988 AT&T */
32 /* All Rights Reserved */
34 #ifndef _STDLIB_H
35 #define _STDLIB_H
37 #include <iso/stdlib_iso.h>
38 #include <iso/stdlib_c99.h>
39 #include <iso/stdlib_c11.h>
42 * Allow global visibility for symbols defined in
43 * C++ "std" namespace in <iso/stdlib_iso.h>.
45 #if __cplusplus >= 199711L
46 using std::div_t;
47 using std::ldiv_t;
48 using std::size_t;
49 using std::abort;
50 using std::abs;
51 using std::atexit;
52 using std::atof;
53 using std::atoi;
54 using std::atol;
55 using std::bsearch;
56 using std::calloc;
57 using std::div;
58 using std::exit;
59 using std::free;
60 using std::getenv;
61 using std::labs;
62 using std::ldiv;
63 using std::malloc;
64 using std::mblen;
65 using std::mbstowcs;
66 using std::mbtowc;
67 using std::qsort;
68 using std::rand;
69 using std::realloc;
70 using std::srand;
71 using std::strtod;
72 using std::strtol;
73 using std::strtoul;
74 using std::system;
75 using std::wcstombs;
76 using std::wctomb;
77 #endif
80 * Allow global visibility for symbols defined in
81 * C++ "std" namespace in <iso/stdlib_c11.h>.
83 #if __cplusplus >= 201103L
84 using std::at_quick_exit;
85 using std::quick_exit;
86 #endif
87 #if __cplusplus >= 201703L
88 using std::aligned_alloc;
89 #endif
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
95 #ifndef _UID_T
96 #define _UID_T
97 typedef unsigned int uid_t; /* UID type */
98 #endif /* !_UID_T */
100 extern int rand_r(unsigned int *);
102 extern void _exithandle(void);
104 #if defined(__EXTENSIONS__) || \
105 (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
106 defined(_XPG4)
107 extern double drand48(void);
108 extern double erand48(unsigned short *);
109 extern long jrand48(unsigned short *);
110 extern void lcong48(unsigned short *);
111 extern long lrand48(void);
112 extern long mrand48(void);
113 extern long nrand48(unsigned short *);
114 extern unsigned short *seed48(unsigned short *);
115 extern void srand48(long);
116 extern int putenv(char *);
117 extern void setkey(const char *);
118 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
121 * swab() has historically been in <stdlib.h> as delivered from AT&T
122 * and continues to be visible in the default compilation environment.
123 * As of Issue 4 of the X/Open Portability Guides, swab() was declared
124 * in <unistd.h>. As a result, with respect to X/Open namespace the
125 * swab() declaration in this header is only visible for the XPG3
126 * environment.
128 #if (defined(__EXTENSIONS__) || \
129 (!defined(_STRICT_STDC__) && !defined(_POSIX_C_SOURCE))) && \
130 (!defined(_XOPEN_SOURCE) || (defined(_XPG3) && !defined(_XPG4)))
131 #ifndef _SSIZE_T
132 #define _SSIZE_T
133 #if defined(_LP64) || defined(_I32LPx)
134 typedef long ssize_t; /* size of something in bytes or -1 */
135 #else
136 typedef int ssize_t; /* (historical version) */
137 #endif
138 #endif /* !_SSIZE_T */
140 extern void swab(const char *, char *, ssize_t);
141 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
143 #if defined(__EXTENSIONS__) || \
144 !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)
145 extern int mkstemp(char *);
146 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
147 extern int mkstemps(char *, int);
148 #endif
149 #endif /* defined(__EXTENSIONS__) ... */
151 #if !defined(_STRICT_SYMBOLS) || defined(_XPG7)
152 extern char *mkdtemp(char *);
153 #endif /* !defined(_STRICT_SYMBOLS) || defined(_XPG7) */
155 #if !defined(_STRICT_SYMBOLS)
156 extern int mkostemp(char *, int);
157 extern int mkostemps(char *, int, int);
158 #endif /* !defined(_STRICT_SYMBOLS) */
160 #if defined(__EXTENSIONS__) || \
161 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
162 defined(_XPG4_2)
163 extern long a64l(const char *);
164 extern char *ecvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
165 extern char *fcvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
166 extern char *gcvt(double, int, char *);
167 extern int getsubopt(char **, char *const *, char **);
168 extern int grantpt(int);
169 extern char *initstate(unsigned, char *, size_t);
170 extern char *l64a(long);
171 extern char *mktemp(char *);
172 extern char *ptsname(int);
173 extern long random(void);
174 extern char *realpath(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
175 extern char *setstate(const char *);
176 extern void srandom(unsigned);
177 extern int unlockpt(int);
178 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
179 #if !defined(_XPG6) || defined(__EXTENSIONS__)
180 extern int ttyslot(void);
181 extern void *valloc(size_t);
182 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
183 #endif /* defined(__EXTENSIONS__) || ... || defined(_XPG4_2) */
185 #if defined(__EXTENSIONS__) || \
186 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
187 defined(_XPG6)
188 extern int posix_memalign(void **, size_t, size_t);
189 extern int posix_openpt(int);
190 extern int setenv(const char *, const char *, int);
191 extern int unsetenv(const char *);
192 #endif
194 #if defined(__EXTENSIONS__) || \
195 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
196 extern char *canonicalize_file_name(const char *);
197 extern int clearenv(void);
198 extern void closefrom(int);
199 extern int daemon(int, int);
200 extern int dup2(int, int);
201 extern int dup3(int, int, int);
202 extern int fdwalk(int (*)(void *, int), void *);
203 extern char *qecvt(long double, int, int *, int *);
204 extern char *qfcvt(long double, int, int *, int *);
205 extern char *qgcvt(long double, int, char *);
206 extern char *getcwd(char *, size_t);
207 extern const char *getexecname(void);
209 #ifndef __GETLOGIN_DEFINED /* Avoid duplicate in unistd.h */
210 extern char *getlogin(void);
211 #endif /* __GETLOGIN_DEFINED */
213 extern int getopt(int, char *const *, const char *);
214 extern char *optarg;
215 extern int optind, opterr, optopt;
216 extern char *getpass(const char *);
217 extern char *getpassphrase(const char *);
218 extern int isatty(int);
219 extern void *memalign(size_t, size_t);
220 extern char *ttyname(int);
221 extern char *mkdtemp(char *);
222 extern const char *getprogname(void);
223 extern void setprogname(const char *);
225 #if __UNLEASHED_VISIBLE
226 extern char *lltostr(long long, char *);
227 extern char *ulltostr(unsigned long long, char *);
228 #endif
230 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
232 /* OpenBSD compatibility functions */
233 #if __UNLEASHED_VISIBLE
235 #include <inttypes.h>
236 extern uint32_t arc4random(void);
237 extern void arc4random_buf(void *, size_t);
238 extern uint32_t arc4random_uniform(uint32_t);
239 long long strtonum(const char *, long long, long long, const char **);
241 #endif /* __UNLEASHED_VISIBLE */
243 /* FIXME: source compat: these are libc aliases to non-64 versions */
244 int mkstemp64(char *);
245 int mkstemps64(char *, int);
246 int mkostemp64(char *, int);
247 int mkostemps64(char *, int, int);
249 #ifdef __cplusplus
251 #endif
253 #endif /* _STDLIB_H */