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.
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.
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]
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 * Copyright 2014 PALO, Richard.
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
31 * An application should not include this header directly. Instead it
32 * should be included only through the inclusion of other Sun headers.
34 * The contents of this header is limited to identifiers specified in the
35 * C Standard. Any new identifiers specified in future amendments to the
36 * C Standard must be placed in this header. If these new identifiers
37 * are required to also be in the C++ Standard "std" namespace, then for
38 * anything other than macro definitions, corresponding "using" directives
39 * must also be added to <wchar.h>.
42 #ifndef _ISO_WCHAR_ISO_H
43 #define _ISO_WCHAR_ISO_H
45 #include <sys/feature_tests.h>
47 #include <stdio_tag.h>
48 #include <wchar_impl.h>
49 #include <iso/time_iso.h>
51 #if (defined(__cplusplus) && (__cplusplus - 0 < 54321L)) || \
52 (!defined(__cplusplus) && !defined(_STRICT_STDC)) || \
53 defined(__EXTENSIONS__)
55 #endif /* (defined(__cplusplus) && (__cplusplus - 0 < 54321L)) ... */
57 #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
60 #endif /* !defined(_STRICT_STDC) || defined(__EXTENSIONS__) */
62 #include <sys/va_list.h>
68 #if __cplusplus >= 199711L
73 * wchar_t is a built-in type in standard C++ and as such is not
74 * defined here when using standard C++. However, the GNU compiler
75 * fixincludes utility nonetheless creates its own version of this
76 * header for use by gcc and g++. In that version it adds a redundant
77 * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
78 * header we need to include the following magic comment:
80 * we must use the C++ compiler's type
82 * The above comment should not be removed or changed until GNU
83 * gcc/fixinc/inclhack.def is updated to bypass this header.
85 #if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
93 #endif /* !_WCHAR_T */
94 #endif /* !defined(__cplusplus) ... */
96 #if !defined(_WINT_T) || __cplusplus >= 199711L
103 #endif /* !defined(_WINT_T) || __cplusplus >= 199711L */
105 #if !defined(_SIZE_T) || __cplusplus >= 199711L
107 #if defined(_LP64) || defined(_I32LPx)
108 typedef unsigned long size_t; /* size of something in bytes */
110 typedef unsigned int size_t; /* (historical version) */
112 #endif /* !defined(_SIZE_T) || __cplusplus >= 199711L */
115 #if __cplusplus >= 199711L
116 #define WEOF ((std::wint_t)(-1))
118 #define WEOF ((wint_t)(-1))
122 /* not XPG4 and not XPG4v2 */
123 #if !defined(_XPG4) || defined(_XPG5)
125 #define WCHAR_MAX 2147483647
128 #define WCHAR_MIN (-2147483647-1)
130 #endif /* not XPG4 and not XPG4v2 */
132 #if !defined(_MBSTATE_T) || __cplusplus >= 199711L
134 typedef __mbstate_t
mbstate_t;
135 #endif /* _MBSTATE_T */
137 #if defined(_XPG4) && !defined(_FILEDEFED) || __cplusplus >= 199711L
142 #if !defined(_LP64) && !defined(_LONGLONG_TYPE)
144 #ifdef __PRAGMA_REDEFINE_EXTNAME
145 #pragma redefine_extname fwprintf _fwprintf_c89
146 #pragma redefine_extname swprintf _swprintf_c89
147 #pragma redefine_extname vfwprintf _vfwprintf_c89
148 #pragma redefine_extname vswprintf _vswprintf_c89
149 #pragma redefine_extname vwprintf _vwprintf_c89
150 #pragma redefine_extname wprintf _wprintf_c89
151 #pragma redefine_extname fwscanf _fwscanf_c89
152 #pragma redefine_extname swscanf _swscanf_c89
153 #pragma redefine_extname wscanf _wscanf_c89
155 #define fwprintf _fwprintf_c89
156 #define swprintf _swprintf_c89
157 #define vfwprintf _vfwprintf_c89
158 #define vswprintf _vswprintf_c89
159 #define vwprintf _vwprintf_c89
160 #define wprintf _wprintf_c89
161 #define fwscanf _fwscanf_c89
162 #define swscanf _swscanf_c89
163 #define wscanf _wscanf_c89
166 #endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */
168 #if (!defined(_MSE_INT_H))
169 /* not XPG4 and not XPG4v2 */
170 #if !defined(_XPG4) || defined(_XPG5)
171 #ifdef __PRAGMA_REDEFINE_EXTNAME
172 #pragma redefine_extname fgetwc __fgetwc_xpg5
173 #pragma redefine_extname getwc __getwc_xpg5
174 #pragma redefine_extname getwchar __getwchar_xpg5
175 #pragma redefine_extname fputwc __fputwc_xpg5
176 #pragma redefine_extname putwc __putwc_xpg5
177 #pragma redefine_extname putwchar __putwchar_xpg5
178 #pragma redefine_extname fgetws __fgetws_xpg5
179 #pragma redefine_extname fputws __fputws_xpg5
180 #pragma redefine_extname ungetwc __ungetwc_xpg5
181 #else /* __PRAGMA_REDEFINE_EXTNAME */
182 extern wint_t __fgetwc_xpg5(__FILE
*);
183 extern wint_t __getwc_xpg5(__FILE
*);
184 extern wint_t __getwchar_xpg5(void);
185 extern wint_t __fputwc_xpg5(wint_t, __FILE
*);
186 extern wint_t __putwc_xpg5(wint_t, __FILE
*);
187 extern wint_t __putwchar_xpg5(wint_t);
188 extern wchar_t *__fgetws_xpg5(wchar_t *_RESTRICT_KYWD
, int,
189 __FILE
*_RESTRICT_KYWD
);
190 extern int __fputws_xpg5(const wchar_t *_RESTRICT_KYWD
, __FILE
*_RESTRICT_KYWD
);
191 extern wint_t __ungetwc_xpg5(wint_t, __FILE
*);
192 #define fgetwc __fgetwc_xpg5
193 #define getwc __getwc_xpg5
194 #define getwchar __getwchar_xpg5
195 #define fputwc __fputwc_xpg5
196 #define putwc __putwc_xpg5
197 #define putwchar __putwchar_xpg5
198 #define fgetws __fgetws_xpg5
199 #define fputws __fputws_xpg5
200 #define ungetwc __ungetwc_xpg5
201 #endif /* __PRAGMA_REDEFINE_EXTNAME */
202 #endif /* not XPG4 and not XPG4v2 */
203 #endif /* defined(_MSE_INT_H) */
205 extern wint_t fgetwc(__FILE
*);
206 extern wchar_t *fgetws(wchar_t *_RESTRICT_KYWD
, int, __FILE
*_RESTRICT_KYWD
);
207 extern wint_t fputwc(wint_t, __FILE
*);
208 extern int fputws(const wchar_t *_RESTRICT_KYWD
, __FILE
*_RESTRICT_KYWD
);
209 extern wint_t ungetwc(wint_t, __FILE
*);
210 extern wint_t getwc(__FILE
*);
211 extern wint_t getwchar(void);
212 extern wint_t putwc(wint_t, __FILE
*);
213 extern wint_t putwchar(wint_t);
214 extern double wcstod(const wchar_t *_RESTRICT_KYWD
, wchar_t **_RESTRICT_KYWD
);
215 extern long wcstol(const wchar_t *_RESTRICT_KYWD
, wchar_t **_RESTRICT_KYWD
,
217 extern unsigned long wcstoul(const wchar_t *_RESTRICT_KYWD
,
218 wchar_t **_RESTRICT_KYWD
, int);
219 extern wchar_t *wcscat(wchar_t *_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
);
220 extern int wcscmp(const wchar_t *, const wchar_t *);
221 extern int wcscoll(const wchar_t *, const wchar_t *);
222 extern wchar_t *wcscpy(wchar_t *_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
);
223 extern size_t wcscspn(const wchar_t *, const wchar_t *);
224 extern size_t wcslen(const wchar_t *);
225 extern wchar_t *wcsncat(wchar_t *_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
227 extern int wcsncmp(const wchar_t *, const wchar_t *, size_t);
228 extern wchar_t *wcsncpy(wchar_t *_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
230 extern size_t wcsspn(const wchar_t *, const wchar_t *);
231 extern size_t wcsxfrm(wchar_t *_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
233 #if __cplusplus >= 199711L
234 extern const wchar_t *wcschr(const wchar_t *, wchar_t);
236 inline wchar_t *wcschr(wchar_t *__ws
, wchar_t __wc
) {
237 return (wchar_t *)wcschr((const wchar_t *)__ws
, __wc
);
240 extern const wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
242 inline wchar_t *wcspbrk(wchar_t *__ws1
, const wchar_t *__ws2
) {
243 return (wchar_t *)wcspbrk((const wchar_t *)__ws1
, __ws2
);
246 extern const wchar_t *wcsrchr(const wchar_t *, wchar_t);
248 inline wchar_t *wcsrchr(wchar_t *__ws
, wchar_t __wc
) {
249 return (wchar_t *)wcsrchr((const wchar_t *)__ws
, __wc
);
252 #else /* __cplusplus >= 199711L */
253 extern wchar_t *wcschr(const wchar_t *, wchar_t);
254 extern wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
255 extern wchar_t *wcsrchr(const wchar_t *, wchar_t);
256 #endif /* __cplusplus >= 199711L */
258 #if (!defined(_MSE_INT_H))
259 #if defined(_XPG4) && !defined(_XPG5) /* XPG4 or XPG4v2 */
260 extern wchar_t *wcstok(wchar_t *, const wchar_t *);
261 extern size_t wcsftime(wchar_t *, size_t, const char *, const struct tm
*);
262 #else /* XPG4 or XPG4v2 */
263 #ifdef __PRAGMA_REDEFINE_EXTNAME
264 #pragma redefine_extname wcstok __wcstok_xpg5
265 #pragma redefine_extname wcsftime __wcsftime_xpg5
266 extern wchar_t *wcstok(wchar_t *_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
267 wchar_t **_RESTRICT_KYWD
);
268 extern size_t wcsftime(wchar_t *_RESTRICT_KYWD
, size_t,
269 const wchar_t *_RESTRICT_KYWD
, const struct tm
*_RESTRICT_KYWD
);
270 #else /* __PRAGMA_REDEFINE_EXTNAME */
271 extern wchar_t *__wcstok_xpg5(wchar_t *_RESTRICT_KYWD
,
272 const wchar_t *_RESTRICT_KYWD
, wchar_t **_RESTRICT_KYWD
);
273 extern size_t __wcsftime_xpg5(wchar_t *_RESTRICT_KYWD
, size_t,
274 const wchar_t *_RESTRICT_KYWD
, const struct tm
*_RESTRICT_KYWD
);
275 #define wcstok __wcstok_xpg5
276 #define wcsftime __wcsftime_xpg5
277 #endif /* __PRAGMA_REDEFINE_EXTNAME */
278 #endif /* XPG4 or XPG4v2 */
279 #endif /* !defined(_MSE_INT_H) */
281 /* not XPG4 and not XPG4v2 */
282 #if !defined(_XPG4) || defined(_XPG5)
283 extern wint_t btowc(int);
284 extern int fwprintf(__FILE
*_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
286 extern int fwscanf(__FILE
*_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
288 extern int fwide(__FILE
*, int);
289 extern int mbsinit(const mbstate_t *);
290 extern size_t mbrlen(const char *_RESTRICT_KYWD
, size_t,
291 mbstate_t *_RESTRICT_KYWD
);
292 extern size_t mbrtowc(wchar_t *_RESTRICT_KYWD
, const char *_RESTRICT_KYWD
,
293 size_t, mbstate_t *_RESTRICT_KYWD
);
294 extern size_t mbsrtowcs(wchar_t *_RESTRICT_KYWD
, const char **_RESTRICT_KYWD
,
295 size_t, mbstate_t *_RESTRICT_KYWD
);
296 extern int swprintf(wchar_t *_RESTRICT_KYWD
, size_t,
297 const wchar_t *_RESTRICT_KYWD
, ...);
298 extern int swscanf(const wchar_t *_RESTRICT_KYWD
,
299 const wchar_t *_RESTRICT_KYWD
, ...);
300 extern int vfwprintf(__FILE
*_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
302 extern int vwprintf(const wchar_t *_RESTRICT_KYWD
, __va_list
);
303 extern int vswprintf(wchar_t *_RESTRICT_KYWD
, size_t,
304 const wchar_t *_RESTRICT_KYWD
, __va_list
);
305 extern size_t wcrtomb(char *_RESTRICT_KYWD
, wchar_t,
306 mbstate_t *_RESTRICT_KYWD
);
307 extern size_t wcsrtombs(char *_RESTRICT_KYWD
, const wchar_t **_RESTRICT_KYWD
,
308 size_t, mbstate_t *_RESTRICT_KYWD
);
309 #if defined(_XPG7) || !defined(_STRICT_SYMBOLS)
310 extern size_t wcsnrtombs(char *_RESTRICT_KYWD
, const wchar_t **_RESTRICT_KYWD
,
311 size_t, size_t, mbstate_t *_RESTRICT_KYWD
);
313 extern int wctob(wint_t);
314 extern int wmemcmp(const wchar_t *, const wchar_t *, size_t);
315 extern wchar_t *wmemcpy(wchar_t *_RESTRICT_KYWD
,
316 const wchar_t *_RESTRICT_KYWD
, size_t);
317 extern wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
318 extern wchar_t *wmemset(wchar_t *, wchar_t, size_t);
319 extern int wprintf(const wchar_t *_RESTRICT_KYWD
, ...);
320 extern int wscanf(const wchar_t *_RESTRICT_KYWD
, ...);
321 #if __cplusplus >= 199711L
322 extern const wchar_t *wcsstr(const wchar_t *, const wchar_t *);
324 inline wchar_t *wcsstr(wchar_t *__ws1
, const wchar_t *__ws2
) {
325 return (wchar_t *)wcsstr((const wchar_t *)__ws1
, __ws2
);
328 extern const wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
330 inline wchar_t *wmemchr(wchar_t *__ws
, wchar_t __wc
, size_t __n
) {
331 return (wchar_t *)wmemchr((const wchar_t *)__ws
, __wc
, __n
);
334 #else /* __cplusplus >= 199711L */
335 extern wchar_t *wcsstr(const wchar_t *_RESTRICT_KYWD
,
336 const wchar_t *_RESTRICT_KYWD
);
337 extern wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
338 #endif /* __cplusplus >= 199711L */
339 #endif /* not XPG4 and not XPG4v2 */
341 #if __cplusplus >= 199711L
343 #endif /* end of namespace std */
349 #endif /* _ISO_WCHAR_ISO_H */