1#ifndef _WCHAR_H
2
3/* Workaround PR90731 with GCC 9 when using ldbl redirects in C++. */
4# include <bits/floatn.h>
5# if defined __cplusplus && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
6# if __GNUC_PREREQ (9, 0) && !__GNUC_PREREQ (9, 3)
7# pragma GCC system_header
8# endif
9# endif
10
11# include <wcsmbs/wchar.h>
12# ifndef _ISOMAC
13
14#include <bits/floatn.h>
15#include <bits/wchar2-decl.h>
16#include <stdbool.h>
17
18extern __typeof (wcscasecmp_l) __wcscasecmp_l;
19extern __typeof (wcsncasecmp_l) __wcsncasecmp_l;
20extern __typeof (wcscoll_l) __wcscoll_l;
21extern __typeof (wcsxfrm_l) __wcsxfrm_l;
22extern __typeof (wcstol_l) __wcstol_l;
23extern __typeof (wcstoul_l) __wcstoul_l;
24extern __typeof (wcstoll_l) __wcstoll_l;
25extern __typeof (wcstoull_l) __wcstoull_l;
26extern __typeof (wcstod_l) __wcstod_l;
27extern __typeof (wcstof_l) __wcstof_l;
28extern __typeof (wcstold_l) __wcstold_l;
29extern __typeof (wcsftime_l) __wcsftime_l;
30libc_hidden_proto (__wcstol_l)
31libc_hidden_proto (__wcstoul_l)
32libc_hidden_proto (__wcstoll_l)
33libc_hidden_proto (__wcstoull_l)
34libc_hidden_proto (__wcstod_l)
35libc_hidden_proto (__wcstof_l)
36libc_hidden_proto (__wcstold_l)
37libc_hidden_proto (__wcsftime_l)
38
39extern __typeof (wcstol) __isoc23_wcstol __attribute_copy__ (wcstol);
40extern __typeof (wcstoul) __isoc23_wcstoul __attribute_copy__ (wcstoul);
41extern __typeof (wcstoll) __isoc23_wcstoll __attribute_copy__ (wcstoll);
42extern __typeof (wcstoull) __isoc23_wcstoull __attribute_copy__ (wcstoull);
43extern __typeof (wcstol_l) __isoc23_wcstol_l __attribute_copy__ (wcstol_l);
44extern __typeof (wcstoul_l) __isoc23_wcstoul_l __attribute_copy__ (wcstoul_l);
45extern __typeof (wcstoll_l) __isoc23_wcstoll_l __attribute_copy__ (wcstoll_l);
46extern __typeof (wcstoull_l) __isoc23_wcstoull_l __attribute_copy__ (wcstoull_l);
47libc_hidden_proto (__isoc23_wcstol)
48libc_hidden_proto (__isoc23_wcstoul)
49libc_hidden_proto (__isoc23_wcstoll)
50libc_hidden_proto (__isoc23_wcstoull)
51libc_hidden_proto (__isoc23_wcstol_l)
52libc_hidden_proto (__isoc23_wcstoul_l)
53libc_hidden_proto (__isoc23_wcstoll_l)
54libc_hidden_proto (__isoc23_wcstoull_l)
55
56#if __GLIBC_USE (C2X_STRTOL)
57/* Redirect internal uses of these functions to the C2X versions; the
58 redirection in the installed header does not work with
59 libc_hidden_proto. */
60# undef wcstol
61# define wcstol __isoc23_wcstol
62# undef wcstoul
63# define wcstoul __isoc23_wcstoul
64# undef wcstoll
65# define wcstoll __isoc23_wcstoll
66# undef wcstoull
67# define wcstoull __isoc23_wcstoull
68# undef wcstol_l
69# define wcstol_l __isoc23_wcstol_l
70# undef wcstoul_l
71# define wcstoul_l __isoc23_wcstoul_l
72# undef wcstoll_l
73# define wcstoll_l __isoc23_wcstoll_l
74# undef wcstoull_l
75# define wcstoull_l __isoc23_wcstoull_l
76#endif
77
78
79extern double __wcstod_internal (const wchar_t *__restrict __nptr,
80 wchar_t **__restrict __endptr, int __group)
81 __THROW;
82extern float __wcstof_internal (const wchar_t *__restrict __nptr,
83 wchar_t **__restrict __endptr, int __group)
84 __THROW;
85extern long double __wcstold_internal (const wchar_t *__restrict __nptr,
86 wchar_t **__restrict __endptr,
87 int __group) __THROW;
88extern long int __wcstol_internal (const wchar_t *__restrict __nptr,
89 wchar_t **__restrict __endptr,
90 int __base, int __group) __THROW;
91extern unsigned long int __wcstoul_internal (const wchar_t *__restrict __npt,
92 wchar_t **__restrict __endptr,
93 int __base, int __group) __THROW;
94__extension__
95extern long long int __wcstoll_internal (const wchar_t *__restrict __nptr,
96 wchar_t **__restrict __endptr,
97 int __base, int __group) __THROW;
98__extension__
99extern unsigned long long int __wcstoull_internal (const wchar_t *
100 __restrict __nptr,
101 wchar_t **
102 __restrict __endptr,
103 int __base,
104 int __group) __THROW;
105extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
106 wchar_t **, int, int,
107 bool, locale_t);
108libc_hidden_proto (__wcstof_internal)
109libc_hidden_proto (__wcstod_internal)
110libc_hidden_proto (__wcstold_internal)
111libc_hidden_proto (__wcstol_internal)
112libc_hidden_proto (__wcstoll_internal)
113libc_hidden_proto (__wcstoul_internal)
114libc_hidden_proto (__wcstoull_internal)
115libc_hidden_proto (wcstof)
116libc_hidden_proto (wcstod)
117libc_hidden_ldbl_proto (wcstold)
118libc_hidden_proto (wcstol)
119libc_hidden_proto (wcstoll)
120libc_hidden_proto (wcstoul)
121libc_hidden_proto (wcstoull)
122
123extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
124 locale_t) attribute_hidden;
125extern double ____wcstod_l_internal (const wchar_t *, wchar_t **, int,
126 locale_t) attribute_hidden;
127extern long double ____wcstold_l_internal (const wchar_t *, wchar_t **,
128 int, locale_t) attribute_hidden;
129extern long int ____wcstol_l_internal (const wchar_t *, wchar_t **, int,
130 int, bool, locale_t) attribute_hidden;
131extern unsigned long int ____wcstoul_l_internal (const wchar_t *,
132 wchar_t **,
133 int, int, bool, locale_t)
134 attribute_hidden;
135extern long long int ____wcstoll_l_internal (const wchar_t *, wchar_t **,
136 int, int, bool, locale_t)
137 attribute_hidden;
138extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
139 wchar_t **, int, int,
140 bool, locale_t)
141 attribute_hidden;
142
143#if __HAVE_DISTINCT_FLOAT128
144extern __typeof (wcstof128_l) __wcstof128_l;
145libc_hidden_proto (__wcstof128_l)
146extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
147 wchar_t **__restrict __endptr,
148 int __group) __THROW;
149
150extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
151 locale_t) attribute_hidden;
152
153libc_hidden_proto (__wcstof128_internal)
154libc_hidden_proto (wcstof128)
155#endif
156
157libc_hidden_proto (__wcscasecmp_l)
158libc_hidden_proto (__wcsncasecmp_l)
159
160libc_hidden_proto (__wcscoll_l)
161libc_hidden_proto (__wcsxfrm_l)
162
163libc_hidden_proto (fputws_unlocked)
164libc_hidden_proto (putwc_unlocked)
165libc_hidden_proto (putwc)
166
167libc_hidden_proto (mbrtowc)
168libc_hidden_proto (wcrtomb)
169libc_hidden_proto (__wcrtomb_chk)
170
171extern int __wcscmp (const wchar_t *__s1, const wchar_t *__s2)
172 __THROW __attribute_pure__;
173libc_hidden_proto (__wcscmp)
174libc_hidden_proto (wcsftime)
175libc_hidden_proto (wcsspn)
176libc_hidden_proto (wcschr)
177/* The C++ overloading of wcschr means we have to repeat the type to
178 declare __wcschr instead of using typeof, to avoid errors in C++
179 tests; in addition, __THROW cannot be used with a function type
180 from typeof in C++. The same applies to __wmemchr and, as regards
181 __THROW, to __wcscmp and __wcscoll. */
182extern wchar_t *__wcschr (const wchar_t *__wcs, wchar_t __wc)
183 __THROW __attribute_pure__;
184libc_hidden_proto (__wcschr)
185extern int __wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW;
186libc_hidden_proto (__wcscoll)
187libc_hidden_proto (wcspbrk)
188
189extern __typeof (wmemset) __wmemset;
190extern wchar_t *__wmemchr (const wchar_t *__s, wchar_t __c, size_t __n)
191 __THROW __attribute_pure__;
192libc_hidden_proto (wmemchr)
193libc_hidden_proto (__wmemchr)
194libc_hidden_proto (wmemset)
195libc_hidden_proto (__wmemset)
196extern int __wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
197 __THROW __attribute_pure__;
198
199/* Now define the internal interfaces. */
200extern int __wcscasecmp (const wchar_t *__s1, const wchar_t *__s2)
201 __attribute_pure__;
202extern int __wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2,
203 size_t __n)
204 __attribute_pure__;
205extern size_t __wcslen (const wchar_t *__s) __attribute_pure__;
206extern size_t __wcsnlen (const wchar_t *__s, size_t __maxlen)
207 __attribute_pure__;
208extern wchar_t *__wcscat (wchar_t *dest, const wchar_t *src);
209extern __typeof (wcslcat) __wcslcat;
210libc_hidden_proto (__wcslcat)
211extern wint_t __btowc (int __c) attribute_hidden;
212extern int __mbsinit (const __mbstate_t *__ps);
213extern size_t __mbrtowc (wchar_t *__restrict __pwc,
214 const char *__restrict __s, size_t __n,
215 __mbstate_t *__restrict __p);
216libc_hidden_proto (__mbrtowc)
217libc_hidden_proto (__mbrlen)
218extern size_t __wcrtomb (char *__restrict __s, wchar_t __wc,
219 __mbstate_t *__restrict __ps) attribute_hidden;
220extern size_t __wcrtomb_internal (char *__restrict __s, wchar_t __wc,
221 __mbstate_t *__restrict __ps,
222 size_t __s_size)
223 attribute_hidden;
224extern size_t __mbsrtowcs (wchar_t *__restrict __dst,
225 const char **__restrict __src,
226 size_t __len, __mbstate_t *__restrict __ps)
227 attribute_hidden;
228extern size_t __wcsrtombs (char *__restrict __dst,
229 const wchar_t **__restrict __src,
230 size_t __len, __mbstate_t *__restrict __ps)
231 attribute_hidden;
232extern size_t __mbsnrtowcs (wchar_t *__restrict __dst,
233 const char **__restrict __src, size_t __nmc,
234 size_t __len, __mbstate_t *__restrict __ps)
235 attribute_hidden;
236extern size_t __wcsnrtombs (char *__restrict __dst,
237 const wchar_t **__restrict __src,
238 size_t __nwc, size_t __len,
239 __mbstate_t *__restrict __ps)
240 attribute_hidden;
241extern wchar_t *__wcscpy (wchar_t *__restrict __dest,
242 const wchar_t *__restrict __src)
243 attribute_hidden __nonnull ((1, 2));
244libc_hidden_proto (__wcscpy)
245extern __typeof (wcslcpy) __wcslcpy;
246libc_hidden_proto (__wcslcpy)
247extern wchar_t *__wcsncpy (wchar_t *__restrict __dest,
248 const wchar_t *__restrict __src, size_t __n);
249
250extern wchar_t *__wcpcpy (wchar_t *__dest, const wchar_t *__src);
251extern wchar_t *__wcpncpy (wchar_t *__dest, const wchar_t *__src,
252 size_t __n);
253extern wchar_t *__wmemcpy (wchar_t *__s1, const wchar_t *s2,
254 size_t __n) attribute_hidden;
255extern wchar_t *__wmempcpy (wchar_t *__restrict __s1,
256 const wchar_t *__restrict __s2,
257 size_t __n) attribute_hidden;
258extern wchar_t *__wmemmove (wchar_t *__s1, const wchar_t *__s2,
259 size_t __n) attribute_hidden;
260extern wchar_t *__wcschrnul (const wchar_t *__s, wchar_t __wc)
261 __attribute_pure__;
262
263extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n,
264 size_t __ns) __THROW;
265libc_hidden_builtin_proto (__wmemset_chk)
266
267extern int __vfwscanf (__FILE *__restrict __s,
268 const wchar_t *__restrict __format,
269 __gnuc_va_list __arg)
270 attribute_hidden
271 /* __attribute__ ((__format__ (__wscanf__, 2, 0)) */;
272
273extern int __swprintf_chk (wchar_t *__restrict __s, size_t __n,
274 int __flag, size_t __s_len,
275 const wchar_t *__restrict __format, ...)
276 __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 6))) */;
277
278extern int __fwprintf (__FILE *__restrict __s,
279 const wchar_t *__restrict __format, ...)
280 attribute_hidden
281 /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
282extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format,
283 ...);
284extern int __vfwprintf_chk (FILE *__restrict __s, int __flag,
285 const wchar_t *__restrict __format,
286 __gnuc_va_list __arg)
287 /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
288extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
289 int __flag, size_t __s_len,
290 const wchar_t *__restrict __format,
291 __gnuc_va_list __arg)
292 /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
293extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag,
294 const wchar_t *__restrict __format, ...);
295extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format,
296 __gnuc_va_list __ap);
297
298extern int __isoc99_fwscanf (__FILE *__restrict __stream,
299 const wchar_t *__restrict __format, ...);
300extern int __isoc99_wscanf (const wchar_t *__restrict __format, ...);
301extern int __isoc99_swscanf (const wchar_t *__restrict __s,
302 const wchar_t *__restrict __format, ...)
303 __THROW;
304extern int __isoc99_vfwscanf (__FILE *__restrict __s,
305 const wchar_t *__restrict __format,
306 __gnuc_va_list __arg);
307extern int __isoc99_vwscanf (const wchar_t *__restrict __format,
308 __gnuc_va_list __arg);
309extern int __isoc99_vswscanf (const wchar_t *__restrict __s,
310 const wchar_t *__restrict __format,
311 __gnuc_va_list __arg) __THROW;
312extern int __isoc23_fwscanf (__FILE *__restrict __stream,
313 const wchar_t *__restrict __format, ...);
314extern int __isoc23_wscanf (const wchar_t *__restrict __format, ...);
315extern int __isoc23_swscanf (const wchar_t *__restrict __s,
316 const wchar_t *__restrict __format, ...)
317 __THROW;
318extern int __isoc23_vfwscanf (__FILE *__restrict __s,
319 const wchar_t *__restrict __format,
320 __gnuc_va_list __arg);
321extern int __isoc23_vwscanf (const wchar_t *__restrict __format,
322 __gnuc_va_list __arg);
323extern int __isoc23_vswscanf (const wchar_t *__restrict __s,
324 const wchar_t *__restrict __format,
325 __gnuc_va_list __arg) __THROW;
326libc_hidden_proto (__isoc99_vswscanf)
327libc_hidden_proto (__isoc99_vfwscanf)
328libc_hidden_proto (__isoc23_vswscanf)
329libc_hidden_proto (__isoc23_vfwscanf)
330
331/* Internal functions. */
332extern size_t __mbsrtowcs_l (wchar_t *dst, const char **src, size_t len,
333 mbstate_t *ps, locale_t l) attribute_hidden;
334
335/* Special version. We know that all uses of mbsinit inside the libc
336 have a non-NULL parameter. And certainly we can access the
337 internals of the data structure directly. */
338# define mbsinit(state) ((state)->__count == 0)
339# define __mbsinit(state) ((state)->__count == 0)
340
341# endif
342#endif
343