xref: /onnv-gate/usr/src/head/iso/stdlib_iso.h (revision 376:28d11977b99c)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
230Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
280Sstevel@tonic-gate /*	  All Rights Reserved  	*/
290Sstevel@tonic-gate 
300Sstevel@tonic-gate 
310Sstevel@tonic-gate /*
320Sstevel@tonic-gate  * An application should not include this header directly.  Instead it
330Sstevel@tonic-gate  * should be included only through the inclusion of other Sun headers.
340Sstevel@tonic-gate  *
350Sstevel@tonic-gate  * The contents of this header is limited to identifiers specified in the
360Sstevel@tonic-gate  * C Standard.  Any new identifiers specified in future amendments to the
370Sstevel@tonic-gate  * C Standard must be placed in this header.  If these new identifiers
380Sstevel@tonic-gate  * are required to also be in the C++ Standard "std" namespace, then for
390Sstevel@tonic-gate  * anything other than macro definitions, corresponding "using" directives
400Sstevel@tonic-gate  * must also be added to <locale.h>.
410Sstevel@tonic-gate  */
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #ifndef _ISO_STDLIB_ISO_H
440Sstevel@tonic-gate #define	_ISO_STDLIB_ISO_H
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
470Sstevel@tonic-gate 
480Sstevel@tonic-gate #include <sys/feature_tests.h>
490Sstevel@tonic-gate 
500Sstevel@tonic-gate #ifdef	__cplusplus
510Sstevel@tonic-gate extern "C" {
520Sstevel@tonic-gate #endif
530Sstevel@tonic-gate 
540Sstevel@tonic-gate #if defined(__STDC__)
550Sstevel@tonic-gate extern unsigned char	__ctype[];
560Sstevel@tonic-gate #define	MB_CUR_MAX	__ctype[520]
570Sstevel@tonic-gate #else
580Sstevel@tonic-gate extern unsigned char	_ctype[];
590Sstevel@tonic-gate #define	MB_CUR_MAX	_ctype[520]
600Sstevel@tonic-gate #endif
610Sstevel@tonic-gate 
620Sstevel@tonic-gate #if __cplusplus >= 199711L
630Sstevel@tonic-gate namespace std {
640Sstevel@tonic-gate #endif
650Sstevel@tonic-gate 
660Sstevel@tonic-gate typedef	struct {
670Sstevel@tonic-gate 	int	quot;
680Sstevel@tonic-gate 	int	rem;
690Sstevel@tonic-gate } div_t;
700Sstevel@tonic-gate 
710Sstevel@tonic-gate typedef struct {
720Sstevel@tonic-gate 	long	quot;
730Sstevel@tonic-gate 	long	rem;
740Sstevel@tonic-gate } ldiv_t;
750Sstevel@tonic-gate 
760Sstevel@tonic-gate #if !defined(_SIZE_T) || __cplusplus >= 199711L
770Sstevel@tonic-gate #define	_SIZE_T
780Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx)
790Sstevel@tonic-gate typedef unsigned long	size_t;		/* size of something in bytes */
800Sstevel@tonic-gate #else
810Sstevel@tonic-gate typedef unsigned int    size_t;		/* (historical version) */
820Sstevel@tonic-gate #endif
830Sstevel@tonic-gate #endif	/* !_SIZE_T */
840Sstevel@tonic-gate 
850Sstevel@tonic-gate #ifndef	NULL
860Sstevel@tonic-gate #if defined(_LP64)
870Sstevel@tonic-gate #define	NULL	0L
880Sstevel@tonic-gate #else
890Sstevel@tonic-gate #define	NULL	0
900Sstevel@tonic-gate #endif
910Sstevel@tonic-gate #endif
920Sstevel@tonic-gate 
930Sstevel@tonic-gate #define	EXIT_FAILURE	1
940Sstevel@tonic-gate #define	EXIT_SUCCESS    0
950Sstevel@tonic-gate #define	RAND_MAX	32767
960Sstevel@tonic-gate 
970Sstevel@tonic-gate /*
980Sstevel@tonic-gate  * wchar_t is a built-in type in standard C++ and as such is not
990Sstevel@tonic-gate  * defined here when using standard C++. However, the GNU compiler
100*376Swesolows  * fixincludes utility nonetheless creates its own version of this
1010Sstevel@tonic-gate  * header for use by gcc and g++. In that version it adds a redundant
1020Sstevel@tonic-gate  * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
1030Sstevel@tonic-gate  * header we need to include the following magic comment:
1040Sstevel@tonic-gate  *
1050Sstevel@tonic-gate  * we must use the C++ compiler's type
1060Sstevel@tonic-gate  *
1070Sstevel@tonic-gate  * The above comment should not be removed or changed until GNU
1080Sstevel@tonic-gate  * gcc/fixinc/inclhack.def is updated to bypass this header.
1090Sstevel@tonic-gate  */
1100Sstevel@tonic-gate #if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
1110Sstevel@tonic-gate #ifndef _WCHAR_T
1120Sstevel@tonic-gate #define	_WCHAR_T
1130Sstevel@tonic-gate #if defined(_LP64)
1140Sstevel@tonic-gate typedef	int	wchar_t;
1150Sstevel@tonic-gate #else
1160Sstevel@tonic-gate typedef long	wchar_t;
1170Sstevel@tonic-gate #endif
1180Sstevel@tonic-gate #endif	/* !_WCHAR_T */
1190Sstevel@tonic-gate #endif	/* !defined(__cplusplus) ... */
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate #if defined(__STDC__)
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate extern void abort(void) __NORETURN;
1240Sstevel@tonic-gate extern int abs(int);
1250Sstevel@tonic-gate extern int atexit(void (*)(void));
1260Sstevel@tonic-gate extern double atof(const char *);
1270Sstevel@tonic-gate extern int atoi(const char *);
1280Sstevel@tonic-gate extern long int atol(const char *);
1290Sstevel@tonic-gate extern void *bsearch(const void *, const void *, size_t, size_t,
1300Sstevel@tonic-gate 	int (*)(const void *, const void *));
1310Sstevel@tonic-gate #if __cplusplus >= 199711L
1320Sstevel@tonic-gate extern "C++" {
1330Sstevel@tonic-gate 	void *bsearch(const void *, const void *, size_t, size_t,
1340Sstevel@tonic-gate 		int (*)(const void *, const void *));
1350Sstevel@tonic-gate }
1360Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */
1370Sstevel@tonic-gate extern void *calloc(size_t, size_t);
1380Sstevel@tonic-gate extern div_t div(int, int);
1390Sstevel@tonic-gate extern void exit(int)
1400Sstevel@tonic-gate 	__NORETURN;
1410Sstevel@tonic-gate extern void free(void *);
1420Sstevel@tonic-gate extern char *getenv(const char *);
1430Sstevel@tonic-gate extern long int labs(long);
1440Sstevel@tonic-gate extern ldiv_t ldiv(long, long);
1450Sstevel@tonic-gate extern void *malloc(size_t);
1460Sstevel@tonic-gate extern int mblen(const char *, size_t);
1470Sstevel@tonic-gate extern size_t mbstowcs(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
1480Sstevel@tonic-gate 	size_t);
1490Sstevel@tonic-gate extern int mbtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
1500Sstevel@tonic-gate extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
1510Sstevel@tonic-gate #if __cplusplus >= 199711L
1520Sstevel@tonic-gate extern "C++" {
1530Sstevel@tonic-gate 	void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
1540Sstevel@tonic-gate }
1550Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */
1560Sstevel@tonic-gate extern int rand(void);
1570Sstevel@tonic-gate extern void *realloc(void *, size_t);
1580Sstevel@tonic-gate extern void srand(unsigned int);
1590Sstevel@tonic-gate extern double strtod(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD);
1600Sstevel@tonic-gate extern long int strtol(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD, int);
1610Sstevel@tonic-gate extern unsigned long int strtoul(const char *_RESTRICT_KYWD,
1620Sstevel@tonic-gate 	char **_RESTRICT_KYWD, int);
1630Sstevel@tonic-gate extern int system(const char *);
1640Sstevel@tonic-gate extern int wctomb(char *, wchar_t);
1650Sstevel@tonic-gate extern size_t wcstombs(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
1660Sstevel@tonic-gate 	size_t);
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate #if __cplusplus >= 199711L
1690Sstevel@tonic-gate extern "C++" {
abs(long _l)1700Sstevel@tonic-gate 	inline long   abs(long _l) { return labs(_l); }
div(long _l1,long _l2)1710Sstevel@tonic-gate 	inline ldiv_t div(long _l1, long _l2) { return ldiv(_l1, _l2); }
1720Sstevel@tonic-gate }
1730Sstevel@tonic-gate #endif /* __cplusplus */
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate #else /* not __STDC__ */
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate extern void abort();
1780Sstevel@tonic-gate extern int abs();
1790Sstevel@tonic-gate extern int atexit();
1800Sstevel@tonic-gate extern double atof();
1810Sstevel@tonic-gate extern int atoi();
1820Sstevel@tonic-gate extern long int atol();
1830Sstevel@tonic-gate extern void *bsearch();
1840Sstevel@tonic-gate extern void *calloc();
1850Sstevel@tonic-gate extern div_t div();
1860Sstevel@tonic-gate extern void exit();
1870Sstevel@tonic-gate extern void free();
1880Sstevel@tonic-gate extern char *getenv();
1890Sstevel@tonic-gate extern long int labs();
1900Sstevel@tonic-gate extern ldiv_t ldiv();
1910Sstevel@tonic-gate extern void *malloc();
1920Sstevel@tonic-gate extern int mblen();
1930Sstevel@tonic-gate extern size_t mbstowcs();
1940Sstevel@tonic-gate extern int mbtowc();
1950Sstevel@tonic-gate extern void qsort();
1960Sstevel@tonic-gate extern int rand();
1970Sstevel@tonic-gate extern void *realloc();
1980Sstevel@tonic-gate extern void srand();
1990Sstevel@tonic-gate extern double strtod();
2000Sstevel@tonic-gate extern long int strtol();
2010Sstevel@tonic-gate extern unsigned long strtoul();
2020Sstevel@tonic-gate extern int system();
2030Sstevel@tonic-gate extern int wctomb();
2040Sstevel@tonic-gate extern size_t wcstombs();
2050Sstevel@tonic-gate 
2060Sstevel@tonic-gate #endif	/* __STDC__ */
2070Sstevel@tonic-gate 
2080Sstevel@tonic-gate #if __cplusplus >= 199711L
2090Sstevel@tonic-gate }
2100Sstevel@tonic-gate #endif /* end of namespace std */
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate #ifdef	__cplusplus
2130Sstevel@tonic-gate }
2140Sstevel@tonic-gate #endif
2150Sstevel@tonic-gate 
2160Sstevel@tonic-gate #endif	/* _ISO_STDLIB_ISO_H */
217