xref: /titanic_52/usr/src/head/iso/stdlib_iso.h (revision 693e4d84eb49b987c3d66cbcd4b13a5c6e9059bf)
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
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
287c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * An application should not include this header directly.  Instead it
337c478bd9Sstevel@tonic-gate  * should be included only through the inclusion of other Sun headers.
347c478bd9Sstevel@tonic-gate  *
357c478bd9Sstevel@tonic-gate  * The contents of this header is limited to identifiers specified in the
367c478bd9Sstevel@tonic-gate  * C Standard.  Any new identifiers specified in future amendments to the
377c478bd9Sstevel@tonic-gate  * C Standard must be placed in this header.  If these new identifiers
387c478bd9Sstevel@tonic-gate  * are required to also be in the C++ Standard "std" namespace, then for
397c478bd9Sstevel@tonic-gate  * anything other than macro definitions, corresponding "using" directives
407c478bd9Sstevel@tonic-gate  * must also be added to <locale.h>.
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #ifndef _ISO_STDLIB_ISO_H
447c478bd9Sstevel@tonic-gate #define	_ISO_STDLIB_ISO_H
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
497c478bd9Sstevel@tonic-gate extern "C" {
507c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #if defined(__STDC__)
537c478bd9Sstevel@tonic-gate extern unsigned char	__ctype[];
547c478bd9Sstevel@tonic-gate #define	MB_CUR_MAX	__ctype[520]
557c478bd9Sstevel@tonic-gate #else
567c478bd9Sstevel@tonic-gate extern unsigned char	_ctype[];
577c478bd9Sstevel@tonic-gate #define	MB_CUR_MAX	_ctype[520]
587c478bd9Sstevel@tonic-gate #endif
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
617c478bd9Sstevel@tonic-gate namespace std {
627c478bd9Sstevel@tonic-gate #endif
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate typedef	struct {
657c478bd9Sstevel@tonic-gate 	int	quot;
667c478bd9Sstevel@tonic-gate 	int	rem;
677c478bd9Sstevel@tonic-gate } div_t;
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate typedef struct {
707c478bd9Sstevel@tonic-gate 	long	quot;
717c478bd9Sstevel@tonic-gate 	long	rem;
727c478bd9Sstevel@tonic-gate } ldiv_t;
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate #if !defined(_SIZE_T) || __cplusplus >= 199711L
757c478bd9Sstevel@tonic-gate #define	_SIZE_T
767c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx)
777c478bd9Sstevel@tonic-gate typedef unsigned long	size_t;		/* size of something in bytes */
787c478bd9Sstevel@tonic-gate #else
797c478bd9Sstevel@tonic-gate typedef unsigned int    size_t;		/* (historical version) */
807c478bd9Sstevel@tonic-gate #endif
817c478bd9Sstevel@tonic-gate #endif	/* !_SIZE_T */
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate #ifndef	NULL
847c478bd9Sstevel@tonic-gate #if defined(_LP64)
857c478bd9Sstevel@tonic-gate #define	NULL	0L
867c478bd9Sstevel@tonic-gate #else
877c478bd9Sstevel@tonic-gate #define	NULL	0
887c478bd9Sstevel@tonic-gate #endif
897c478bd9Sstevel@tonic-gate #endif
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate #define	EXIT_FAILURE	1
927c478bd9Sstevel@tonic-gate #define	EXIT_SUCCESS    0
937c478bd9Sstevel@tonic-gate #define	RAND_MAX	32767
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate  * wchar_t is a built-in type in standard C++ and as such is not
977c478bd9Sstevel@tonic-gate  * defined here when using standard C++. However, the GNU compiler
98159cf8a6Swesolows  * fixincludes utility nonetheless creates its own version of this
997c478bd9Sstevel@tonic-gate  * header for use by gcc and g++. In that version it adds a redundant
1007c478bd9Sstevel@tonic-gate  * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
1017c478bd9Sstevel@tonic-gate  * header we need to include the following magic comment:
1027c478bd9Sstevel@tonic-gate  *
1037c478bd9Sstevel@tonic-gate  * we must use the C++ compiler's type
1047c478bd9Sstevel@tonic-gate  *
1057c478bd9Sstevel@tonic-gate  * The above comment should not be removed or changed until GNU
1067c478bd9Sstevel@tonic-gate  * gcc/fixinc/inclhack.def is updated to bypass this header.
1077c478bd9Sstevel@tonic-gate  */
1087c478bd9Sstevel@tonic-gate #if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
1097c478bd9Sstevel@tonic-gate #ifndef _WCHAR_T
1107c478bd9Sstevel@tonic-gate #define	_WCHAR_T
1117c478bd9Sstevel@tonic-gate #if defined(_LP64)
1127c478bd9Sstevel@tonic-gate typedef	int	wchar_t;
1137c478bd9Sstevel@tonic-gate #else
1147c478bd9Sstevel@tonic-gate typedef long	wchar_t;
1157c478bd9Sstevel@tonic-gate #endif
1167c478bd9Sstevel@tonic-gate #endif	/* !_WCHAR_T */
1177c478bd9Sstevel@tonic-gate #endif	/* !defined(__cplusplus) ... */
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate #if defined(__STDC__)
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate extern void abort(void) __NORETURN;
1227c478bd9Sstevel@tonic-gate extern int abs(int);
1237c478bd9Sstevel@tonic-gate extern int atexit(void (*)(void));
1247c478bd9Sstevel@tonic-gate extern double atof(const char *);
1257c478bd9Sstevel@tonic-gate extern int atoi(const char *);
1267c478bd9Sstevel@tonic-gate extern long int atol(const char *);
1277c478bd9Sstevel@tonic-gate extern void *bsearch(const void *, const void *, size_t, size_t,
1287c478bd9Sstevel@tonic-gate 	int (*)(const void *, const void *));
129*693e4d84SAlexander Pyhalov #if __cplusplus >= 199711L && defined(__SUNPRO_CC)
1307c478bd9Sstevel@tonic-gate extern "C++" {
1317c478bd9Sstevel@tonic-gate 	void *bsearch(const void *, const void *, size_t, size_t,
1327c478bd9Sstevel@tonic-gate 		int (*)(const void *, const void *));
1337c478bd9Sstevel@tonic-gate }
134*693e4d84SAlexander Pyhalov #endif /* __cplusplus >= 199711L && defined(__SUNPRO_CC) */
1357c478bd9Sstevel@tonic-gate extern void *calloc(size_t, size_t);
1367c478bd9Sstevel@tonic-gate extern div_t div(int, int);
1377c478bd9Sstevel@tonic-gate extern void exit(int)
1387c478bd9Sstevel@tonic-gate 	__NORETURN;
1397c478bd9Sstevel@tonic-gate extern void free(void *);
1407c478bd9Sstevel@tonic-gate extern char *getenv(const char *);
1417c478bd9Sstevel@tonic-gate extern long int labs(long);
1427c478bd9Sstevel@tonic-gate extern ldiv_t ldiv(long, long);
1437c478bd9Sstevel@tonic-gate extern void *malloc(size_t);
1447c478bd9Sstevel@tonic-gate extern int mblen(const char *, size_t);
1457c478bd9Sstevel@tonic-gate extern size_t mbstowcs(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
1467c478bd9Sstevel@tonic-gate 	size_t);
1477c478bd9Sstevel@tonic-gate extern int mbtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
1487c478bd9Sstevel@tonic-gate extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
149*693e4d84SAlexander Pyhalov #if __cplusplus >= 199711L && defined(__SUNPRO_CC)
1507c478bd9Sstevel@tonic-gate extern "C++" {
1517c478bd9Sstevel@tonic-gate 	void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
1527c478bd9Sstevel@tonic-gate }
153*693e4d84SAlexander Pyhalov #endif /* __cplusplus >= 199711L && defined(__SUNPRO_CC) */
1547c478bd9Sstevel@tonic-gate extern int rand(void);
1557c478bd9Sstevel@tonic-gate extern void *realloc(void *, size_t);
1567c478bd9Sstevel@tonic-gate extern void srand(unsigned int);
1577c478bd9Sstevel@tonic-gate extern double strtod(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD);
1587c478bd9Sstevel@tonic-gate extern long int strtol(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD, int);
1597c478bd9Sstevel@tonic-gate extern unsigned long int strtoul(const char *_RESTRICT_KYWD,
1607c478bd9Sstevel@tonic-gate 	char **_RESTRICT_KYWD, int);
1617c478bd9Sstevel@tonic-gate extern int system(const char *);
1627c478bd9Sstevel@tonic-gate extern int wctomb(char *, wchar_t);
1637c478bd9Sstevel@tonic-gate extern size_t wcstombs(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
1647c478bd9Sstevel@tonic-gate 	size_t);
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
1677c478bd9Sstevel@tonic-gate extern "C++" {
1687c478bd9Sstevel@tonic-gate 	inline long   abs(long _l) { return labs(_l); }
1697c478bd9Sstevel@tonic-gate 	inline ldiv_t div(long _l1, long _l2) { return ldiv(_l1, _l2); }
1707c478bd9Sstevel@tonic-gate }
1717c478bd9Sstevel@tonic-gate #endif /* __cplusplus */
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate #else /* not __STDC__ */
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate extern void abort();
1767c478bd9Sstevel@tonic-gate extern int abs();
1777c478bd9Sstevel@tonic-gate extern int atexit();
1787c478bd9Sstevel@tonic-gate extern double atof();
1797c478bd9Sstevel@tonic-gate extern int atoi();
1807c478bd9Sstevel@tonic-gate extern long int atol();
1817c478bd9Sstevel@tonic-gate extern void *bsearch();
1827c478bd9Sstevel@tonic-gate extern void *calloc();
1837c478bd9Sstevel@tonic-gate extern div_t div();
1847c478bd9Sstevel@tonic-gate extern void exit();
1857c478bd9Sstevel@tonic-gate extern void free();
1867c478bd9Sstevel@tonic-gate extern char *getenv();
1877c478bd9Sstevel@tonic-gate extern long int labs();
1887c478bd9Sstevel@tonic-gate extern ldiv_t ldiv();
1897c478bd9Sstevel@tonic-gate extern void *malloc();
1907c478bd9Sstevel@tonic-gate extern int mblen();
1917c478bd9Sstevel@tonic-gate extern size_t mbstowcs();
1927c478bd9Sstevel@tonic-gate extern int mbtowc();
1937c478bd9Sstevel@tonic-gate extern void qsort();
1947c478bd9Sstevel@tonic-gate extern int rand();
1957c478bd9Sstevel@tonic-gate extern void *realloc();
1967c478bd9Sstevel@tonic-gate extern void srand();
1977c478bd9Sstevel@tonic-gate extern double strtod();
1987c478bd9Sstevel@tonic-gate extern long int strtol();
1997c478bd9Sstevel@tonic-gate extern unsigned long strtoul();
2007c478bd9Sstevel@tonic-gate extern int system();
2017c478bd9Sstevel@tonic-gate extern int wctomb();
2027c478bd9Sstevel@tonic-gate extern size_t wcstombs();
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
2077c478bd9Sstevel@tonic-gate }
2087c478bd9Sstevel@tonic-gate #endif /* end of namespace std */
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2117c478bd9Sstevel@tonic-gate }
2127c478bd9Sstevel@tonic-gate #endif
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate #endif	/* _ISO_STDLIB_ISO_H */
215