xref: /onnv-gate/usr/src/head/iso/stdlib_iso.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
28*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate /*
32*0Sstevel@tonic-gate  * An application should not include this header directly.  Instead it
33*0Sstevel@tonic-gate  * should be included only through the inclusion of other Sun headers.
34*0Sstevel@tonic-gate  *
35*0Sstevel@tonic-gate  * The contents of this header is limited to identifiers specified in the
36*0Sstevel@tonic-gate  * C Standard.  Any new identifiers specified in future amendments to the
37*0Sstevel@tonic-gate  * C Standard must be placed in this header.  If these new identifiers
38*0Sstevel@tonic-gate  * are required to also be in the C++ Standard "std" namespace, then for
39*0Sstevel@tonic-gate  * anything other than macro definitions, corresponding "using" directives
40*0Sstevel@tonic-gate  * must also be added to <locale.h>.
41*0Sstevel@tonic-gate  */
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate #ifndef _ISO_STDLIB_ISO_H
44*0Sstevel@tonic-gate #define	_ISO_STDLIB_ISO_H
45*0Sstevel@tonic-gate 
46*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate #include <sys/feature_tests.h>
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate #ifdef	__cplusplus
51*0Sstevel@tonic-gate extern "C" {
52*0Sstevel@tonic-gate #endif
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate #if defined(__STDC__)
55*0Sstevel@tonic-gate extern unsigned char	__ctype[];
56*0Sstevel@tonic-gate #define	MB_CUR_MAX	__ctype[520]
57*0Sstevel@tonic-gate #else
58*0Sstevel@tonic-gate extern unsigned char	_ctype[];
59*0Sstevel@tonic-gate #define	MB_CUR_MAX	_ctype[520]
60*0Sstevel@tonic-gate #endif
61*0Sstevel@tonic-gate 
62*0Sstevel@tonic-gate #if __cplusplus >= 199711L
63*0Sstevel@tonic-gate namespace std {
64*0Sstevel@tonic-gate #endif
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate typedef	struct {
67*0Sstevel@tonic-gate 	int	quot;
68*0Sstevel@tonic-gate 	int	rem;
69*0Sstevel@tonic-gate } div_t;
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate typedef struct {
72*0Sstevel@tonic-gate 	long	quot;
73*0Sstevel@tonic-gate 	long	rem;
74*0Sstevel@tonic-gate } ldiv_t;
75*0Sstevel@tonic-gate 
76*0Sstevel@tonic-gate #if !defined(_SIZE_T) || __cplusplus >= 199711L
77*0Sstevel@tonic-gate #define	_SIZE_T
78*0Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx)
79*0Sstevel@tonic-gate typedef unsigned long	size_t;		/* size of something in bytes */
80*0Sstevel@tonic-gate #else
81*0Sstevel@tonic-gate typedef unsigned int    size_t;		/* (historical version) */
82*0Sstevel@tonic-gate #endif
83*0Sstevel@tonic-gate #endif	/* !_SIZE_T */
84*0Sstevel@tonic-gate 
85*0Sstevel@tonic-gate #ifndef	NULL
86*0Sstevel@tonic-gate #if defined(_LP64)
87*0Sstevel@tonic-gate #define	NULL	0L
88*0Sstevel@tonic-gate #else
89*0Sstevel@tonic-gate #define	NULL	0
90*0Sstevel@tonic-gate #endif
91*0Sstevel@tonic-gate #endif
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate #define	EXIT_FAILURE	1
94*0Sstevel@tonic-gate #define	EXIT_SUCCESS    0
95*0Sstevel@tonic-gate #define	RAND_MAX	32767
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate /*
98*0Sstevel@tonic-gate  * wchar_t is a built-in type in standard C++ and as such is not
99*0Sstevel@tonic-gate  * defined here when using standard C++. However, the GNU compiler
100*0Sstevel@tonic-gate  * fixincludes utility nonetheless creates it's own version of this
101*0Sstevel@tonic-gate  * header for use by gcc and g++. In that version it adds a redundant
102*0Sstevel@tonic-gate  * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
103*0Sstevel@tonic-gate  * header we need to include the following magic comment:
104*0Sstevel@tonic-gate  *
105*0Sstevel@tonic-gate  * we must use the C++ compiler's type
106*0Sstevel@tonic-gate  *
107*0Sstevel@tonic-gate  * The above comment should not be removed or changed until GNU
108*0Sstevel@tonic-gate  * gcc/fixinc/inclhack.def is updated to bypass this header.
109*0Sstevel@tonic-gate  */
110*0Sstevel@tonic-gate #if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
111*0Sstevel@tonic-gate #ifndef _WCHAR_T
112*0Sstevel@tonic-gate #define	_WCHAR_T
113*0Sstevel@tonic-gate #if defined(_LP64)
114*0Sstevel@tonic-gate typedef	int	wchar_t;
115*0Sstevel@tonic-gate #else
116*0Sstevel@tonic-gate typedef long	wchar_t;
117*0Sstevel@tonic-gate #endif
118*0Sstevel@tonic-gate #endif	/* !_WCHAR_T */
119*0Sstevel@tonic-gate #endif	/* !defined(__cplusplus) ... */
120*0Sstevel@tonic-gate 
121*0Sstevel@tonic-gate #if defined(__STDC__)
122*0Sstevel@tonic-gate 
123*0Sstevel@tonic-gate extern void abort(void) __NORETURN;
124*0Sstevel@tonic-gate extern int abs(int);
125*0Sstevel@tonic-gate extern int atexit(void (*)(void));
126*0Sstevel@tonic-gate extern double atof(const char *);
127*0Sstevel@tonic-gate extern int atoi(const char *);
128*0Sstevel@tonic-gate extern long int atol(const char *);
129*0Sstevel@tonic-gate extern void *bsearch(const void *, const void *, size_t, size_t,
130*0Sstevel@tonic-gate 	int (*)(const void *, const void *));
131*0Sstevel@tonic-gate #if __cplusplus >= 199711L
132*0Sstevel@tonic-gate extern "C++" {
133*0Sstevel@tonic-gate 	void *bsearch(const void *, const void *, size_t, size_t,
134*0Sstevel@tonic-gate 		int (*)(const void *, const void *));
135*0Sstevel@tonic-gate }
136*0Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */
137*0Sstevel@tonic-gate extern void *calloc(size_t, size_t);
138*0Sstevel@tonic-gate extern div_t div(int, int);
139*0Sstevel@tonic-gate extern void exit(int)
140*0Sstevel@tonic-gate 	__NORETURN;
141*0Sstevel@tonic-gate extern void free(void *);
142*0Sstevel@tonic-gate extern char *getenv(const char *);
143*0Sstevel@tonic-gate extern long int labs(long);
144*0Sstevel@tonic-gate extern ldiv_t ldiv(long, long);
145*0Sstevel@tonic-gate extern void *malloc(size_t);
146*0Sstevel@tonic-gate extern int mblen(const char *, size_t);
147*0Sstevel@tonic-gate extern size_t mbstowcs(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
148*0Sstevel@tonic-gate 	size_t);
149*0Sstevel@tonic-gate extern int mbtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
150*0Sstevel@tonic-gate extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
151*0Sstevel@tonic-gate #if __cplusplus >= 199711L
152*0Sstevel@tonic-gate extern "C++" {
153*0Sstevel@tonic-gate 	void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
154*0Sstevel@tonic-gate }
155*0Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */
156*0Sstevel@tonic-gate extern int rand(void);
157*0Sstevel@tonic-gate extern void *realloc(void *, size_t);
158*0Sstevel@tonic-gate extern void srand(unsigned int);
159*0Sstevel@tonic-gate extern double strtod(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD);
160*0Sstevel@tonic-gate extern long int strtol(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD, int);
161*0Sstevel@tonic-gate extern unsigned long int strtoul(const char *_RESTRICT_KYWD,
162*0Sstevel@tonic-gate 	char **_RESTRICT_KYWD, int);
163*0Sstevel@tonic-gate extern int system(const char *);
164*0Sstevel@tonic-gate extern int wctomb(char *, wchar_t);
165*0Sstevel@tonic-gate extern size_t wcstombs(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
166*0Sstevel@tonic-gate 	size_t);
167*0Sstevel@tonic-gate 
168*0Sstevel@tonic-gate #if __cplusplus >= 199711L
169*0Sstevel@tonic-gate extern "C++" {
170*0Sstevel@tonic-gate 	inline long   abs(long _l) { return labs(_l); }
171*0Sstevel@tonic-gate 	inline ldiv_t div(long _l1, long _l2) { return ldiv(_l1, _l2); }
172*0Sstevel@tonic-gate }
173*0Sstevel@tonic-gate #endif /* __cplusplus */
174*0Sstevel@tonic-gate 
175*0Sstevel@tonic-gate #else /* not __STDC__ */
176*0Sstevel@tonic-gate 
177*0Sstevel@tonic-gate extern void abort();
178*0Sstevel@tonic-gate extern int abs();
179*0Sstevel@tonic-gate extern int atexit();
180*0Sstevel@tonic-gate extern double atof();
181*0Sstevel@tonic-gate extern int atoi();
182*0Sstevel@tonic-gate extern long int atol();
183*0Sstevel@tonic-gate extern void *bsearch();
184*0Sstevel@tonic-gate extern void *calloc();
185*0Sstevel@tonic-gate extern div_t div();
186*0Sstevel@tonic-gate extern void exit();
187*0Sstevel@tonic-gate extern void free();
188*0Sstevel@tonic-gate extern char *getenv();
189*0Sstevel@tonic-gate extern long int labs();
190*0Sstevel@tonic-gate extern ldiv_t ldiv();
191*0Sstevel@tonic-gate extern void *malloc();
192*0Sstevel@tonic-gate extern int mblen();
193*0Sstevel@tonic-gate extern size_t mbstowcs();
194*0Sstevel@tonic-gate extern int mbtowc();
195*0Sstevel@tonic-gate extern void qsort();
196*0Sstevel@tonic-gate extern int rand();
197*0Sstevel@tonic-gate extern void *realloc();
198*0Sstevel@tonic-gate extern void srand();
199*0Sstevel@tonic-gate extern double strtod();
200*0Sstevel@tonic-gate extern long int strtol();
201*0Sstevel@tonic-gate extern unsigned long strtoul();
202*0Sstevel@tonic-gate extern int system();
203*0Sstevel@tonic-gate extern int wctomb();
204*0Sstevel@tonic-gate extern size_t wcstombs();
205*0Sstevel@tonic-gate 
206*0Sstevel@tonic-gate #endif	/* __STDC__ */
207*0Sstevel@tonic-gate 
208*0Sstevel@tonic-gate #if __cplusplus >= 199711L
209*0Sstevel@tonic-gate }
210*0Sstevel@tonic-gate #endif /* end of namespace std */
211*0Sstevel@tonic-gate 
212*0Sstevel@tonic-gate #ifdef	__cplusplus
213*0Sstevel@tonic-gate }
214*0Sstevel@tonic-gate #endif
215*0Sstevel@tonic-gate 
216*0Sstevel@tonic-gate #endif	/* _ISO_STDLIB_ISO_H */
217