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