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