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 | |
18 | extern __typeof (wcscasecmp_l) __wcscasecmp_l; |
19 | extern __typeof (wcsncasecmp_l) __wcsncasecmp_l; |
20 | extern __typeof (wcscoll_l) __wcscoll_l; |
21 | extern __typeof (wcsxfrm_l) __wcsxfrm_l; |
22 | extern __typeof (wcstol_l) __wcstol_l; |
23 | extern __typeof (wcstoul_l) __wcstoul_l; |
24 | extern __typeof (wcstoll_l) __wcstoll_l; |
25 | extern __typeof (wcstoull_l) __wcstoull_l; |
26 | extern __typeof (wcstod_l) __wcstod_l; |
27 | extern __typeof (wcstof_l) __wcstof_l; |
28 | extern __typeof (wcstold_l) __wcstold_l; |
29 | extern __typeof (wcsftime_l) __wcsftime_l; |
30 | libc_hidden_proto (__wcstol_l) |
31 | libc_hidden_proto (__wcstoul_l) |
32 | libc_hidden_proto (__wcstoll_l) |
33 | libc_hidden_proto (__wcstoull_l) |
34 | libc_hidden_proto (__wcstod_l) |
35 | libc_hidden_proto (__wcstof_l) |
36 | libc_hidden_proto (__wcstold_l) |
37 | libc_hidden_proto (__wcsftime_l) |
38 | |
39 | extern __typeof (wcstol) __isoc23_wcstol __attribute_copy__ (wcstol); |
40 | extern __typeof (wcstoul) __isoc23_wcstoul __attribute_copy__ (wcstoul); |
41 | extern __typeof (wcstoll) __isoc23_wcstoll __attribute_copy__ (wcstoll); |
42 | extern __typeof (wcstoull) __isoc23_wcstoull __attribute_copy__ (wcstoull); |
43 | extern __typeof (wcstol_l) __isoc23_wcstol_l __attribute_copy__ (wcstol_l); |
44 | extern __typeof (wcstoul_l) __isoc23_wcstoul_l __attribute_copy__ (wcstoul_l); |
45 | extern __typeof (wcstoll_l) __isoc23_wcstoll_l __attribute_copy__ (wcstoll_l); |
46 | extern __typeof (wcstoull_l) __isoc23_wcstoull_l __attribute_copy__ (wcstoull_l); |
47 | libc_hidden_proto (__isoc23_wcstol) |
48 | libc_hidden_proto (__isoc23_wcstoul) |
49 | libc_hidden_proto (__isoc23_wcstoll) |
50 | libc_hidden_proto (__isoc23_wcstoull) |
51 | libc_hidden_proto (__isoc23_wcstol_l) |
52 | libc_hidden_proto (__isoc23_wcstoul_l) |
53 | libc_hidden_proto (__isoc23_wcstoll_l) |
54 | libc_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 | |
79 | extern double __wcstod_internal (const wchar_t *__restrict __nptr, |
80 | wchar_t **__restrict __endptr, int __group) |
81 | __THROW; |
82 | extern float __wcstof_internal (const wchar_t *__restrict __nptr, |
83 | wchar_t **__restrict __endptr, int __group) |
84 | __THROW; |
85 | extern long double __wcstold_internal (const wchar_t *__restrict __nptr, |
86 | wchar_t **__restrict __endptr, |
87 | int __group) __THROW; |
88 | extern long int __wcstol_internal (const wchar_t *__restrict __nptr, |
89 | wchar_t **__restrict __endptr, |
90 | int __base, int __group) __THROW; |
91 | extern unsigned long int __wcstoul_internal (const wchar_t *__restrict __npt, |
92 | wchar_t **__restrict __endptr, |
93 | int __base, int __group) __THROW; |
94 | __extension__ |
95 | extern long long int __wcstoll_internal (const wchar_t *__restrict __nptr, |
96 | wchar_t **__restrict __endptr, |
97 | int __base, int __group) __THROW; |
98 | __extension__ |
99 | extern 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; |
105 | extern unsigned long long int ____wcstoull_l_internal (const wchar_t *, |
106 | wchar_t **, int, int, |
107 | bool, locale_t); |
108 | libc_hidden_proto (__wcstof_internal) |
109 | libc_hidden_proto (__wcstod_internal) |
110 | libc_hidden_proto (__wcstold_internal) |
111 | libc_hidden_proto (__wcstol_internal) |
112 | libc_hidden_proto (__wcstoll_internal) |
113 | libc_hidden_proto (__wcstoul_internal) |
114 | libc_hidden_proto (__wcstoull_internal) |
115 | libc_hidden_proto (wcstof) |
116 | libc_hidden_proto (wcstod) |
117 | libc_hidden_ldbl_proto (wcstold) |
118 | libc_hidden_proto (wcstol) |
119 | libc_hidden_proto (wcstoll) |
120 | libc_hidden_proto (wcstoul) |
121 | libc_hidden_proto (wcstoull) |
122 | |
123 | extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int, |
124 | locale_t) attribute_hidden; |
125 | extern double ____wcstod_l_internal (const wchar_t *, wchar_t **, int, |
126 | locale_t) attribute_hidden; |
127 | extern long double ____wcstold_l_internal (const wchar_t *, wchar_t **, |
128 | int, locale_t) attribute_hidden; |
129 | extern long int ____wcstol_l_internal (const wchar_t *, wchar_t **, int, |
130 | int, bool, locale_t) attribute_hidden; |
131 | extern unsigned long int ____wcstoul_l_internal (const wchar_t *, |
132 | wchar_t **, |
133 | int, int, bool, locale_t) |
134 | attribute_hidden; |
135 | extern long long int ____wcstoll_l_internal (const wchar_t *, wchar_t **, |
136 | int, int, bool, locale_t) |
137 | attribute_hidden; |
138 | extern 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 |
144 | extern __typeof (wcstof128_l) __wcstof128_l; |
145 | libc_hidden_proto (__wcstof128_l) |
146 | extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr, |
147 | wchar_t **__restrict __endptr, |
148 | int __group) __THROW; |
149 | |
150 | extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int, |
151 | locale_t) attribute_hidden; |
152 | |
153 | libc_hidden_proto (__wcstof128_internal) |
154 | libc_hidden_proto (wcstof128) |
155 | #endif |
156 | |
157 | libc_hidden_proto (__wcscasecmp_l) |
158 | libc_hidden_proto (__wcsncasecmp_l) |
159 | |
160 | libc_hidden_proto (__wcscoll_l) |
161 | libc_hidden_proto (__wcsxfrm_l) |
162 | |
163 | libc_hidden_proto (fputws_unlocked) |
164 | libc_hidden_proto (putwc_unlocked) |
165 | libc_hidden_proto (putwc) |
166 | |
167 | libc_hidden_proto (mbrtowc) |
168 | libc_hidden_proto (wcrtomb) |
169 | libc_hidden_proto (__wcrtomb_chk) |
170 | |
171 | extern int __wcscmp (const wchar_t *__s1, const wchar_t *__s2) |
172 | __THROW __attribute_pure__; |
173 | libc_hidden_proto (__wcscmp) |
174 | libc_hidden_proto (wcsftime) |
175 | libc_hidden_proto (wcsspn) |
176 | libc_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. */ |
182 | extern wchar_t *__wcschr (const wchar_t *__wcs, wchar_t __wc) |
183 | __THROW __attribute_pure__; |
184 | libc_hidden_proto (__wcschr) |
185 | extern int __wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW; |
186 | libc_hidden_proto (__wcscoll) |
187 | libc_hidden_proto (wcspbrk) |
188 | |
189 | extern __typeof (wmemset) __wmemset; |
190 | extern wchar_t *__wmemchr (const wchar_t *__s, wchar_t __c, size_t __n) |
191 | __THROW __attribute_pure__; |
192 | libc_hidden_proto (wmemchr) |
193 | libc_hidden_proto (__wmemchr) |
194 | libc_hidden_proto (wmemset) |
195 | libc_hidden_proto (__wmemset) |
196 | extern int __wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n) |
197 | __THROW __attribute_pure__; |
198 | |
199 | /* Now define the internal interfaces. */ |
200 | extern int __wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) |
201 | __attribute_pure__; |
202 | extern int __wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2, |
203 | size_t __n) |
204 | __attribute_pure__; |
205 | extern size_t __wcslen (const wchar_t *__s) __attribute_pure__; |
206 | extern size_t __wcsnlen (const wchar_t *__s, size_t __maxlen) |
207 | __attribute_pure__; |
208 | extern wchar_t *__wcscat (wchar_t *dest, const wchar_t *src); |
209 | extern __typeof (wcslcat) __wcslcat; |
210 | libc_hidden_proto (__wcslcat) |
211 | extern wint_t __btowc (int __c) attribute_hidden; |
212 | extern int __mbsinit (const __mbstate_t *__ps); |
213 | extern size_t __mbrtowc (wchar_t *__restrict __pwc, |
214 | const char *__restrict __s, size_t __n, |
215 | __mbstate_t *__restrict __p); |
216 | libc_hidden_proto (__mbrtowc) |
217 | libc_hidden_proto (__mbrlen) |
218 | extern size_t __wcrtomb (char *__restrict __s, wchar_t __wc, |
219 | __mbstate_t *__restrict __ps) attribute_hidden; |
220 | extern size_t __wcrtomb_internal (char *__restrict __s, wchar_t __wc, |
221 | __mbstate_t *__restrict __ps, |
222 | size_t __s_size) |
223 | attribute_hidden; |
224 | extern size_t __mbsrtowcs (wchar_t *__restrict __dst, |
225 | const char **__restrict __src, |
226 | size_t __len, __mbstate_t *__restrict __ps) |
227 | attribute_hidden; |
228 | extern size_t __wcsrtombs (char *__restrict __dst, |
229 | const wchar_t **__restrict __src, |
230 | size_t __len, __mbstate_t *__restrict __ps) |
231 | attribute_hidden; |
232 | extern 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; |
236 | extern 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; |
241 | extern wchar_t *__wcscpy (wchar_t *__restrict __dest, |
242 | const wchar_t *__restrict __src) |
243 | attribute_hidden __nonnull ((1, 2)); |
244 | libc_hidden_proto (__wcscpy) |
245 | extern __typeof (wcslcpy) __wcslcpy; |
246 | libc_hidden_proto (__wcslcpy) |
247 | extern wchar_t *__wcsncpy (wchar_t *__restrict __dest, |
248 | const wchar_t *__restrict __src, size_t __n); |
249 | |
250 | extern wchar_t *__wcpcpy (wchar_t *__dest, const wchar_t *__src); |
251 | extern wchar_t *__wcpncpy (wchar_t *__dest, const wchar_t *__src, |
252 | size_t __n); |
253 | extern wchar_t *__wmemcpy (wchar_t *__s1, const wchar_t *s2, |
254 | size_t __n) attribute_hidden; |
255 | extern wchar_t *__wmempcpy (wchar_t *__restrict __s1, |
256 | const wchar_t *__restrict __s2, |
257 | size_t __n) attribute_hidden; |
258 | extern wchar_t *__wmemmove (wchar_t *__s1, const wchar_t *__s2, |
259 | size_t __n) attribute_hidden; |
260 | extern wchar_t *__wcschrnul (const wchar_t *__s, wchar_t __wc) |
261 | __attribute_pure__; |
262 | |
263 | extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n, |
264 | size_t __ns) __THROW; |
265 | libc_hidden_builtin_proto (__wmemset_chk) |
266 | |
267 | extern 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 | |
273 | extern 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 | |
278 | extern int __fwprintf (__FILE *__restrict __s, |
279 | const wchar_t *__restrict __format, ...) |
280 | attribute_hidden |
281 | /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */; |
282 | extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format, |
283 | ...); |
284 | extern 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))) */; |
288 | extern 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))) */; |
293 | extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag, |
294 | const wchar_t *__restrict __format, ...); |
295 | extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format, |
296 | __gnuc_va_list __ap); |
297 | |
298 | extern int __isoc99_fwscanf (__FILE *__restrict __stream, |
299 | const wchar_t *__restrict __format, ...); |
300 | extern int __isoc99_wscanf (const wchar_t *__restrict __format, ...); |
301 | extern int __isoc99_swscanf (const wchar_t *__restrict __s, |
302 | const wchar_t *__restrict __format, ...) |
303 | __THROW; |
304 | extern int __isoc99_vfwscanf (__FILE *__restrict __s, |
305 | const wchar_t *__restrict __format, |
306 | __gnuc_va_list __arg); |
307 | extern int __isoc99_vwscanf (const wchar_t *__restrict __format, |
308 | __gnuc_va_list __arg); |
309 | extern int __isoc99_vswscanf (const wchar_t *__restrict __s, |
310 | const wchar_t *__restrict __format, |
311 | __gnuc_va_list __arg) __THROW; |
312 | extern int __isoc23_fwscanf (__FILE *__restrict __stream, |
313 | const wchar_t *__restrict __format, ...); |
314 | extern int __isoc23_wscanf (const wchar_t *__restrict __format, ...); |
315 | extern int __isoc23_swscanf (const wchar_t *__restrict __s, |
316 | const wchar_t *__restrict __format, ...) |
317 | __THROW; |
318 | extern int __isoc23_vfwscanf (__FILE *__restrict __s, |
319 | const wchar_t *__restrict __format, |
320 | __gnuc_va_list __arg); |
321 | extern int __isoc23_vwscanf (const wchar_t *__restrict __format, |
322 | __gnuc_va_list __arg); |
323 | extern int __isoc23_vswscanf (const wchar_t *__restrict __s, |
324 | const wchar_t *__restrict __format, |
325 | __gnuc_va_list __arg) __THROW; |
326 | libc_hidden_proto (__isoc99_vswscanf) |
327 | libc_hidden_proto (__isoc99_vfwscanf) |
328 | libc_hidden_proto (__isoc23_vswscanf) |
329 | libc_hidden_proto (__isoc23_vfwscanf) |
330 | |
331 | /* Internal functions. */ |
332 | extern 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 | |