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>
25 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
30 * An application should not include this header directly. Instead it
31 * should be included only through the inclusion of other Sun headers.
33 * The contents of this header is limited to identifiers specified in the
34 * C Standard. Any new identifiers specified in future amendments to the
35 * C Standard must be placed in this header. If these new identifiers
36 * are required to also be in the C++ Standard "std" namespace, then for
37 * anything other than macro definitions, corresponding "using" directives
38 * must also be added to <wchar.h>.
41 #ifndef _ISO_WCHAR_ISO_H
42 #define _ISO_WCHAR_ISO_H
44 #include <sys/feature_tests.h>
45 #include <stdio_tag.h>
46 #include <wchar_impl.h>
47 #include <iso/time_iso.h>
49 #if (defined(__cplusplus) && (__cplusplus - 0 < 54321L)) || \
50 (!defined(__cplusplus) && !defined(_STRICT_STDC)) || \
51 defined(__EXTENSIONS__)
53 #endif /* (defined(__cplusplus) && (__cplusplus - 0 < 54321L)) ... */
55 #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
58 #endif /* !defined(_STRICT_STDC) || defined(__EXTENSIONS__) */
60 #include <sys/va_list.h>
66 #if __cplusplus >= 199711L
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:
78 * we must use the C++ compiler's type
80 * The above comment should not be removed or changed until GNU
81 * gcc/fixinc/inclhack.def is updated to bypass this header.
83 #if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
91 #endif /* !_WCHAR_T */
92 #endif /* !defined(__cplusplus) ... */
94 #if !defined(_WINT_T) || __cplusplus >= 199711L
101 #endif /* !defined(_WINT_T) || __cplusplus >= 199711L */
103 #if !defined(_SIZE_T) || __cplusplus >= 199711L
105 #if defined(_LP64) || defined(_I32LPx)
106 typedef unsigned long size_t; /* size of something in bytes */
108 typedef unsigned int size_t; /* (historical version) */
110 #endif /* !defined(_SIZE_T) || __cplusplus >= 199711L */
121 #if __cplusplus >= 199711L
122 #define WEOF ((std::wint_t)(-1))
124 #define WEOF ((wint_t)(-1))
128 /* not XPG4 and not XPG4v2 */
129 #if !defined(_XPG4) || defined(_XPG5)
131 #define WCHAR_MAX 2147483647
134 #define WCHAR_MIN (-2147483647-1)
136 #endif /* not XPG4 and not XPG4v2 */
138 #if !defined(_MBSTATE_T) || __cplusplus >= 199711L
140 typedef __mbstate_t
mbstate_t;
141 #endif /* _MBSTATE_T */
143 #if defined(_XPG4) && !defined(_FILEDEFED) || __cplusplus >= 199711L
148 #if !defined(_LP64) && !defined(_LONGLONG_TYPE)
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
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
172 #endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */
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 extern wint_t __fgetwc_xpg5(__FILE
*);
189 extern wint_t __getwc_xpg5(__FILE
*);
190 extern wint_t __getwchar_xpg5(void);
191 extern wint_t __fputwc_xpg5(wint_t, __FILE
*);
192 extern wint_t __putwc_xpg5(wint_t, __FILE
*);
193 extern wint_t __putwchar_xpg5(wint_t);
194 extern wchar_t *__fgetws_xpg5(wchar_t *_RESTRICT_KYWD
, int,
195 __FILE
*_RESTRICT_KYWD
);
196 extern int __fputws_xpg5(const wchar_t *_RESTRICT_KYWD
, __FILE
*_RESTRICT_KYWD
);
197 extern wint_t __ungetwc_xpg5(wint_t, __FILE
*);
198 #define fgetwc __fgetwc_xpg5
199 #define getwc __getwc_xpg5
200 #define getwchar __getwchar_xpg5
201 #define fputwc __fputwc_xpg5
202 #define putwc __putwc_xpg5
203 #define putwchar __putwchar_xpg5
204 #define fgetws __fgetws_xpg5
205 #define fputws __fputws_xpg5
206 #define ungetwc __ungetwc_xpg5
207 #endif /* __PRAGMA_REDEFINE_EXTNAME */
208 #endif /* not XPG4 and not XPG4v2 */
209 #endif /* defined(_MSE_INT_H) */
211 extern wint_t fgetwc(__FILE
*);
212 extern wchar_t *fgetws(wchar_t *_RESTRICT_KYWD
, int, __FILE
*_RESTRICT_KYWD
);
213 extern wint_t fputwc(wint_t, __FILE
*);
214 extern int fputws(const wchar_t *_RESTRICT_KYWD
, __FILE
*_RESTRICT_KYWD
);
215 extern wint_t ungetwc(wint_t, __FILE
*);
216 extern wint_t getwc(__FILE
*);
217 extern wint_t getwchar(void);
218 extern wint_t putwc(wint_t, __FILE
*);
219 extern wint_t putwchar(wint_t);
220 extern double wcstod(const wchar_t *_RESTRICT_KYWD
, wchar_t **_RESTRICT_KYWD
);
221 extern long wcstol(const wchar_t *_RESTRICT_KYWD
, wchar_t **_RESTRICT_KYWD
,
223 extern unsigned long wcstoul(const wchar_t *_RESTRICT_KYWD
,
224 wchar_t **_RESTRICT_KYWD
, int);
225 extern wchar_t *wcscat(wchar_t *_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
);
226 extern int wcscmp(const wchar_t *, const wchar_t *);
227 extern int wcscoll(const wchar_t *, const wchar_t *);
228 extern wchar_t *wcscpy(wchar_t *_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
);
229 extern size_t wcscspn(const wchar_t *, const wchar_t *);
230 extern size_t wcslen(const wchar_t *);
231 extern wchar_t *wcsncat(wchar_t *_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
233 extern int wcsncmp(const wchar_t *, const wchar_t *, size_t);
234 extern wchar_t *wcsncpy(wchar_t *_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
236 extern size_t wcsspn(const wchar_t *, const wchar_t *);
237 extern size_t wcsxfrm(wchar_t *_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
239 #if __cplusplus >= 199711L
240 extern const wchar_t *wcschr(const wchar_t *, wchar_t);
242 inline wchar_t *wcschr(wchar_t *__ws
, wchar_t __wc
) {
243 return (wchar_t *)wcschr((const wchar_t *)__ws
, __wc
);
246 extern const wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
248 inline wchar_t *wcspbrk(wchar_t *__ws1
, const wchar_t *__ws2
) {
249 return (wchar_t *)wcspbrk((const wchar_t *)__ws1
, __ws2
);
252 extern const wchar_t *wcsrchr(const wchar_t *, wchar_t);
254 inline wchar_t *wcsrchr(wchar_t *__ws
, wchar_t __wc
) {
255 return (wchar_t *)wcsrchr((const wchar_t *)__ws
, __wc
);
258 #else /* __cplusplus >= 199711L */
259 extern wchar_t *wcschr(const wchar_t *, wchar_t);
260 extern wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
261 extern wchar_t *wcsrchr(const wchar_t *, wchar_t);
262 #endif /* __cplusplus >= 199711L */
264 #if (!defined(_MSE_INT_H))
265 #if defined(_XPG4) && !defined(_XPG5) /* XPG4 or XPG4v2 */
266 extern wchar_t *wcstok(wchar_t *, const wchar_t *);
267 extern size_t wcsftime(wchar_t *, size_t, const char *, const struct tm
*);
268 #else /* XPG4 or XPG4v2 */
269 #ifdef __PRAGMA_REDEFINE_EXTNAME
270 #pragma redefine_extname wcstok __wcstok_xpg5
271 #pragma redefine_extname wcsftime __wcsftime_xpg5
272 extern wchar_t *wcstok(wchar_t *_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
273 wchar_t **_RESTRICT_KYWD
);
274 extern size_t wcsftime(wchar_t *_RESTRICT_KYWD
, size_t,
275 const wchar_t *_RESTRICT_KYWD
, const struct tm
*_RESTRICT_KYWD
);
276 #else /* __PRAGMA_REDEFINE_EXTNAME */
277 extern wchar_t *__wcstok_xpg5(wchar_t *_RESTRICT_KYWD
,
278 const wchar_t *_RESTRICT_KYWD
, wchar_t **_RESTRICT_KYWD
);
279 extern size_t __wcsftime_xpg5(wchar_t *_RESTRICT_KYWD
, size_t,
280 const wchar_t *_RESTRICT_KYWD
, const struct tm
*_RESTRICT_KYWD
);
281 #define wcstok __wcstok_xpg5
282 #define wcsftime __wcsftime_xpg5
283 #endif /* __PRAGMA_REDEFINE_EXTNAME */
284 #endif /* XPG4 or XPG4v2 */
285 #endif /* !defined(_MSE_INT_H) */
287 /* not XPG4 and not XPG4v2 */
288 #if !defined(_XPG4) || defined(_XPG5)
289 extern wint_t btowc(int);
290 extern int fwprintf(__FILE
*_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
292 extern int fwscanf(__FILE
*_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
294 extern int fwide(__FILE
*, int);
295 extern int mbsinit(const mbstate_t *);
296 extern size_t mbrlen(const char *_RESTRICT_KYWD
, size_t,
297 mbstate_t *_RESTRICT_KYWD
);
298 extern size_t mbrtowc(wchar_t *_RESTRICT_KYWD
, const char *_RESTRICT_KYWD
,
299 size_t, mbstate_t *_RESTRICT_KYWD
);
300 extern size_t mbsrtowcs(wchar_t *_RESTRICT_KYWD
, const char **_RESTRICT_KYWD
,
301 size_t, mbstate_t *_RESTRICT_KYWD
);
302 extern int swprintf(wchar_t *_RESTRICT_KYWD
, size_t,
303 const wchar_t *_RESTRICT_KYWD
, ...);
304 extern int swscanf(const wchar_t *_RESTRICT_KYWD
,
305 const wchar_t *_RESTRICT_KYWD
, ...);
306 extern int vfwprintf(__FILE
*_RESTRICT_KYWD
, const wchar_t *_RESTRICT_KYWD
,
308 extern int vwprintf(const wchar_t *_RESTRICT_KYWD
, __va_list
);
309 extern int vswprintf(wchar_t *_RESTRICT_KYWD
, size_t,
310 const wchar_t *_RESTRICT_KYWD
, __va_list
);
311 extern size_t wcrtomb(char *_RESTRICT_KYWD
, wchar_t,
312 mbstate_t *_RESTRICT_KYWD
);
313 extern size_t wcsrtombs(char *_RESTRICT_KYWD
, const wchar_t **_RESTRICT_KYWD
,
314 size_t, mbstate_t *_RESTRICT_KYWD
);
315 #if defined(_XPG7) || !defined(_STRICT_SYMBOLS)
316 extern size_t wcsnrtombs(char *_RESTRICT_KYWD
, const wchar_t **_RESTRICT_KYWD
,
317 size_t, size_t, mbstate_t *_RESTRICT_KYWD
);
319 extern int wctob(wint_t);
320 extern int wmemcmp(const wchar_t *, const wchar_t *, size_t);
321 extern wchar_t *wmemcpy(wchar_t *_RESTRICT_KYWD
,
322 const wchar_t *_RESTRICT_KYWD
, size_t);
323 extern wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
324 extern wchar_t *wmemset(wchar_t *, wchar_t, size_t);
325 extern int wprintf(const wchar_t *_RESTRICT_KYWD
, ...);
326 extern int wscanf(const wchar_t *_RESTRICT_KYWD
, ...);
327 #if __cplusplus >= 199711L
328 extern const wchar_t *wcsstr(const wchar_t *, const wchar_t *);
330 inline wchar_t *wcsstr(wchar_t *__ws1
, const wchar_t *__ws2
) {
331 return (wchar_t *)wcsstr((const wchar_t *)__ws1
, __ws2
);
334 extern const wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
336 inline wchar_t *wmemchr(wchar_t *__ws
, wchar_t __wc
, size_t __n
) {
337 return (wchar_t *)wmemchr((const wchar_t *)__ws
, __wc
, __n
);
340 #else /* __cplusplus >= 199711L */
341 extern wchar_t *wcsstr(const wchar_t *_RESTRICT_KYWD
,
342 const wchar_t *_RESTRICT_KYWD
);
343 extern wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
344 #endif /* __cplusplus >= 199711L */
345 #endif /* not XPG4 and not XPG4v2 */
347 #if __cplusplus >= 199711L
349 #endif /* end of namespace std */
355 #endif /* _ISO_WCHAR_ISO_H */