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