xref: /illumos-gate/usr/src/head/stdlib.h (revision 223750d9)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c4dcc55Scasper  * Common Development and Distribution License (the "License").
67c4dcc55Scasper  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21019c3c43Sraf 
227c478bd9Sstevel@tonic-gate /*
23ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
240a1278f2SGary Mills  * Copyright (c) 2013 Gary Mills
250a1278f2SGary Mills  *
2623a1cceaSRoger A. Faulkner  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
29e7b66456SAndy Fiddaman /*
30e7b66456SAndy Fiddaman  * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
317d8deab2SAndy Fiddaman  * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
32*223750d9SAndy Fiddaman  * Copyright 2023 Oxide Computer Company
33e7b66456SAndy Fiddaman  */
345dbfd19aSTheo Schlossnagle 
357c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
36b4203d75SMarcel Telka /*	  All Rights Reserved	*/
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifndef _STDLIB_H
397c478bd9Sstevel@tonic-gate #define	_STDLIB_H
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #include <iso/stdlib_iso.h>
427c478bd9Sstevel@tonic-gate #include <iso/stdlib_c99.h>
43fc2512cfSRobert Mustacchi #include <iso/stdlib_c11.h>
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || defined(_XPG4)
467c478bd9Sstevel@tonic-gate #include <sys/wait.h>
477c478bd9Sstevel@tonic-gate #endif
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * Allow global visibility for symbols defined in
517c478bd9Sstevel@tonic-gate  * C++ "std" namespace in <iso/stdlib_iso.h>.
527c478bd9Sstevel@tonic-gate  */
537c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
547c478bd9Sstevel@tonic-gate using std::div_t;
557c478bd9Sstevel@tonic-gate using std::ldiv_t;
567c478bd9Sstevel@tonic-gate using std::size_t;
577c478bd9Sstevel@tonic-gate using std::abort;
587c478bd9Sstevel@tonic-gate using std::abs;
597c478bd9Sstevel@tonic-gate using std::atexit;
607c478bd9Sstevel@tonic-gate using std::atof;
617c478bd9Sstevel@tonic-gate using std::atoi;
627c478bd9Sstevel@tonic-gate using std::atol;
637c478bd9Sstevel@tonic-gate using std::bsearch;
647c478bd9Sstevel@tonic-gate using std::calloc;
657c478bd9Sstevel@tonic-gate using std::div;
667c478bd9Sstevel@tonic-gate using std::exit;
677c478bd9Sstevel@tonic-gate using std::free;
687c478bd9Sstevel@tonic-gate using std::getenv;
697c478bd9Sstevel@tonic-gate using std::labs;
707c478bd9Sstevel@tonic-gate using std::ldiv;
717c478bd9Sstevel@tonic-gate using std::malloc;
727c478bd9Sstevel@tonic-gate using std::mblen;
737c478bd9Sstevel@tonic-gate using std::mbstowcs;
747c478bd9Sstevel@tonic-gate using std::mbtowc;
757c478bd9Sstevel@tonic-gate using std::qsort;
767c478bd9Sstevel@tonic-gate using std::rand;
777c478bd9Sstevel@tonic-gate using std::realloc;
787c478bd9Sstevel@tonic-gate using std::srand;
797c478bd9Sstevel@tonic-gate using std::strtod;
807c478bd9Sstevel@tonic-gate using std::strtol;
817c478bd9Sstevel@tonic-gate using std::strtoul;
827c478bd9Sstevel@tonic-gate using std::system;
837c478bd9Sstevel@tonic-gate using std::wcstombs;
847c478bd9Sstevel@tonic-gate using std::wctomb;
857c478bd9Sstevel@tonic-gate #endif
867c478bd9Sstevel@tonic-gate 
870df48811SAurélien Larcher /*
880df48811SAurélien Larcher  * Allow global visibility for symbols defined in
890df48811SAurélien Larcher  * C++ "std" namespace in <iso/stdlib_c11.h>.
900df48811SAurélien Larcher  */
910df48811SAurélien Larcher #if __cplusplus >= 201103L
920df48811SAurélien Larcher using std::at_quick_exit;
930df48811SAurélien Larcher using std::quick_exit;
940df48811SAurélien Larcher #endif
950df48811SAurélien Larcher #if __cplusplus >= 201703L
960df48811SAurélien Larcher using std::aligned_alloc;
970df48811SAurélien Larcher #endif
980df48811SAurélien Larcher 
997c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1007c478bd9Sstevel@tonic-gate extern "C" {
1017c478bd9Sstevel@tonic-gate #endif
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate #ifndef _UID_T
1047c478bd9Sstevel@tonic-gate #define	_UID_T
105f48205beScasper typedef	unsigned int	uid_t;		/* UID type		*/
1067c478bd9Sstevel@tonic-gate #endif	/* !_UID_T */
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate /* large file compilation environment setup */
1097c478bd9Sstevel@tonic-gate #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
1127c478bd9Sstevel@tonic-gate #pragma redefine_extname	mkstemp		mkstemp64
1137c4dcc55Scasper #pragma redefine_extname	mkstemps	mkstemps64
11490553fa8SMohamed A. Khalfella #pragma	redefine_extname	mkostemp	mkostemp64
11590553fa8SMohamed A. Khalfella #pragma	redefine_extname	mkostemps	mkostemps64
1167c478bd9Sstevel@tonic-gate #else	/* __PRAGMA_REDEFINE_EXTNAME */
1177c478bd9Sstevel@tonic-gate #define	mkstemp			mkstemp64
1187c4dcc55Scasper #define	mkstemps		mkstemps64
11990553fa8SMohamed A. Khalfella #define	mkostemp		mkostemp64
12090553fa8SMohamed A. Khalfella #define	mkostemps		mkostemps64
1217c478bd9Sstevel@tonic-gate #endif	/* __PRAGMA_REDEFINE_EXTNAME */
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate #endif	/* _FILE_OFFSET_BITS == 64 */
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate /* In the LP64 compilation environment, all APIs are already large file */
1267c478bd9Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
1297c478bd9Sstevel@tonic-gate #pragma redefine_extname	mkstemp64	mkstemp
1307c4dcc55Scasper #pragma redefine_extname	mkstemps64	mkstemps
13190553fa8SMohamed A. Khalfella #pragma	redefine_extname	mkostemp64	mkostemp
13290553fa8SMohamed A. Khalfella #pragma	redefine_extname	mkostemps64	mkostemps
1337c478bd9Sstevel@tonic-gate #else	/* __PRAGMA_REDEFINE_EXTNAME */
1347c478bd9Sstevel@tonic-gate #define	mkstemp64		mkstemp
1357c4dcc55Scasper #define	mkstemps64		mkstemps
13690553fa8SMohamed A. Khalfella #define	mkostemp64		mkostemp
13790553fa8SMohamed A. Khalfella #define	mkostemps64		mkostemps
1387c478bd9Sstevel@tonic-gate #endif	/* __PRAGMA_REDEFINE_EXTNAME */
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate #endif	/* _LP64 && _LARGEFILE64_SOURCE */
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || \
1437c478bd9Sstevel@tonic-gate 	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
1447c478bd9Sstevel@tonic-gate 	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
1457c478bd9Sstevel@tonic-gate extern int rand_r(unsigned int *);
1467c478bd9Sstevel@tonic-gate #endif
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate extern void _exithandle(void);
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || \
1517c478bd9Sstevel@tonic-gate 	(!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
1527c478bd9Sstevel@tonic-gate 	defined(_XPG4)
1537c478bd9Sstevel@tonic-gate extern double drand48(void);
1547c478bd9Sstevel@tonic-gate extern double erand48(unsigned short *);
1557c478bd9Sstevel@tonic-gate extern long jrand48(unsigned short *);
1567c478bd9Sstevel@tonic-gate extern void lcong48(unsigned short *);
1577c478bd9Sstevel@tonic-gate extern long lrand48(void);
1587c478bd9Sstevel@tonic-gate extern long mrand48(void);
1597c478bd9Sstevel@tonic-gate extern long nrand48(unsigned short *);
1607c478bd9Sstevel@tonic-gate extern unsigned short *seed48(unsigned short *);
1617c478bd9Sstevel@tonic-gate extern void srand48(long);
1627c478bd9Sstevel@tonic-gate extern int putenv(char *);
1637c478bd9Sstevel@tonic-gate extern void setkey(const char *);
1647c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate /*
1677c478bd9Sstevel@tonic-gate  * swab() has historically been in <stdlib.h> as delivered from AT&T
1687c478bd9Sstevel@tonic-gate  * and continues to be visible in the default compilation environment.
1697c478bd9Sstevel@tonic-gate  * As of Issue 4 of the X/Open Portability Guides, swab() was declared
1707c478bd9Sstevel@tonic-gate  * in <unistd.h>. As a result, with respect to X/Open namespace the
1717c478bd9Sstevel@tonic-gate  * swab() declaration in this header is only visible for the XPG3
1727c478bd9Sstevel@tonic-gate  * environment.
1737c478bd9Sstevel@tonic-gate  */
1747c478bd9Sstevel@tonic-gate #if (defined(__EXTENSIONS__) || \
1757c478bd9Sstevel@tonic-gate 	(!defined(_STRICT_STDC__) && !defined(_POSIX_C_SOURCE))) && \
1767c478bd9Sstevel@tonic-gate 	(!defined(_XOPEN_SOURCE) || (defined(_XPG3) && !defined(_XPG4)))
1777c478bd9Sstevel@tonic-gate #ifndef	_SSIZE_T
1787c478bd9Sstevel@tonic-gate #define	_SSIZE_T
1797c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx)
1807c478bd9Sstevel@tonic-gate typedef long	ssize_t;	/* size of something in bytes or -1 */
1817c478bd9Sstevel@tonic-gate #else
1827c478bd9Sstevel@tonic-gate typedef int	ssize_t;	/* (historical version) */
1837c478bd9Sstevel@tonic-gate #endif
1847c478bd9Sstevel@tonic-gate #endif	/* !_SSIZE_T */
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate extern void swab(const char *, char *, ssize_t);
1877c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || \
1907c478bd9Sstevel@tonic-gate 	!defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
1917c478bd9Sstevel@tonic-gate 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64)
1927c478bd9Sstevel@tonic-gate extern int	mkstemp(char *);
1934e9cef60Scasper #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
1947c4dcc55Scasper extern int	mkstemps(char *, int);
1954e9cef60Scasper #endif
1967c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) ... */
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
1997c478bd9Sstevel@tonic-gate 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
2007c478bd9Sstevel@tonic-gate extern int	mkstemp64(char *);
2014e9cef60Scasper #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
2027c4dcc55Scasper extern int	mkstemps64(char *, int);
2034e9cef60Scasper #endif
2047c478bd9Sstevel@tonic-gate #endif	/* _LARGEFILE64_SOURCE... */
2057c478bd9Sstevel@tonic-gate 
20690553fa8SMohamed A. Khalfella #if !defined(_STRICT_SYMBOLS) || defined(_XPG7)
20790553fa8SMohamed A. Khalfella extern char	*mkdtemp(char *);
20890553fa8SMohamed A. Khalfella #endif	/* !defined(_STRICT_SYMBOLS) || defined(_XPG7) */
20990553fa8SMohamed A. Khalfella 
21090553fa8SMohamed A. Khalfella #if !defined(_STRICT_SYMBOLS)
21190553fa8SMohamed A. Khalfella extern int		mkostemp(char *, int);
21290553fa8SMohamed A. Khalfella extern int		mkostemps(char *, int, int);
21390553fa8SMohamed A. Khalfella #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
21490553fa8SMohamed A. Khalfella 		!defined(__PRAGMA_REDEFINE_EXTNAME))
21590553fa8SMohamed A. Khalfella extern int		mkostemp64(char *, int);
21690553fa8SMohamed A. Khalfella extern int		mkostemps64(char *, int, int);
21790553fa8SMohamed A. Khalfella #endif	/* defined(_LARGEFILE64_SOURCE) || !((_FILE_OFFSET_BITS == 64) ... */
21890553fa8SMohamed A. Khalfella #endif	/* !defined(_STRICT_SYMBOLS) */
21990553fa8SMohamed A. Khalfella 
2207c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || \
2217c478bd9Sstevel@tonic-gate 	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
2227c478bd9Sstevel@tonic-gate 	defined(_XPG4_2)
2237c478bd9Sstevel@tonic-gate extern long a64l(const char *);
2247c478bd9Sstevel@tonic-gate extern char *ecvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
2257c478bd9Sstevel@tonic-gate extern char *fcvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
2267c478bd9Sstevel@tonic-gate extern char *gcvt(double, int, char *);
2277c478bd9Sstevel@tonic-gate extern int getsubopt(char **, char *const *, char **);
2287c478bd9Sstevel@tonic-gate extern int  grantpt(int);
2297c478bd9Sstevel@tonic-gate extern char *initstate(unsigned, char *, size_t);
2307c478bd9Sstevel@tonic-gate extern char *l64a(long);
2317c478bd9Sstevel@tonic-gate extern char *mktemp(char *);
2327c478bd9Sstevel@tonic-gate extern char *ptsname(int);
2337c478bd9Sstevel@tonic-gate extern long random(void);
2347c478bd9Sstevel@tonic-gate extern char *realpath(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
2357c478bd9Sstevel@tonic-gate extern char *setstate(const char *);
2367c478bd9Sstevel@tonic-gate extern void srandom(unsigned);
2377c478bd9Sstevel@tonic-gate extern int  unlockpt(int);
2387c478bd9Sstevel@tonic-gate /* Marked LEGACY in SUSv2 and removed in SUSv3 */
2397c478bd9Sstevel@tonic-gate #if !defined(_XPG6) || defined(__EXTENSIONS__)
2407c478bd9Sstevel@tonic-gate extern int ttyslot(void);
2417c478bd9Sstevel@tonic-gate extern void *valloc(size_t);
2427c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
2437c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || ... || defined(_XPG4_2) */
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || \
2467c478bd9Sstevel@tonic-gate 	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
2477c478bd9Sstevel@tonic-gate 	defined(_XPG6)
248019c3c43Sraf extern int posix_memalign(void **, size_t, size_t);
2497c478bd9Sstevel@tonic-gate extern int posix_openpt(int);
2507c478bd9Sstevel@tonic-gate extern int setenv(const char *, const char *, int);
2517c478bd9Sstevel@tonic-gate extern int unsetenv(const char *);
2527c478bd9Sstevel@tonic-gate #endif
2537c478bd9Sstevel@tonic-gate 
2547d8deab2SAndy Fiddaman /*
2557d8deab2SAndy Fiddaman  * In strict XPG4v2 mode, slave pseudo terminal devices behave differently.
2567d8deab2SAndy Fiddaman  * See the block comment in usr/src/lib/libc/port/gen/pt.c
2577d8deab2SAndy Fiddaman  */
2587d8deab2SAndy Fiddaman #if defined(_STRICT_SYMBOLS) && defined(_XPG4_2)
2597d8deab2SAndy Fiddaman #ifdef	__PRAGMA_REDEFINE_EXTNAME
2607d8deab2SAndy Fiddaman #pragma redefine_extname unlockpt __unlockpt_xpg4
2617d8deab2SAndy Fiddaman #else
2627d8deab2SAndy Fiddaman extern int __unlockpt_xpg4(int);
2637d8deab2SAndy Fiddaman #define	unlockpt __unlockpt_xpg4
2647d8deab2SAndy Fiddaman #endif
2657d8deab2SAndy Fiddaman #endif	/* defined(_STRICT_SYMBOLS) && defined(_XPG4_2) */
2667d8deab2SAndy Fiddaman 
2677c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || \
2687c478bd9Sstevel@tonic-gate 	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
26923a1cceaSRoger A. Faulkner extern char *canonicalize_file_name(const char *);
27023a1cceaSRoger A. Faulkner extern int clearenv(void);
2717c478bd9Sstevel@tonic-gate extern void closefrom(int);
27244991a1cSVladimir Kotal extern int daemon(int, int);
2737c478bd9Sstevel@tonic-gate extern int dup2(int, int);
2745dbfd19aSTheo Schlossnagle extern int dup3(int, int, int);
2757c478bd9Sstevel@tonic-gate extern int fdwalk(int (*)(void *, int), void *);
2767c478bd9Sstevel@tonic-gate extern char *qecvt(long double, int, int *, int *);
2777c478bd9Sstevel@tonic-gate extern char *qfcvt(long double, int, int *, int *);
2787c478bd9Sstevel@tonic-gate extern char *qgcvt(long double, int, char *);
2797c478bd9Sstevel@tonic-gate extern char *getcwd(char *, size_t);
2807c478bd9Sstevel@tonic-gate extern const char *getexecname(void);
2810a1278f2SGary Mills 
2820a1278f2SGary Mills #ifndef	__GETLOGIN_DEFINED	/* Avoid duplicate in unistd.h */
2830a1278f2SGary Mills #define	__GETLOGIN_DEFINED
2840a1278f2SGary Mills #ifndef	__USE_LEGACY_LOGNAME__
2850a1278f2SGary Mills #ifdef	__PRAGMA_REDEFINE_EXTNAME
2860a1278f2SGary Mills #pragma	redefine_extname getlogin getloginx
2870a1278f2SGary Mills #else	/* __PRAGMA_REDEFINE_EXTNAME */
2880a1278f2SGary Mills extern char *getloginx(void);
2890a1278f2SGary Mills #define	getlogin	getloginx
2900a1278f2SGary Mills #endif	/* __PRAGMA_REDEFINE_EXTNAME */
2910a1278f2SGary Mills #endif	/* __USE_LEGACY_LOGNAME__ */
2927c478bd9Sstevel@tonic-gate extern char *getlogin(void);
2930a1278f2SGary Mills #endif	/* __GETLOGIN_DEFINED */
2940a1278f2SGary Mills 
2957c478bd9Sstevel@tonic-gate extern int getopt(int, char *const *, const char *);
2967c478bd9Sstevel@tonic-gate extern char *optarg;
2977c478bd9Sstevel@tonic-gate extern int optind, opterr, optopt;
2987c478bd9Sstevel@tonic-gate extern char *getpass(const char *);
2997c478bd9Sstevel@tonic-gate extern char *getpassphrase(const char *);
3007c478bd9Sstevel@tonic-gate extern int getpw(uid_t, char *);
3017c478bd9Sstevel@tonic-gate extern int isatty(int);
3027c478bd9Sstevel@tonic-gate extern void *memalign(size_t, size_t);
3037c478bd9Sstevel@tonic-gate extern char *ttyname(int);
3047c4dcc55Scasper extern char *mkdtemp(char *);
30523a1cceaSRoger A. Faulkner extern const char *getprogname(void);
30623a1cceaSRoger A. Faulkner extern void setprogname(const char *);
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate #if !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE)
3097c478bd9Sstevel@tonic-gate extern char *lltostr(long long, char *);
3107c478bd9Sstevel@tonic-gate extern char *ulltostr(unsigned long long, char *);
3117c478bd9Sstevel@tonic-gate #endif	/* !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE) */
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
3147c478bd9Sstevel@tonic-gate 
31544431c82SRobert Mustacchi /* OpenBSD and misc. compatibility functions */
3169d12795fSRobert Mustacchi #if !defined(_STRICT_SYMBOLS)
3179d12795fSRobert Mustacchi 
3189d12795fSRobert Mustacchi #include <inttypes.h>
3199d12795fSRobert Mustacchi extern uint32_t arc4random(void);
3209d12795fSRobert Mustacchi extern void arc4random_buf(void *, size_t);
3219d12795fSRobert Mustacchi extern uint32_t arc4random_uniform(uint32_t);
322f1cdbd37SYuri Pankov extern void freezero(void *, size_t);
3234585130bSYuri Pankov extern void *reallocarray(void *, size_t, size_t);
324f1cdbd37SYuri Pankov extern void *recallocarray(void *, size_t, size_t, size_t);
3254585130bSYuri Pankov extern long long strtonum(const char *, long long, long long, const char **);
326*223750d9SAndy Fiddaman extern long long strtonumx(const char *, long long, long long, const char **,
327*223750d9SAndy Fiddaman     int);
328e7b66456SAndy Fiddaman extern void *reallocf(void *, size_t);
3299d12795fSRobert Mustacchi 
33044431c82SRobert Mustacchi extern void qsort_r(void *, size_t, size_t,
33144431c82SRobert Mustacchi     int (*)(const void *, const void *, void *), void *);
3329d12795fSRobert Mustacchi #endif	/* !_STRICT_SYBMOLS */
3339d12795fSRobert Mustacchi 
3349d12795fSRobert Mustacchi 
3357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3367c478bd9Sstevel@tonic-gate }
3377c478bd9Sstevel@tonic-gate #endif
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate #endif	/* _STDLIB_H */
340