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]
23 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
26 /* Copyright (c) 1988 AT&T */
27 /* All Rights Reserved */
32 #include <iso/stdlib_iso.h>
33 #include <iso/stdlib_c99.h>
35 #if defined(__EXTENSIONS__) || defined(_XPG4)
40 * Allow global visibility for symbols defined in
41 * C++ "std" namespace in <iso/stdlib_iso.h>.
43 #if __cplusplus >= 199711L
83 typedef unsigned int uid_t
; /* UID type */
88 /* large file compilation environment setup */
89 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
91 #ifdef __PRAGMA_REDEFINE_EXTNAME
92 #pragma redefine_extname mkstemp mkstemp64
93 #pragma redefine_extname mkstemps mkstemps64
94 #else /* __PRAGMA_REDEFINE_EXTNAME */
95 #define mkstemp mkstemp64
96 #define mkstemps mkstemps64
97 #endif /* __PRAGMA_REDEFINE_EXTNAME */
99 #endif /* _FILE_OFFSET_BITS == 64 */
101 /* In the LP64 compilation environment, all APIs are already large file */
102 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
104 #ifdef __PRAGMA_REDEFINE_EXTNAME
105 #pragma redefine_extname mkstemp64 mkstemp
106 #pragma redefine_extname mkstemps64 mkstemps
107 #else /* __PRAGMA_REDEFINE_EXTNAME */
108 #define mkstemp64 mkstemp
109 #define mkstemps64 mkstemps
110 #endif /* __PRAGMA_REDEFINE_EXTNAME */
112 #endif /* _LP64 && _LARGEFILE64_SOURCE */
114 #if defined(__EXTENSIONS__) || \
115 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
116 (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
117 extern int rand_r(unsigned int *);
120 extern void _exithandle(void);
122 #if defined(__EXTENSIONS__) || \
123 (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
125 extern double drand48(void);
126 extern double erand48(unsigned short *);
127 extern long jrand48(unsigned short *);
128 extern void lcong48(unsigned short *);
129 extern long lrand48(void);
130 extern long mrand48(void);
131 extern long nrand48(unsigned short *);
132 extern unsigned short *seed48(unsigned short *);
133 extern void srand48(long);
134 extern int putenv(char *);
135 extern void setkey(const char *);
136 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
139 * swab() has historically been in <stdlib.h> as delivered from AT&T
140 * and continues to be visible in the default compilation environment.
141 * As of Issue 4 of the X/Open Portability Guides, swab() was declared
142 * in <unistd.h>. As a result, with respect to X/Open namespace the
143 * swab() declaration in this header is only visible for the XPG3
146 #if (defined(__EXTENSIONS__) || \
147 (!defined(_STRICT_STDC__) && !defined(_POSIX_C_SOURCE))) && \
148 (!defined(_XOPEN_SOURCE) || (defined(_XPG3) && !defined(_XPG4)))
151 #if defined(_LP64) || defined(_I32LPx)
152 typedef long ssize_t
; /* size of something in bytes or -1 */
154 typedef int ssize_t
; /* (historical version) */
156 #endif /* !_SSIZE_T */
158 extern void swab(const char *, char *, ssize_t
);
159 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
161 #if defined(__EXTENSIONS__) || \
162 !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
163 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64)
164 extern int mkstemp(char *);
165 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
166 extern int mkstemps(char *, int);
168 #endif /* defined(__EXTENSIONS__) ... */
170 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
171 !defined(__PRAGMA_REDEFINE_EXTNAME))
172 extern int mkstemp64(char *);
173 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
174 extern int mkstemps64(char *, int);
176 #endif /* _LARGEFILE64_SOURCE... */
178 #if defined(__EXTENSIONS__) || \
179 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
181 extern long a64l(const char *);
182 extern char *ecvt(double, int, int *_RESTRICT_KYWD
, int *_RESTRICT_KYWD
);
183 extern char *fcvt(double, int, int *_RESTRICT_KYWD
, int *_RESTRICT_KYWD
);
184 extern char *gcvt(double, int, char *);
185 extern int getsubopt(char **, char *const *, char **);
186 extern int grantpt(int);
187 extern char *initstate(unsigned, char *, size_t);
188 extern char *l64a(long);
189 extern char *mktemp(char *);
190 extern char *ptsname(int);
191 extern long random(void);
192 extern char *realpath(const char *_RESTRICT_KYWD
, char *_RESTRICT_KYWD
);
193 extern char *setstate(const char *);
194 extern void srandom(unsigned);
195 extern int unlockpt(int);
196 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
197 #if !defined(_XPG6) || defined(__EXTENSIONS__)
198 extern int ttyslot(void);
199 extern void *valloc(size_t);
200 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
201 #endif /* defined(__EXTENSIONS__) || ... || defined(_XPG4_2) */
203 #if defined(__EXTENSIONS__) || \
204 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
206 extern int posix_memalign(void **, size_t, size_t);
207 extern int posix_openpt(int);
208 extern int setenv(const char *, const char *, int);
209 extern int unsetenv(const char *);
212 #if defined(__EXTENSIONS__) || \
213 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
214 extern char *canonicalize_file_name(const char *);
215 extern int clearenv(void);
216 extern void closefrom(int);
217 extern int daemon(int, int);
218 extern int dup2(int, int);
219 extern int fdwalk(int (*)(void *, int), void *);
220 extern char *qecvt(long double, int, int *, int *);
221 extern char *qfcvt(long double, int, int *, int *);
222 extern char *qgcvt(long double, int, char *);
223 extern char *getcwd(char *, size_t);
224 extern const char *getexecname(void);
225 extern char *getlogin(void);
226 extern int getopt(int, char *const *, const char *);
228 extern int optind
, opterr
, optopt
;
229 extern char *getpass(const char *);
230 extern char *getpassphrase(const char *);
231 extern int getpw(uid_t
, char *);
232 extern int isatty(int);
233 extern void *memalign(size_t, size_t);
234 extern char *ttyname(int);
235 extern char *mkdtemp(char *);
236 extern const char *getprogname(void);
237 extern void setprogname(const char *);
239 #if !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE)
240 extern char *lltostr(long long, char *);
241 extern char *ulltostr(unsigned long long, char *);
242 #endif /* !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE) */
244 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
246 #else /* not __STDC__ */
248 #if defined(__EXTENSIONS__) || !defined(_XOPEN_OR_POSIX) || \
249 (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
251 #endif /* defined(__EXTENSIONS__) || defined(_REENTRANT) ... */
253 extern void _exithandle();
255 #if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || defined(_XPG4)
256 extern double drand48();
257 extern double erand48();
258 extern long jrand48();
259 extern void lcong48();
260 extern long lrand48();
261 extern long mrand48();
262 extern long nrand48();
263 extern unsigned short *seed48();
264 extern void srand48();
266 extern void setkey();
267 #endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) ... */
269 #if (defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE)) && \
270 (!defined(_XOPEN_SOURCE) || (defined(_XPG3) && !defined(_XPG4)))
274 #if defined(__EXTENSIONS__) || \
275 !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
276 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64)
277 extern int mkstemp();
278 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
279 extern int mkstemps();
281 #endif /* defined(__EXTENSIONS__) ... */
283 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
284 !defined(__PRAGMA_REDEFINE_EXTNAME))
285 extern int mkstemp64();
286 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
287 extern int mkstemps64();
289 #endif /* _LARGEFILE64_SOURCE... */
291 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)
296 extern int getsubopt();
297 extern int grantpt();
298 extern char *initstate();
300 extern char *mktemp();
301 extern char *ptsname();
302 extern long random();
303 extern char *realpath();
304 extern char *setstate();
305 extern void srandom();
306 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
307 #if !defined(_XPG6) || defined(__EXTENSIONS__)
308 extern int ttyslot();
309 extern void *valloc();
310 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
311 #endif /* defined(__EXTENSIONS__) || ... || defined(_XPG4_2) */
313 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG6)
314 extern int posix_memalign();
315 extern int posix_openpt();
317 extern int unsetenv();
320 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
321 extern char *canonicalize_file_name();
322 extern int clearenv();
323 extern void closefrom();
327 extern char *qecvt();
328 extern char *qfcvt();
329 extern char *qgcvt();
330 extern char *getcwd();
331 extern char *getexecname();
332 extern char *getlogin();
335 extern int optind
, opterr
, optopt
;
336 extern char *getpass();
337 extern char *getpassphrase();
340 extern void *memalign();
341 extern char *ttyname();
342 extern char *mkdtemp();
343 extern char *getprogname();
344 extern void setprogname();
346 #if defined(_LONGLONG_TYPE)
347 extern char *lltostr();
348 extern char *ulltostr();
349 #endif /* defined(_LONGLONG_TYPE) */
350 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
352 #endif /* __STDC__ */
358 #endif /* _STDLIB_H */