1 1.1 joerg // -*- C++ -*- 2 1.1 joerg //===--------------------------- wchar.h ----------------------------------===// 3 1.1 joerg // 4 1.1 joerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 1.1 joerg // See https://llvm.org/LICENSE.txt for license information. 6 1.1 joerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 1.1 joerg // 8 1.1 joerg //===----------------------------------------------------------------------===// 9 1.1 joerg 10 1.1 joerg #if defined(__need_wint_t) || defined(__need_mbstate_t) 11 1.1 joerg 12 1.1 joerg #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 13 1.1 joerg #pragma GCC system_header 14 1.1 joerg #endif 15 1.1 joerg 16 1.1 joerg #include_next <wchar.h> 17 1.1 joerg 18 1.1 joerg #elif !defined(_LIBCPP_WCHAR_H) 19 1.1 joerg #define _LIBCPP_WCHAR_H 20 1.1 joerg 21 1.1 joerg /* 22 1.1 joerg wchar.h synopsis 23 1.1 joerg 24 1.1 joerg Macros: 25 1.1 joerg 26 1.1 joerg NULL 27 1.1 joerg WCHAR_MAX 28 1.1 joerg WCHAR_MIN 29 1.1 joerg WEOF 30 1.1 joerg 31 1.1 joerg Types: 32 1.1 joerg 33 1.1 joerg mbstate_t 34 1.1 joerg size_t 35 1.1 joerg tm 36 1.1 joerg wint_t 37 1.1 joerg 38 1.1 joerg int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...); 39 1.1 joerg int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...); 40 1.1 joerg int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, ...); 41 1.1 joerg int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...); 42 1.1 joerg int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); 43 1.1 joerg int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); // C99 44 1.1 joerg int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, va_list arg); 45 1.1 joerg int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, va_list arg); // C99 46 1.1 joerg int vwprintf(const wchar_t* restrict format, va_list arg); 47 1.1 joerg int vwscanf(const wchar_t* restrict format, va_list arg); // C99 48 1.1 joerg int wprintf(const wchar_t* restrict format, ...); 49 1.1 joerg int wscanf(const wchar_t* restrict format, ...); 50 1.1 joerg wint_t fgetwc(FILE* stream); 51 1.1 joerg wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream); 52 1.1 joerg wint_t fputwc(wchar_t c, FILE* stream); 53 1.1 joerg int fputws(const wchar_t* restrict s, FILE* restrict stream); 54 1.1 joerg int fwide(FILE* stream, int mode); 55 1.1 joerg wint_t getwc(FILE* stream); 56 1.1 joerg wint_t getwchar(); 57 1.1 joerg wint_t putwc(wchar_t c, FILE* stream); 58 1.1 joerg wint_t putwchar(wchar_t c); 59 1.1 joerg wint_t ungetwc(wint_t c, FILE* stream); 60 1.1 joerg double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr); 61 1.1 joerg float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99 62 1.1 joerg long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99 63 1.1 joerg long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); 64 1.1 joerg long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99 65 1.1 joerg unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); 66 1.1 joerg unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99 67 1.1 joerg wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2); 68 1.1 joerg wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); 69 1.1 joerg wchar_t* wcscat(wchar_t* restrict s1, const wchar_t* restrict s2); 70 1.1 joerg wchar_t* wcsncat(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); 71 1.1 joerg int wcscmp(const wchar_t* s1, const wchar_t* s2); 72 1.1 joerg int wcscoll(const wchar_t* s1, const wchar_t* s2); 73 1.1 joerg int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n); 74 1.1 joerg size_t wcsxfrm(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); 75 1.1 joerg const wchar_t* wcschr(const wchar_t* s, wchar_t c); 76 1.1 joerg wchar_t* wcschr( wchar_t* s, wchar_t c); 77 1.1 joerg size_t wcscspn(const wchar_t* s1, const wchar_t* s2); 78 1.1 joerg size_t wcslen(const wchar_t* s); 79 1.1 joerg const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2); 80 1.1 joerg wchar_t* wcspbrk( wchar_t* s1, const wchar_t* s2); 81 1.1 joerg const wchar_t* wcsrchr(const wchar_t* s, wchar_t c); 82 1.1 joerg wchar_t* wcsrchr( wchar_t* s, wchar_t c); 83 1.1 joerg size_t wcsspn(const wchar_t* s1, const wchar_t* s2); 84 1.1 joerg const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2); 85 1.1 joerg wchar_t* wcsstr( wchar_t* s1, const wchar_t* s2); 86 1.1 joerg wchar_t* wcstok(wchar_t* restrict s1, const wchar_t* restrict s2, wchar_t** restrict ptr); 87 1.1 joerg const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n); 88 1.1 joerg wchar_t* wmemchr( wchar_t* s, wchar_t c, size_t n); 89 1.1 joerg int wmemcmp(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); 90 1.1 joerg wchar_t* wmemcpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); 91 1.1 joerg wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n); 92 1.1 joerg wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n); 93 1.1 joerg size_t wcsftime(wchar_t* restrict s, size_t maxsize, const wchar_t* restrict format, 94 1.1 joerg const tm* restrict timeptr); 95 1.1 joerg wint_t btowc(int c); 96 1.1 joerg int wctob(wint_t c); 97 1.1 joerg int mbsinit(const mbstate_t* ps); 98 1.1 joerg size_t mbrlen(const char* restrict s, size_t n, mbstate_t* restrict ps); 99 1.1 joerg size_t mbrtowc(wchar_t* restrict pwc, const char* restrict s, size_t n, mbstate_t* restrict ps); 100 1.1 joerg size_t wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps); 101 1.1 joerg size_t mbsrtowcs(wchar_t* restrict dst, const char** restrict src, size_t len, 102 1.1 joerg mbstate_t* restrict ps); 103 1.1 joerg size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, 104 1.1 joerg mbstate_t* restrict ps); 105 1.1 joerg 106 1.1 joerg */ 107 1.1 joerg 108 1.1 joerg #include <__config> 109 1.1 joerg #include <stddef.h> 110 1.1 joerg 111 1.1 joerg #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 112 1.1 joerg #pragma GCC system_header 113 1.1 joerg #endif 114 1.1 joerg 115 1.1 joerg #ifdef __cplusplus 116 1.1 joerg #define __CORRECT_ISO_CPP_WCHAR_H_PROTO 117 1.1 joerg #endif 118 1.1 joerg 119 1.1 joerg #include_next <wchar.h> 120 1.1 joerg 121 1.1 joerg // Determine whether we have const-correct overloads for wcschr and friends. 122 1.1 joerg #if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_) 123 1.1 joerg # define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 124 1.1 joerg #elif defined(__GLIBC_PREREQ) 125 1.1 joerg # if __GLIBC_PREREQ(2, 10) 126 1.1 joerg # define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 127 1.1 joerg # endif 128 1.1 joerg #elif defined(_LIBCPP_MSVCRT) 129 1.1 joerg # if defined(_CRT_CONST_CORRECT_OVERLOADS) 130 1.1 joerg # define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 131 1.1 joerg # endif 132 1.1 joerg #endif 133 1.1 joerg 134 1.1 joerg #if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD) 135 1.1 joerg extern "C++" { 136 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY 137 1.1 joerg wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcschr(__s, __c);} 138 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD 139 1.1 joerg const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);} 140 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD 141 1.1 joerg wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);} 142 1.1 joerg 143 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY 144 1.1 joerg wchar_t* __libcpp_wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcspbrk(__s1, __s2);} 145 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD 146 1.1 joerg const wchar_t* wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcspbrk(__s1, __s2);} 147 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD 148 1.1 joerg wchar_t* wcspbrk( wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcspbrk(__s1, __s2);} 149 1.1 joerg 150 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY 151 1.1 joerg wchar_t* __libcpp_wcsrchr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcsrchr(__s, __c);} 152 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD 153 1.1 joerg const wchar_t* wcsrchr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcsrchr(__s, __c);} 154 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD 155 1.1 joerg wchar_t* wcsrchr( wchar_t* __s, wchar_t __c) {return __libcpp_wcsrchr(__s, __c);} 156 1.1 joerg 157 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY 158 1.1 joerg wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);} 159 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD 160 1.1 joerg const wchar_t* wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcsstr(__s1, __s2);} 161 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD 162 1.1 joerg wchar_t* wcsstr( wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcsstr(__s1, __s2);} 163 1.1 joerg 164 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY 165 1.1 joerg wchar_t* __libcpp_wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return (wchar_t*)wmemchr(__s, __c, __n);} 166 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD 167 1.1 joerg const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);} 168 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD 169 1.1 joerg wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);} 170 1.1 joerg } 171 1.1 joerg #endif 172 1.1 joerg 173 1.1 joerg #if defined(__cplusplus) && defined(_LIBCPP_MSVCRT_LIKE) 174 1.1 joerg extern "C" { 175 1.1 joerg size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src, 176 1.1 joerg size_t nmc, size_t len, mbstate_t *__restrict ps); 177 1.1 joerg size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src, 178 1.1 joerg size_t nwc, size_t len, mbstate_t *__restrict ps); 179 1.1 joerg } // extern "C++" 180 1.1 joerg #endif // __cplusplus && _LIBCPP_MSVCRT 181 1.1 joerg 182 1.1 joerg #endif // _LIBCPP_WCHAR_H 183