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