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 * Copyright 2014 Garrett D'Amore <garrett@damore.org> 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 <wchar.h>. 41 */ 42 43 #ifndef _ISO_WCHAR_ISO_H 44 #define _ISO_WCHAR_ISO_H 45 46 #include <sys/feature_tests.h> 47 #include <stdio_tag.h> 48 #include <wchar_impl.h> 49 #include <iso/time_iso.h> 50 51 #if (defined(__cplusplus) && (__cplusplus - 0 < 54321L)) || \ 52 (!defined(__cplusplus) && !defined(_STRICT_STDC)) || \ 53 defined(__EXTENSIONS__) 54 #include <stdio.h> 55 #endif /* (defined(__cplusplus) && (__cplusplus - 0 < 54321L)) ... */ 56 57 #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__) 58 #include <ctype.h> 59 #include <stddef.h> 60 #endif /* !defined(_STRICT_STDC) || defined(__EXTENSIONS__) */ 61 62 #include <sys/va_list.h> 63 64 #ifdef __cplusplus 65 extern "C" { 66 #endif 67 68 #if __cplusplus >= 199711L 69 namespace std { 70 #endif 71 72 /* 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: 79 * 80 * we must use the C++ compiler's type 81 * 82 * The above comment should not be removed or changed until GNU 83 * gcc/fixinc/inclhack.def is updated to bypass this header. 84 */ 85 #if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__)) 86 #ifndef _WCHAR_T 87 #define _WCHAR_T 88 #if defined(_LP64) 89 typedef int wchar_t; 90 #else 91 typedef long wchar_t; 92 #endif 93 #endif /* !_WCHAR_T */ 94 #endif /* !defined(__cplusplus) ... */ 95 96 #if !defined(_WINT_T) || __cplusplus >= 199711L 97 #define _WINT_T 98 #if defined(_LP64) 99 typedef int wint_t; 100 #else 101 typedef long wint_t; 102 #endif 103 #endif /* !defined(_WINT_T) || __cplusplus >= 199711L */ 104 105 #if !defined(_SIZE_T) || __cplusplus >= 199711L 106 #define _SIZE_T 107 #if defined(_LP64) || defined(_I32LPx) 108 typedef unsigned long size_t; /* size of something in bytes */ 109 #else 110 typedef unsigned int size_t; /* (historical version) */ 111 #endif 112 #endif /* !defined(_SIZE_T) || __cplusplus >= 199711L */ 113 114 #ifndef NULL 115 #if defined(_LP64) 116 #define NULL 0L 117 #else 118 #define NULL 0 119 #endif 120 #endif /* !NULL */ 121 122 #ifndef WEOF 123 #if __cplusplus >= 199711L 124 #define WEOF ((std::wint_t)(-1)) 125 #else 126 #define WEOF ((wint_t)(-1)) 127 #endif 128 #endif /* WEOF */ 129 130 /* not XPG4 and not XPG4v2 */ 131 #if !defined(_XPG4) || defined(_XPG5) 132 #ifndef WCHAR_MAX 133 #define WCHAR_MAX 2147483647 134 #endif 135 #ifndef WCHAR_MIN 136 #define WCHAR_MIN (-2147483647-1) 137 #endif 138 #endif /* not XPG4 and not XPG4v2 */ 139 140 #if !defined(_MBSTATE_T) || __cplusplus >= 199711L 141 #define _MBSTATE_T 142 typedef __mbstate_t mbstate_t; 143 #endif /* _MBSTATE_T */ 144 145 #if defined(_XPG4) && !defined(_FILEDEFED) || __cplusplus >= 199711L 146 #define _FILEDEFED 147 typedef __FILE FILE; 148 #endif 149 150 #if !defined(_LP64) && !defined(_LONGLONG_TYPE) 151 152 #ifdef __PRAGMA_REDEFINE_EXTNAME 153 #pragma redefine_extname fwprintf _fwprintf_c89 154 #pragma redefine_extname swprintf _swprintf_c89 155 #pragma redefine_extname vfwprintf _vfwprintf_c89 156 #pragma redefine_extname vswprintf _vswprintf_c89 157 #pragma redefine_extname vwprintf _vwprintf_c89 158 #pragma redefine_extname wprintf _wprintf_c89 159 #pragma redefine_extname fwscanf _fwscanf_c89 160 #pragma redefine_extname swscanf _swscanf_c89 161 #pragma redefine_extname wscanf _wscanf_c89 162 #else 163 #define fwprintf _fwprintf_c89 164 #define swprintf _swprintf_c89 165 #define vfwprintf _vfwprintf_c89 166 #define vswprintf _vswprintf_c89 167 #define vwprintf _vwprintf_c89 168 #define wprintf _wprintf_c89 169 #define fwscanf _fwscanf_c89 170 #define swscanf _swscanf_c89 171 #define wscanf _wscanf_c89 172 #endif 173 174 #endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */ 175 176 #if (!defined(_MSE_INT_H)) 177 /* not XPG4 and not XPG4v2 */ 178 #if !defined(_XPG4) || defined(_XPG5) 179 #ifdef __PRAGMA_REDEFINE_EXTNAME 180 #pragma redefine_extname fgetwc __fgetwc_xpg5 181 #pragma redefine_extname getwc __getwc_xpg5 182 #pragma redefine_extname getwchar __getwchar_xpg5 183 #pragma redefine_extname fputwc __fputwc_xpg5 184 #pragma redefine_extname putwc __putwc_xpg5 185 #pragma redefine_extname putwchar __putwchar_xpg5 186 #pragma redefine_extname fgetws __fgetws_xpg5 187 #pragma redefine_extname fputws __fputws_xpg5 188 #pragma redefine_extname ungetwc __ungetwc_xpg5 189 #else /* __PRAGMA_REDEFINE_EXTNAME */ 190 #ifdef __STDC__ 191 extern wint_t __fgetwc_xpg5(__FILE *); 192 extern wint_t __getwc_xpg5(__FILE *); 193 extern wint_t __getwchar_xpg5(void); 194 extern wint_t __fputwc_xpg5(wint_t, __FILE *); 195 extern wint_t __putwc_xpg5(wint_t, __FILE *); 196 extern wint_t __putwchar_xpg5(wint_t); 197 extern wchar_t *__fgetws_xpg5(wchar_t *_RESTRICT_KYWD, int, 198 __FILE *_RESTRICT_KYWD); 199 extern int __fputws_xpg5(const wchar_t *_RESTRICT_KYWD, __FILE *_RESTRICT_KYWD); 200 extern wint_t __ungetwc_xpg5(wint_t, __FILE *); 201 #else 202 extern wint_t __fgetwc_xpg5(); 203 extern wint_t __getwc_xpg5(); 204 extern wint_t __getwchar_xpg5(); 205 extern wint_t __fputwc_xpg5(); 206 extern wint_t __putwc_xpg5(); 207 extern wint_t __putwchar_xpg5(); 208 extern wchar_t *__fgetws_xpg5(); 209 extern int __fputws_xpg5(); 210 extern wint_t __ungetwc_xpg5(); 211 #endif /* __STDC__ */ 212 #define fgetwc __fgetwc_xpg5 213 #define getwc __getwc_xpg5 214 #define getwchar __getwchar_xpg5 215 #define fputwc __fputwc_xpg5 216 #define putwc __putwc_xpg5 217 #define putwchar __putwchar_xpg5 218 #define fgetws __fgetws_xpg5 219 #define fputws __fputws_xpg5 220 #define ungetwc __ungetwc_xpg5 221 #endif /* __PRAGMA_REDEFINE_EXTNAME */ 222 #endif /* not XPG4 and not XPG4v2 */ 223 #endif /* defined(_MSE_INT_H) */ 224 225 #ifdef __STDC__ 226 227 extern wint_t fgetwc(__FILE *); 228 extern wchar_t *fgetws(wchar_t *_RESTRICT_KYWD, int, __FILE *_RESTRICT_KYWD); 229 extern wint_t fputwc(wint_t, __FILE *); 230 extern int fputws(const wchar_t *_RESTRICT_KYWD, __FILE *_RESTRICT_KYWD); 231 extern wint_t ungetwc(wint_t, __FILE *); 232 extern wint_t getwc(__FILE *); 233 extern wint_t getwchar(void); 234 extern wint_t putwc(wint_t, __FILE *); 235 extern wint_t putwchar(wint_t); 236 extern double wcstod(const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD); 237 extern long wcstol(const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD, 238 int); 239 extern unsigned long wcstoul(const wchar_t *_RESTRICT_KYWD, 240 wchar_t **_RESTRICT_KYWD, int); 241 extern wchar_t *wcscat(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD); 242 extern int wcscmp(const wchar_t *, const wchar_t *); 243 extern int wcscoll(const wchar_t *, const wchar_t *); 244 extern wchar_t *wcscpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD); 245 extern size_t wcscspn(const wchar_t *, const wchar_t *); 246 extern size_t wcslen(const wchar_t *); 247 extern wchar_t *wcsncat(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, 248 size_t); 249 extern int wcsncmp(const wchar_t *, const wchar_t *, size_t); 250 extern wchar_t *wcsncpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, 251 size_t); 252 extern size_t wcsspn(const wchar_t *, const wchar_t *); 253 extern size_t wcsxfrm(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, 254 size_t); 255 #if __cplusplus >= 199711L 256 extern const wchar_t *wcschr(const wchar_t *, wchar_t); 257 extern "C++" { 258 inline wchar_t *wcschr(wchar_t *__ws, wchar_t __wc) { 259 return (wchar_t *)wcschr((const wchar_t *)__ws, __wc); 260 } 261 } 262 extern const wchar_t *wcspbrk(const wchar_t *, const wchar_t *); 263 extern "C++" { 264 inline wchar_t *wcspbrk(wchar_t *__ws1, const wchar_t *__ws2) { 265 return (wchar_t *)wcspbrk((const wchar_t *)__ws1, __ws2); 266 } 267 } 268 extern const wchar_t *wcsrchr(const wchar_t *, wchar_t); 269 extern "C++" { 270 inline wchar_t *wcsrchr(wchar_t *__ws, wchar_t __wc) { 271 return (wchar_t *)wcsrchr((const wchar_t *)__ws, __wc); 272 } 273 } 274 #else /* __cplusplus >= 199711L */ 275 extern wchar_t *wcschr(const wchar_t *, wchar_t); 276 extern wchar_t *wcspbrk(const wchar_t *, const wchar_t *); 277 extern wchar_t *wcsrchr(const wchar_t *, wchar_t); 278 #endif /* __cplusplus >= 199711L */ 279 280 #if (!defined(_MSE_INT_H)) 281 #if defined(_XPG4) && !defined(_XPG5) /* XPG4 or XPG4v2 */ 282 extern wchar_t *wcstok(wchar_t *, const wchar_t *); 283 extern size_t wcsftime(wchar_t *, size_t, const char *, const struct tm *); 284 #else /* XPG4 or XPG4v2 */ 285 #ifdef __PRAGMA_REDEFINE_EXTNAME 286 #pragma redefine_extname wcstok __wcstok_xpg5 287 #pragma redefine_extname wcsftime __wcsftime_xpg5 288 extern wchar_t *wcstok(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, 289 wchar_t **_RESTRICT_KYWD); 290 extern size_t wcsftime(wchar_t *_RESTRICT_KYWD, size_t, 291 const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD); 292 #else /* __PRAGMA_REDEFINE_EXTNAME */ 293 extern wchar_t *__wcstok_xpg5(wchar_t *_RESTRICT_KYWD, 294 const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD); 295 extern size_t __wcsftime_xpg5(wchar_t *_RESTRICT_KYWD, size_t, 296 const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD); 297 #define wcstok __wcstok_xpg5 298 #define wcsftime __wcsftime_xpg5 299 #endif /* __PRAGMA_REDEFINE_EXTNAME */ 300 #endif /* XPG4 or XPG4v2 */ 301 #endif /* !defined(_MSE_INT_H) */ 302 303 /* not XPG4 and not XPG4v2 */ 304 #if !defined(_XPG4) || defined(_XPG5) 305 extern wint_t btowc(int); 306 extern int fwprintf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, 307 ...); 308 extern int fwscanf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, 309 ...); 310 extern int fwide(__FILE *, int); 311 extern int mbsinit(const mbstate_t *); 312 extern size_t mbrlen(const char *_RESTRICT_KYWD, size_t, 313 mbstate_t *_RESTRICT_KYWD); 314 extern size_t mbrtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, 315 size_t, mbstate_t *_RESTRICT_KYWD); 316 extern size_t mbsrtowcs(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD, 317 size_t, mbstate_t *_RESTRICT_KYWD); 318 extern int swprintf(wchar_t *_RESTRICT_KYWD, size_t, 319 const wchar_t *_RESTRICT_KYWD, ...); 320 extern int swscanf(const wchar_t *_RESTRICT_KYWD, 321 const wchar_t *_RESTRICT_KYWD, ...); 322 extern int vfwprintf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, 323 __va_list); 324 extern int vwprintf(const wchar_t *_RESTRICT_KYWD, __va_list); 325 extern int vswprintf(wchar_t *_RESTRICT_KYWD, size_t, 326 const wchar_t *_RESTRICT_KYWD, __va_list); 327 extern size_t wcrtomb(char *_RESTRICT_KYWD, wchar_t, 328 mbstate_t *_RESTRICT_KYWD); 329 extern size_t wcsrtombs(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD, 330 size_t, mbstate_t *_RESTRICT_KYWD); 331 #if defined(_XPG7) || !defined(_STRICT_SYMBOLS) 332 extern size_t wcsnrtombs(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD, 333 size_t, size_t, mbstate_t *_RESTRICT_KYWD); 334 #endif 335 extern int wctob(wint_t); 336 extern int wmemcmp(const wchar_t *, const wchar_t *, size_t); 337 extern wchar_t *wmemcpy(wchar_t *_RESTRICT_KYWD, 338 const wchar_t *_RESTRICT_KYWD, size_t); 339 extern wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t); 340 extern wchar_t *wmemset(wchar_t *, wchar_t, size_t); 341 extern int wprintf(const wchar_t *_RESTRICT_KYWD, ...); 342 extern int wscanf(const wchar_t *_RESTRICT_KYWD, ...); 343 #if __cplusplus >= 199711L 344 extern const wchar_t *wcsstr(const wchar_t *, const wchar_t *); 345 extern "C++" { 346 inline wchar_t *wcsstr(wchar_t *__ws1, const wchar_t *__ws2) { 347 return (wchar_t *)wcsstr((const wchar_t *)__ws1, __ws2); 348 } 349 } 350 extern const wchar_t *wmemchr(const wchar_t *, wchar_t, size_t); 351 extern "C++" { 352 inline wchar_t *wmemchr(wchar_t *__ws, wchar_t __wc, size_t __n) { 353 return (wchar_t *)wmemchr((const wchar_t *)__ws, __wc, __n); 354 } 355 } 356 #else /* __cplusplus >= 199711L */ 357 extern wchar_t *wcsstr(const wchar_t *_RESTRICT_KYWD, 358 const wchar_t *_RESTRICT_KYWD); 359 extern wchar_t *wmemchr(const wchar_t *, wchar_t, size_t); 360 #endif /* __cplusplus >= 199711L */ 361 #endif /* not XPG4 and not XPG4v2 */ 362 363 #else /* __STDC__ */ 364 365 extern wint_t fgetwc(); 366 extern wchar_t *fgetws(); 367 extern wint_t fputwc(); 368 extern int fputws(); 369 extern wint_t ungetwc(); 370 extern wint_t getwc(); 371 extern wint_t getwchar(); 372 extern wint_t putwc(); 373 extern wint_t putwchar(); 374 extern wint_t ungetwc(); 375 extern double wcstod(); 376 extern long wcstol(); 377 extern unsigned long wcstoul(); 378 extern wchar_t *wcscat(); 379 extern wchar_t *wcschr(); 380 extern int wcscmp(); 381 extern int wcscoll(); 382 extern wchar_t *wcscpy(); 383 extern size_t wcscspn(); 384 extern size_t wcslen(); 385 extern wchar_t *wcsncat(); 386 extern int wcsncmp(); 387 extern wchar_t *wcsncpy(); 388 extern wchar_t *wcspbrk(); 389 extern wchar_t *wcsrchr(); 390 extern size_t wcsspn(); 391 extern size_t wcsxfrm(); 392 393 #if (!defined(_MSE_INT_H)) 394 #if defined(_XPG4) && !defined(_XPG5) /* XPG4 or XPG4v2 */ 395 extern wchar_t *wcstok(); 396 extern size_t wcsftime(); 397 #else /* XPG4 or XPG4v2 */ 398 #ifdef __PRAGMA_REDEFINE_EXTNAME 399 #pragma redefine_extname wcstok __wcstok_xpg5 400 #pragma redefine_extname wcsftime __wcsftime_xpg5 401 extern wchar_t *wcstok(); 402 extern size_t wcsftime(); 403 #else /* __PRAGMA_REDEFINE_EXTNAME */ 404 extern wchar_t *__wcstok_xpg5(); 405 extern size_t __wcsftime_xpg5(); 406 #define wcstok __wcstok_xpg5 407 #define wcsftime __wcsftime_xpg5 408 #endif /* __PRAGMA_REDEFINE_EXTNAME */ 409 #endif /* XPG4 or XPG4v2 */ 410 #endif /* defined(_MSE_INT_H) */ 411 412 /* not XPG4 and not XPG4v2 */ 413 #if (!defined(_XPG4) && !defined(_XPG4_2) || defined(_XPG5)) 414 extern wint_t btowc(); 415 extern int fwprintf(); 416 extern int fwscanf(); 417 extern int fwide(); 418 extern int mbsinit(); 419 extern size_t mbrlen(); 420 extern size_t mbrtowc(); 421 extern size_t mbsrtowcs(); 422 extern int swprintf(); 423 extern int swscanf(); 424 extern int vfwprintf(); 425 extern int vwprintf(); 426 extern int vswprintf(); 427 extern size_t wcrtomb(); 428 extern size_t wcsrtombs(); 429 #if defined(_XPG7) || !defined(_STRICT_SYMBOLS) 430 extern size_t wcsnrtombs(); 431 #endif 432 433 extern wchar_t *wcsstr(); 434 extern int wctob(); 435 extern wchar_t *wmemchr(); 436 extern int wmemcmp(); 437 extern wchar_t *wmemcpy(); 438 extern wchar_t *wmemmove(); 439 extern wchar_t *wmemset(); 440 extern int wprintf(); 441 extern int wscanf(); 442 #endif /* not XPG4 and not XPG4v2 */ 443 444 #endif /* __STDC__ */ 445 446 #if __cplusplus >= 199711L 447 } 448 #endif /* end of namespace std */ 449 450 #ifdef __cplusplus 451 } 452 #endif 453 454 #endif /* _ISO_WCHAR_ISO_H */ 455