19729cf09SDimitry Andric // -*- C++ -*-
29729cf09SDimitry Andric //===--------------------------- wchar.h ----------------------------------===//
39729cf09SDimitry Andric //
49729cf09SDimitry Andric // The LLVM Compiler Infrastructure
59729cf09SDimitry Andric //
69729cf09SDimitry Andric // This file is dual licensed under the MIT and the University of Illinois Open
79729cf09SDimitry Andric // Source Licenses. See LICENSE.TXT for details.
89729cf09SDimitry Andric //
99729cf09SDimitry Andric //===----------------------------------------------------------------------===//
109729cf09SDimitry Andric
119729cf09SDimitry Andric #if defined(__need_wint_t) || defined(__need_mbstate_t)
129729cf09SDimitry Andric
139729cf09SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
149729cf09SDimitry Andric #pragma GCC system_header
159729cf09SDimitry Andric #endif
169729cf09SDimitry Andric
179729cf09SDimitry Andric #include_next <wchar.h>
189729cf09SDimitry Andric
199729cf09SDimitry Andric #elif !defined(_LIBCPP_WCHAR_H)
209729cf09SDimitry Andric #define _LIBCPP_WCHAR_H
219729cf09SDimitry Andric
229729cf09SDimitry Andric /*
239729cf09SDimitry Andric wchar.h synopsis
249729cf09SDimitry Andric
259729cf09SDimitry Andric Macros:
269729cf09SDimitry Andric
279729cf09SDimitry Andric NULL
289729cf09SDimitry Andric WCHAR_MAX
299729cf09SDimitry Andric WCHAR_MIN
309729cf09SDimitry Andric WEOF
319729cf09SDimitry Andric
329729cf09SDimitry Andric Types:
339729cf09SDimitry Andric
349729cf09SDimitry Andric mbstate_t
359729cf09SDimitry Andric size_t
369729cf09SDimitry Andric tm
379729cf09SDimitry Andric wint_t
389729cf09SDimitry Andric
399729cf09SDimitry Andric int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...);
409729cf09SDimitry Andric int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...);
419729cf09SDimitry Andric int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, ...);
429729cf09SDimitry Andric int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...);
439729cf09SDimitry Andric int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list arg);
449729cf09SDimitry Andric int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); // C99
459729cf09SDimitry Andric int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, va_list arg);
469729cf09SDimitry Andric int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, va_list arg); // C99
479729cf09SDimitry Andric int vwprintf(const wchar_t* restrict format, va_list arg);
489729cf09SDimitry Andric int vwscanf(const wchar_t* restrict format, va_list arg); // C99
499729cf09SDimitry Andric int wprintf(const wchar_t* restrict format, ...);
509729cf09SDimitry Andric int wscanf(const wchar_t* restrict format, ...);
519729cf09SDimitry Andric wint_t fgetwc(FILE* stream);
529729cf09SDimitry Andric wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream);
539729cf09SDimitry Andric wint_t fputwc(wchar_t c, FILE* stream);
549729cf09SDimitry Andric int fputws(const wchar_t* restrict s, FILE* restrict stream);
559729cf09SDimitry Andric int fwide(FILE* stream, int mode);
569729cf09SDimitry Andric wint_t getwc(FILE* stream);
579729cf09SDimitry Andric wint_t getwchar();
589729cf09SDimitry Andric wint_t putwc(wchar_t c, FILE* stream);
599729cf09SDimitry Andric wint_t putwchar(wchar_t c);
609729cf09SDimitry Andric wint_t ungetwc(wint_t c, FILE* stream);
619729cf09SDimitry Andric double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr);
629729cf09SDimitry Andric float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
639729cf09SDimitry Andric long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
649729cf09SDimitry Andric long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
659729cf09SDimitry Andric long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
669729cf09SDimitry Andric unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
679729cf09SDimitry Andric unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
689729cf09SDimitry Andric wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2);
699729cf09SDimitry Andric wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
709729cf09SDimitry Andric wchar_t* wcscat(wchar_t* restrict s1, const wchar_t* restrict s2);
719729cf09SDimitry Andric wchar_t* wcsncat(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
729729cf09SDimitry Andric int wcscmp(const wchar_t* s1, const wchar_t* s2);
739729cf09SDimitry Andric int wcscoll(const wchar_t* s1, const wchar_t* s2);
749729cf09SDimitry Andric int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n);
759729cf09SDimitry Andric size_t wcsxfrm(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
769729cf09SDimitry Andric const wchar_t* wcschr(const wchar_t* s, wchar_t c);
779729cf09SDimitry Andric wchar_t* wcschr( wchar_t* s, wchar_t c);
789729cf09SDimitry Andric size_t wcscspn(const wchar_t* s1, const wchar_t* s2);
799729cf09SDimitry Andric size_t wcslen(const wchar_t* s);
809729cf09SDimitry Andric const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2);
819729cf09SDimitry Andric wchar_t* wcspbrk( wchar_t* s1, const wchar_t* s2);
829729cf09SDimitry Andric const wchar_t* wcsrchr(const wchar_t* s, wchar_t c);
839729cf09SDimitry Andric wchar_t* wcsrchr( wchar_t* s, wchar_t c);
849729cf09SDimitry Andric size_t wcsspn(const wchar_t* s1, const wchar_t* s2);
859729cf09SDimitry Andric const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
869729cf09SDimitry Andric wchar_t* wcsstr( wchar_t* s1, const wchar_t* s2);
879729cf09SDimitry Andric wchar_t* wcstok(wchar_t* restrict s1, const wchar_t* restrict s2, wchar_t** restrict ptr);
889729cf09SDimitry Andric const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n);
899729cf09SDimitry Andric wchar_t* wmemchr( wchar_t* s, wchar_t c, size_t n);
909729cf09SDimitry Andric int wmemcmp(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
919729cf09SDimitry Andric wchar_t* wmemcpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
929729cf09SDimitry Andric wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n);
939729cf09SDimitry Andric wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);
949729cf09SDimitry Andric size_t wcsftime(wchar_t* restrict s, size_t maxsize, const wchar_t* restrict format,
959729cf09SDimitry Andric const tm* restrict timeptr);
969729cf09SDimitry Andric wint_t btowc(int c);
979729cf09SDimitry Andric int wctob(wint_t c);
989729cf09SDimitry Andric int mbsinit(const mbstate_t* ps);
999729cf09SDimitry Andric size_t mbrlen(const char* restrict s, size_t n, mbstate_t* restrict ps);
1009729cf09SDimitry Andric size_t mbrtowc(wchar_t* restrict pwc, const char* restrict s, size_t n, mbstate_t* restrict ps);
1019729cf09SDimitry Andric size_t wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps);
1029729cf09SDimitry Andric size_t mbsrtowcs(wchar_t* restrict dst, const char** restrict src, size_t len,
1039729cf09SDimitry Andric mbstate_t* restrict ps);
1049729cf09SDimitry Andric size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
1059729cf09SDimitry Andric mbstate_t* restrict ps);
1069729cf09SDimitry Andric
1079729cf09SDimitry Andric */
1089729cf09SDimitry Andric
1099729cf09SDimitry Andric #include <__config>
1109729cf09SDimitry Andric
1119729cf09SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1129729cf09SDimitry Andric #pragma GCC system_header
1139729cf09SDimitry Andric #endif
1149729cf09SDimitry Andric
1159729cf09SDimitry Andric #ifdef __cplusplus
1169729cf09SDimitry Andric #define __CORRECT_ISO_CPP_WCHAR_H_PROTO
1179729cf09SDimitry Andric #endif
1189729cf09SDimitry Andric
1199729cf09SDimitry Andric #include_next <wchar.h>
1209729cf09SDimitry Andric
1217c82a1ecSDimitry Andric // Determine whether we have const-correct overloads for wcschr and friends.
1229729cf09SDimitry Andric #if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
1239729cf09SDimitry Andric # define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
1249729cf09SDimitry Andric #elif defined(__GLIBC_PREREQ)
1259729cf09SDimitry Andric # if __GLIBC_PREREQ(2, 10)
1269729cf09SDimitry Andric # define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
1279729cf09SDimitry Andric # endif
128*b2c7081bSDimitry Andric #elif defined(_LIBCPP_MSVCRT)
129*b2c7081bSDimitry Andric # if defined(_CRT_CONST_CORRECT_OVERLOADS)
130*b2c7081bSDimitry Andric # define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
131*b2c7081bSDimitry Andric # endif
1329729cf09SDimitry Andric #endif
1339729cf09SDimitry Andric
1347c82a1ecSDimitry Andric #if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
1357c82a1ecSDimitry Andric extern "C++" {
1367c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY
__libcpp_wcschr(const wchar_t * __s,wchar_t __c)1377c82a1ecSDimitry Andric wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcschr(__s, __c);}
1387c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
wcschr(const wchar_t * __s,wchar_t __c)1397c82a1ecSDimitry Andric const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
1407c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
wcschr(wchar_t * __s,wchar_t __c)1417c82a1ecSDimitry Andric wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
1427c82a1ecSDimitry Andric
1437c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY
__libcpp_wcspbrk(const wchar_t * __s1,const wchar_t * __s2)1447c82a1ecSDimitry Andric wchar_t* __libcpp_wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcspbrk(__s1, __s2);}
1457c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
wcspbrk(const wchar_t * __s1,const wchar_t * __s2)1467c82a1ecSDimitry Andric const wchar_t* wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcspbrk(__s1, __s2);}
1477c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
wcspbrk(wchar_t * __s1,const wchar_t * __s2)1487c82a1ecSDimitry Andric wchar_t* wcspbrk( wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcspbrk(__s1, __s2);}
1497c82a1ecSDimitry Andric
1507c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY
__libcpp_wcsrchr(const wchar_t * __s,wchar_t __c)1517c82a1ecSDimitry Andric wchar_t* __libcpp_wcsrchr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcsrchr(__s, __c);}
1527c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
wcsrchr(const wchar_t * __s,wchar_t __c)1537c82a1ecSDimitry Andric const wchar_t* wcsrchr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcsrchr(__s, __c);}
1547c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
wcsrchr(wchar_t * __s,wchar_t __c)1557c82a1ecSDimitry Andric wchar_t* wcsrchr( wchar_t* __s, wchar_t __c) {return __libcpp_wcsrchr(__s, __c);}
1567c82a1ecSDimitry Andric
1577c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY
__libcpp_wcsstr(const wchar_t * __s1,const wchar_t * __s2)1587c82a1ecSDimitry Andric wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
1597c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
wcsstr(const wchar_t * __s1,const wchar_t * __s2)1607c82a1ecSDimitry Andric const wchar_t* wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcsstr(__s1, __s2);}
1617c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
wcsstr(wchar_t * __s1,const wchar_t * __s2)1627c82a1ecSDimitry Andric wchar_t* wcsstr( wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcsstr(__s1, __s2);}
1637c82a1ecSDimitry Andric
1647c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY
__libcpp_wmemchr(const wchar_t * __s,wchar_t __c,size_t __n)1657c82a1ecSDimitry Andric wchar_t* __libcpp_wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return (wchar_t*)wmemchr(__s, __c, __n);}
1667c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
wmemchr(const wchar_t * __s,wchar_t __c,size_t __n)1677c82a1ecSDimitry Andric const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);}
1687c82a1ecSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
wmemchr(wchar_t * __s,wchar_t __c,size_t __n)1697c82a1ecSDimitry Andric wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);}
1707c82a1ecSDimitry Andric }
1717c82a1ecSDimitry Andric #endif
1727c82a1ecSDimitry Andric
173f9448bf3SDimitry Andric #if defined(__cplusplus) && defined(_LIBCPP_MSVCRT_LIKE)
1745517e702SDimitry Andric extern "C" {
1755517e702SDimitry Andric size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
1765517e702SDimitry Andric size_t nmc, size_t len, mbstate_t *__restrict ps);
1775517e702SDimitry Andric size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
1785517e702SDimitry Andric size_t nwc, size_t len, mbstate_t *__restrict ps);
1799729cf09SDimitry Andric } // extern "C++"
1809729cf09SDimitry Andric #endif // __cplusplus && _LIBCPP_MSVCRT
1819729cf09SDimitry Andric
1829729cf09SDimitry Andric #endif // _LIBCPP_WCHAR_H
183