xref: /titanic_52/usr/src/head/iso/wchar_iso.h (revision e6eb57e72471348376359efe9105d50bf487a312)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * An application should not include this header directly.  Instead it
29  * should be included only through the inclusion of other Sun headers.
30  *
31  * The contents of this header is limited to identifiers specified in the
32  * C Standard.  Any new identifiers specified in future amendments to the
33  * C Standard must be placed in this header.  If these new identifiers
34  * are required to also be in the C++ Standard "std" namespace, then for
35  * anything other than macro definitions, corresponding "using" directives
36  * must also be added to <wchar.h>.
37  */
38 
39 #ifndef	_ISO_WCHAR_ISO_H
40 #define	_ISO_WCHAR_ISO_H
41 
42 #pragma ident	"%Z%%M%	%I%	%E% SMI"
43 
44 #include <sys/feature_tests.h>
45 #include <stdio_tag.h>
46 #include <wchar_impl.h>
47 #include <iso/time_iso.h>
48 
49 #if (defined(__cplusplus) && (__cplusplus - 0 < 54321L)) || \
50 	(!defined(__cplusplus) && !defined(_STRICT_STDC)) || \
51 	defined(__EXTENSIONS__)
52 #include <stdio.h>
53 #endif  /*  (defined(__cplusplus) && (__cplusplus - 0 < 54321L)) ... */
54 
55 #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
56 #include <ctype.h>
57 #include <stddef.h>
58 #endif /* !defined(_STRICT_STDC) || defined(__EXTENSIONS__) */
59 
60 #include <sys/va_list.h>
61 
62 #ifdef	__cplusplus
63 extern "C" {
64 #endif
65 
66 #if __cplusplus >= 199711L
67 namespace std {
68 #endif
69 
70 /*
71  * wchar_t is a built-in type in standard C++ and as such is not
72  * defined here when using standard C++. However, the GNU compiler
73  * fixincludes utility nonetheless creates its own version of this
74  * header for use by gcc and g++. In that version it adds a redundant
75  * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
76  * header we need to include the following magic comment:
77  *
78  * we must use the C++ compiler's type
79  *
80  * The above comment should not be removed or changed until GNU
81  * gcc/fixinc/inclhack.def is updated to bypass this header.
82  */
83 #if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
84 #ifndef _WCHAR_T
85 #define	_WCHAR_T
86 #if defined(_LP64)
87 typedef	int	wchar_t;
88 #else
89 typedef	long	wchar_t;
90 #endif
91 #endif	/* !_WCHAR_T */
92 #endif	/* !defined(__cplusplus) ... */
93 
94 #if !defined(_WINT_T) || __cplusplus >= 199711L
95 #define	_WINT_T
96 #if defined(_LP64)
97 typedef	int	wint_t;
98 #else
99 typedef	long	wint_t;
100 #endif
101 #endif	/* !defined(_WINT_T) || __cplusplus >= 199711L */
102 
103 #if !defined(_SIZE_T) || __cplusplus >= 199711L
104 #define	_SIZE_T
105 #if defined(_LP64) || defined(_I32LPx)
106 typedef	unsigned long	size_t;		/* size of something in bytes */
107 #else
108 typedef unsigned int	size_t;		/* (historical version) */
109 #endif
110 #endif  /* !defined(_SIZE_T) || __cplusplus >= 199711L */
111 
112 #ifndef NULL
113 #if defined(_LP64)
114 #define	NULL	0L
115 #else
116 #define	NULL	0
117 #endif
118 #endif /* !NULL */
119 
120 #ifndef WEOF
121 #if __cplusplus >= 199711L
122 #define	WEOF	((std::wint_t)(-1))
123 #else
124 #define	WEOF	((wint_t)(-1))
125 #endif
126 #endif /* WEOF */
127 
128 /* not XPG4 and not XPG4v2 */
129 #if !defined(_XPG4) || defined(_XPG5)
130 #ifndef	WCHAR_MAX
131 #define	WCHAR_MAX	2147483647
132 #endif
133 #ifndef	WCHAR_MIN
134 #define	WCHAR_MIN	(-2147483647-1)
135 #endif
136 #endif /* not XPG4 and not XPG4v2 */
137 
138 #if !defined(_MBSTATE_T) || __cplusplus >= 199711L
139 #define	_MBSTATE_T
140 typedef __mbstate_t	mbstate_t;
141 #endif	/* _MBSTATE_T */
142 
143 #if defined(_XPG4) && !defined(_FILEDEFED) || __cplusplus >= 199711L
144 #define	_FILEDEFED
145 typedef __FILE FILE;
146 #endif
147 
148 #if !defined(_LP64) && !defined(_LONGLONG_TYPE)
149 
150 #ifdef __PRAGMA_REDEFINE_EXTNAME
151 #pragma	redefine_extname fwprintf	_fwprintf_c89
152 #pragma	redefine_extname swprintf	_swprintf_c89
153 #pragma	redefine_extname vfwprintf	_vfwprintf_c89
154 #pragma	redefine_extname vswprintf	_vswprintf_c89
155 #pragma	redefine_extname vwprintf	_vwprintf_c89
156 #pragma	redefine_extname wprintf	_wprintf_c89
157 #pragma	redefine_extname fwscanf	_fwscanf_c89
158 #pragma	redefine_extname swscanf	_swscanf_c89
159 #pragma	redefine_extname wscanf		_wscanf_c89
160 #else
161 #define	fwprintf	_fwprintf_c89
162 #define	swprintf	_swprintf_c89
163 #define	vfwprintf	_vfwprintf_c89
164 #define	vswprintf	_vswprintf_c89
165 #define	vwprintf	_vwprintf_c89
166 #define	wprintf		_wprintf_c89
167 #define	fwscanf		_fwscanf_c89
168 #define	swscanf		_swscanf_c89
169 #define	wscanf		_wscanf_c89
170 #endif
171 
172 #endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */
173 
174 #if (!defined(_MSE_INT_H))
175 /* not XPG4 and not XPG4v2 */
176 #if !defined(_XPG4) || defined(_XPG5)
177 #ifdef __PRAGMA_REDEFINE_EXTNAME
178 #pragma redefine_extname fgetwc	__fgetwc_xpg5
179 #pragma redefine_extname getwc	__getwc_xpg5
180 #pragma redefine_extname getwchar	__getwchar_xpg5
181 #pragma redefine_extname fputwc	__fputwc_xpg5
182 #pragma redefine_extname putwc	__putwc_xpg5
183 #pragma redefine_extname putwchar	__putwchar_xpg5
184 #pragma redefine_extname fgetws	__fgetws_xpg5
185 #pragma redefine_extname fputws	__fputws_xpg5
186 #pragma redefine_extname ungetwc	__ungetwc_xpg5
187 #else	/* __PRAGMA_REDEFINE_EXTNAME */
188 #ifdef __STDC__
189 extern wint_t __fgetwc_xpg5(__FILE *);
190 extern wint_t __getwc_xpg5(__FILE *);
191 extern wint_t __getwchar_xpg5(void);
192 extern wint_t __fputwc_xpg5(wint_t, __FILE *);
193 extern wint_t __putwc_xpg5(wint_t, __FILE *);
194 extern wint_t __putwchar_xpg5(wint_t);
195 extern wchar_t *__fgetws_xpg5(wchar_t *_RESTRICT_KYWD, int,
196 			__FILE *_RESTRICT_KYWD);
197 extern int __fputws_xpg5(const wchar_t *_RESTRICT_KYWD, __FILE *_RESTRICT_KYWD);
198 extern wint_t __ungetwc_xpg5(wint_t, __FILE *);
199 #else
200 extern wint_t __fgetwc_xpg5();
201 extern wint_t __getwc_xpg5();
202 extern wint_t __getwchar_xpg5();
203 extern wint_t __fputwc_xpg5();
204 extern wint_t __putwc_xpg5();
205 extern wint_t __putwchar_xpg5();
206 extern wchar_t *__fgetws_xpg5();
207 extern int __fputws_xpg5();
208 extern wint_t __ungetwc_xpg5();
209 #endif	/* __STDC__ */
210 #define	fgetwc	__fgetwc_xpg5
211 #define	getwc	__getwc_xpg5
212 #define	getwchar	__getwchar_xpg5
213 #define	fputwc	__fputwc_xpg5
214 #define	putwc	__putwc_xpg5
215 #define	putwchar	__putwchar_xpg5
216 #define	fgetws	__fgetws_xpg5
217 #define	fputws	__fputws_xpg5
218 #define	ungetwc	__ungetwc_xpg5
219 #endif	/* __PRAGMA_REDEFINE_EXTNAME */
220 #endif /* not XPG4 and not XPG4v2 */
221 #endif /* defined(_MSE_INT_H) */
222 
223 #ifdef __STDC__
224 
225 extern wint_t fgetwc(__FILE *);
226 extern wchar_t *fgetws(wchar_t *_RESTRICT_KYWD, int, __FILE *_RESTRICT_KYWD);
227 extern wint_t fputwc(wint_t, __FILE *);
228 extern int fputws(const wchar_t *_RESTRICT_KYWD, __FILE *_RESTRICT_KYWD);
229 extern wint_t ungetwc(wint_t, __FILE *);
230 extern wint_t getwc(__FILE *);
231 extern wint_t getwchar(void);
232 extern wint_t putwc(wint_t, __FILE *);
233 extern wint_t putwchar(wint_t);
234 extern double wcstod(const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD);
235 extern long wcstol(const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD,
236 	int);
237 extern unsigned long wcstoul(const wchar_t *_RESTRICT_KYWD,
238 	wchar_t **_RESTRICT_KYWD, int);
239 extern wchar_t *wcscat(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD);
240 extern int wcscmp(const wchar_t *, const wchar_t *);
241 extern int wcscoll(const wchar_t *, const wchar_t *);
242 extern wchar_t *wcscpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD);
243 extern size_t wcscspn(const wchar_t *, const wchar_t *);
244 extern size_t wcslen(const wchar_t *);
245 extern wchar_t *wcsncat(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
246 	size_t);
247 extern int wcsncmp(const wchar_t *, const wchar_t *, size_t);
248 extern wchar_t *wcsncpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
249 	size_t);
250 extern size_t wcsspn(const wchar_t *, const wchar_t *);
251 extern size_t wcsxfrm(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
252 	size_t);
253 #if __cplusplus >= 199711L
254 extern const wchar_t *wcschr(const wchar_t *, wchar_t);
255 extern "C++" {
256 	inline wchar_t *wcschr(wchar_t *__ws, wchar_t __wc) {
257 		return (wchar_t *)wcschr((const wchar_t *)__ws, __wc);
258 	}
259 }
260 extern const wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
261 extern "C++" {
262 	inline wchar_t *wcspbrk(wchar_t *__ws1, const wchar_t *__ws2) {
263 		return (wchar_t *)wcspbrk((const wchar_t *)__ws1, __ws2);
264 	}
265 }
266 extern const wchar_t *wcsrchr(const wchar_t *, wchar_t);
267 extern "C++" {
268 	inline wchar_t *wcsrchr(wchar_t *__ws, wchar_t __wc) {
269 		return (wchar_t *)wcsrchr((const wchar_t *)__ws, __wc);
270 	}
271 }
272 #else /* __cplusplus >= 199711L */
273 extern wchar_t *wcschr(const wchar_t *, wchar_t);
274 extern wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
275 extern wchar_t *wcsrchr(const wchar_t *, wchar_t);
276 #endif /* __cplusplus >= 199711L */
277 
278 #if (!defined(_MSE_INT_H))
279 #if defined(_XPG4) && !defined(_XPG5) /* XPG4 or XPG4v2 */
280 extern wchar_t *wcstok(wchar_t *, const wchar_t *);
281 extern size_t wcsftime(wchar_t *, size_t, const char *, const struct tm *);
282 #else	/* XPG4 or XPG4v2 */
283 #ifdef __PRAGMA_REDEFINE_EXTNAME
284 #pragma redefine_extname wcstok	__wcstok_xpg5
285 #pragma redefine_extname wcsftime	__wcsftime_xpg5
286 extern wchar_t *wcstok(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
287 	wchar_t **_RESTRICT_KYWD);
288 extern size_t wcsftime(wchar_t *_RESTRICT_KYWD, size_t,
289 	const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD);
290 #else	/* __PRAGMA_REDEFINE_EXTNAME */
291 extern wchar_t *__wcstok_xpg5(wchar_t *_RESTRICT_KYWD,
292 	const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD);
293 extern size_t __wcsftime_xpg5(wchar_t *_RESTRICT_KYWD, size_t,
294 	const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD);
295 #define	wcstok	__wcstok_xpg5
296 #define	wcsftime	__wcsftime_xpg5
297 #endif	/* __PRAGMA_REDEFINE_EXTNAME */
298 #endif	/* XPG4 or XPG4v2 */
299 #endif	/* !defined(_MSE_INT_H) */
300 
301 /* not XPG4 and not XPG4v2 */
302 #if !defined(_XPG4) || defined(_XPG5)
303 extern wint_t	btowc(int);
304 extern int	fwprintf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
305 			...);
306 extern int	fwscanf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
307 			...);
308 extern int	fwide(__FILE *, int);
309 extern int	mbsinit(const mbstate_t *);
310 extern size_t	mbrlen(const char *_RESTRICT_KYWD, size_t,
311 			mbstate_t *_RESTRICT_KYWD);
312 extern size_t	mbrtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
313 			size_t, mbstate_t *_RESTRICT_KYWD);
314 extern size_t	mbsrtowcs(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD,
315 			size_t, mbstate_t *_RESTRICT_KYWD);
316 extern int	swprintf(wchar_t *_RESTRICT_KYWD, size_t,
317 			const wchar_t *_RESTRICT_KYWD, ...);
318 extern int	swscanf(const wchar_t *_RESTRICT_KYWD,
319 			const wchar_t *_RESTRICT_KYWD, ...);
320 extern int	vfwprintf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
321 			__va_list);
322 extern int	vwprintf(const wchar_t *_RESTRICT_KYWD, __va_list);
323 extern int	vswprintf(wchar_t *_RESTRICT_KYWD, size_t,
324 			const wchar_t *_RESTRICT_KYWD, __va_list);
325 extern size_t	wcrtomb(char *_RESTRICT_KYWD, wchar_t,
326 			mbstate_t *_RESTRICT_KYWD);
327 extern size_t	wcsrtombs(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD,
328 			size_t, mbstate_t *_RESTRICT_KYWD);
329 extern int	wctob(wint_t);
330 extern int	wmemcmp(const wchar_t *, const wchar_t *, size_t);
331 extern wchar_t	*wmemcpy(wchar_t *_RESTRICT_KYWD,
332 			const wchar_t *_RESTRICT_KYWD, size_t);
333 extern wchar_t	*wmemmove(wchar_t *, const wchar_t *, size_t);
334 extern wchar_t	*wmemset(wchar_t *, wchar_t, size_t);
335 extern int	wprintf(const wchar_t *_RESTRICT_KYWD, ...);
336 extern int	wscanf(const wchar_t *_RESTRICT_KYWD, ...);
337 #if __cplusplus >= 199711L
338 extern const wchar_t *wcsstr(const wchar_t *, const wchar_t *);
339 extern "C++" {
340 	inline wchar_t *wcsstr(wchar_t *__ws1, const wchar_t *__ws2) {
341 		return (wchar_t *)wcsstr((const wchar_t *)__ws1, __ws2);
342 	}
343 }
344 extern const wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
345 extern "C++" {
346 	inline wchar_t *wmemchr(wchar_t *__ws, wchar_t __wc, size_t __n) {
347 		return (wchar_t *)wmemchr((const wchar_t *)__ws, __wc, __n);
348 	}
349 }
350 #else /* __cplusplus >= 199711L */
351 extern wchar_t	*wcsstr(const wchar_t *_RESTRICT_KYWD,
352 	const wchar_t *_RESTRICT_KYWD);
353 extern wchar_t	*wmemchr(const wchar_t *, wchar_t, size_t);
354 #endif /* __cplusplus >= 199711L */
355 #endif /* not XPG4 and not XPG4v2 */
356 
357 #else /* __STDC__ */
358 
359 extern  wint_t fgetwc();
360 extern  wchar_t *fgetws();
361 extern  wint_t fputwc();
362 extern  int fputws();
363 extern  wint_t  ungetwc();
364 extern wint_t getwc();
365 extern wint_t getwchar();
366 extern wint_t putwc();
367 extern wint_t putwchar();
368 extern wint_t ungetwc();
369 extern double wcstod();
370 extern long wcstol();
371 extern unsigned long wcstoul();
372 extern wchar_t *wcscat();
373 extern wchar_t *wcschr();
374 extern int wcscmp();
375 extern int wcscoll();
376 extern wchar_t *wcscpy();
377 extern size_t wcscspn();
378 extern size_t wcslen();
379 extern wchar_t *wcsncat();
380 extern int wcsncmp();
381 extern wchar_t *wcsncpy();
382 extern wchar_t *wcspbrk();
383 extern wchar_t *wcsrchr();
384 extern size_t wcsspn();
385 extern size_t wcsxfrm();
386 
387 #if (!defined(_MSE_INT_H))
388 #if defined(_XPG4) && !defined(_XPG5) /* XPG4 or XPG4v2 */
389 extern wchar_t *wcstok();
390 extern size_t wcsftime();
391 #else	/* XPG4 or XPG4v2 */
392 #ifdef __PRAGMA_REDEFINE_EXTNAME
393 #pragma redefine_extname wcstok	__wcstok_xpg5
394 #pragma redefine_extname wcsftime	__wcsftime_xpg5
395 extern wchar_t *wcstok();
396 extern size_t wcsftime();
397 #else	/* __PRAGMA_REDEFINE_EXTNAME */
398 extern wchar_t *__wcstok_xpg5();
399 extern size_t __wcsftime_xpg5();
400 #define	wcstok	__wcstok_xpg5
401 #define	wcsftime	__wcsftime_xpg5
402 #endif	/* __PRAGMA_REDEFINE_EXTNAME */
403 #endif	/* XPG4 or XPG4v2 */
404 #endif	/* defined(_MSE_INT_H) */
405 
406 /* not XPG4 and not XPG4v2 */
407 #if (!defined(_XPG4) && !defined(_XPG4_2) || defined(_XPG5))
408 extern wint_t	btowc();
409 extern int	fwprintf();
410 extern int	fwscanf();
411 extern int	fwide();
412 extern int	mbsinit();
413 extern size_t	mbrlen();
414 extern size_t	mbrtowc();
415 extern size_t	mbsrtowcs();
416 extern int	swprintf();
417 extern int	swscanf();
418 extern int	vfwprintf();
419 extern int	vwprintf();
420 extern int	vswprintf();
421 extern size_t	wcrtomb();
422 extern size_t	wcsrtombs();
423 extern wchar_t	*wcsstr();
424 extern int	wctob();
425 extern wchar_t	*wmemchr();
426 extern int	wmemcmp();
427 extern wchar_t	*wmemcpy();
428 extern wchar_t	*wmemmove();
429 extern wchar_t	*wmemset();
430 extern int	wprintf();
431 extern int	wscanf();
432 #endif /* not XPG4 and not XPG4v2 */
433 
434 #endif /* __STDC__ */
435 
436 #if __cplusplus >= 199711L
437 }
438 #endif /* end of namespace std */
439 
440 #ifdef	__cplusplus
441 }
442 #endif
443 
444 #endif	/* _ISO_WCHAR_ISO_H */
445