assert: Reformat Makefile.
[glibc.git] / wcsmbs / wchar.h
blobacc2eb9ddf38a9a6db2c5330a3c274f349f95e6f
1 /* Copyright (C) 1995-2023 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
19 * ISO C99 Standard: 7.24
20 * Extended multibyte and wide character utilities <wchar.h>
23 #ifndef _WCHAR_H
24 #define _WCHAR_H 1
26 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
27 #include <bits/libc-header-start.h>
29 /* Gather machine dependent type support. */
30 #include <bits/floatn.h>
32 #define __need_size_t
33 #define __need_wchar_t
34 #define __need_NULL
35 #include <stddef.h>
37 #define __need___va_list
38 #include <stdarg.h>
40 #include <bits/wchar.h>
41 #include <bits/types/wint_t.h>
42 #include <bits/types/mbstate_t.h>
43 #include <bits/types/__FILE.h>
45 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
46 # include <bits/types/FILE.h>
47 #endif
48 #ifdef __USE_XOPEN2K8
49 # include <bits/types/locale_t.h>
50 #endif
52 /* Tell the caller that we provide correct C++ prototypes. */
53 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
54 # define __CORRECT_ISO_CPP_WCHAR_H_PROTO
55 #endif
57 #ifndef WCHAR_MIN
58 /* These constants might also be defined in <inttypes.h>. */
59 # define WCHAR_MIN __WCHAR_MIN
60 # define WCHAR_MAX __WCHAR_MAX
61 #endif
63 #ifndef WEOF
64 # define WEOF (0xffffffffu)
65 #endif
67 /* All versions of XPG prior to the publication of ISO C99 required
68 the bulk of <wctype.h>'s declarations to appear in this header
69 (because <wctype.h> did not exist prior to C99). In POSIX.1-2001
70 those declarations were marked as XSI extensions; in -2008 they
71 were additionally marked as obsolescent. _GNU_SOURCE mode
72 anticipates the removal of these declarations in the next revision
73 of POSIX. */
74 #if (defined __USE_XOPEN && !defined __USE_GNU \
75 && !(defined __USE_XOPEN2K && !defined __USE_XOPEN2KXSI))
76 # include <bits/wctype-wchar.h>
77 #endif
79 __BEGIN_DECLS
81 /* This incomplete type is defined in <time.h> but needed here because
82 of `wcsftime'. */
83 struct tm;
86 /* Copy SRC to DEST. */
87 extern wchar_t *wcscpy (wchar_t *__restrict __dest,
88 const wchar_t *__restrict __src)
89 __THROW __nonnull ((1, 2));
91 /* Copy no more than N wide-characters of SRC to DEST. */
92 extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
93 const wchar_t *__restrict __src, size_t __n)
94 __THROW __nonnull ((1, 2));
96 /* Append SRC onto DEST. */
97 extern wchar_t *wcscat (wchar_t *__restrict __dest,
98 const wchar_t *__restrict __src)
99 __THROW __nonnull ((1, 2));
100 /* Append no more than N wide-characters of SRC onto DEST. */
101 extern wchar_t *wcsncat (wchar_t *__restrict __dest,
102 const wchar_t *__restrict __src, size_t __n)
103 __THROW __nonnull ((1, 2));
105 /* Compare S1 and S2. */
106 extern int wcscmp (const wchar_t *__s1, const wchar_t *__s2)
107 __THROW __attribute_pure__ __nonnull ((1, 2));
108 /* Compare N wide-characters of S1 and S2. */
109 extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
110 __THROW __attribute_pure__ __nonnull ((1, 2));
112 #ifdef __USE_XOPEN2K8
113 /* Compare S1 and S2, ignoring case. */
114 extern int wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) __THROW;
116 /* Compare no more than N chars of S1 and S2, ignoring case. */
117 extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2,
118 size_t __n) __THROW;
120 /* Similar to the two functions above but take the information from
121 the provided locale and not the global locale. */
122 extern int wcscasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
123 locale_t __loc) __THROW;
125 extern int wcsncasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
126 size_t __n, locale_t __loc) __THROW;
127 #endif
129 /* Compare S1 and S2, both interpreted as appropriate to the
130 LC_COLLATE category of the current locale. */
131 extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW;
132 /* Transform S2 into array pointed to by S1 such that if wcscmp is
133 applied to two transformed strings the result is the as applying
134 `wcscoll' to the original strings. */
135 extern size_t wcsxfrm (wchar_t *__restrict __s1,
136 const wchar_t *__restrict __s2, size_t __n) __THROW;
138 #ifdef __USE_XOPEN2K8
139 /* Similar to the two functions above but take the information from
140 the provided locale and not the global locale. */
142 /* Compare S1 and S2, both interpreted as appropriate to the
143 LC_COLLATE category of the given locale. */
144 extern int wcscoll_l (const wchar_t *__s1, const wchar_t *__s2,
145 locale_t __loc) __THROW;
147 /* Transform S2 into array pointed to by S1 such that if wcscmp is
148 applied to two transformed strings the result is the as applying
149 `wcscoll' to the original strings. */
150 extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2,
151 size_t __n, locale_t __loc) __THROW;
153 /* Duplicate S, returning an identical malloc'd string. */
154 extern wchar_t *wcsdup (const wchar_t *__s) __THROW
155 __attribute_malloc__ __attr_dealloc_free;
156 #endif
158 /* Find the first occurrence of WC in WCS. */
159 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
160 extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc)
161 __THROW __asm ("wcschr") __attribute_pure__;
162 extern "C++" const wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
163 __THROW __asm ("wcschr") __attribute_pure__;
164 #else
165 extern wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
166 __THROW __attribute_pure__;
167 #endif
168 /* Find the last occurrence of WC in WCS. */
169 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
170 extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc)
171 __THROW __asm ("wcsrchr") __attribute_pure__;
172 extern "C++" const wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
173 __THROW __asm ("wcsrchr") __attribute_pure__;
174 #else
175 extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
176 __THROW __attribute_pure__;
177 #endif
179 #ifdef __USE_GNU
180 /* This function is similar to `wcschr'. But it returns a pointer to
181 the closing NUL wide character in case C is not found in S. */
182 extern wchar_t *wcschrnul (const wchar_t *__s, wchar_t __wc)
183 __THROW __attribute_pure__;
184 #endif
186 /* Return the length of the initial segmet of WCS which
187 consists entirely of wide characters not in REJECT. */
188 extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject)
189 __THROW __attribute_pure__;
190 /* Return the length of the initial segmet of WCS which
191 consists entirely of wide characters in ACCEPT. */
192 extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept)
193 __THROW __attribute_pure__;
194 /* Find the first occurrence in WCS of any character in ACCEPT. */
195 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
196 extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, const wchar_t *__accept)
197 __THROW __asm ("wcspbrk") __attribute_pure__;
198 extern "C++" const wchar_t *wcspbrk (const wchar_t *__wcs,
199 const wchar_t *__accept)
200 __THROW __asm ("wcspbrk") __attribute_pure__;
201 #else
202 extern wchar_t *wcspbrk (const wchar_t *__wcs, const wchar_t *__accept)
203 __THROW __attribute_pure__;
204 #endif
205 /* Find the first occurrence of NEEDLE in HAYSTACK. */
206 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
207 extern "C++" wchar_t *wcsstr (wchar_t *__haystack, const wchar_t *__needle)
208 __THROW __asm ("wcsstr") __attribute_pure__;
209 extern "C++" const wchar_t *wcsstr (const wchar_t *__haystack,
210 const wchar_t *__needle)
211 __THROW __asm ("wcsstr") __attribute_pure__;
212 #else
213 extern wchar_t *wcsstr (const wchar_t *__haystack, const wchar_t *__needle)
214 __THROW __attribute_pure__;
215 #endif
217 /* Divide WCS into tokens separated by characters in DELIM. */
218 extern wchar_t *wcstok (wchar_t *__restrict __s,
219 const wchar_t *__restrict __delim,
220 wchar_t **__restrict __ptr) __THROW;
222 /* Return the number of wide characters in S. */
223 extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__;
225 #ifdef __USE_XOPEN
226 /* Another name for `wcsstr' from XPG4. */
227 # ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
228 extern "C++" wchar_t *wcswcs (wchar_t *__haystack, const wchar_t *__needle)
229 __THROW __asm ("wcswcs") __attribute_pure__;
230 extern "C++" const wchar_t *wcswcs (const wchar_t *__haystack,
231 const wchar_t *__needle)
232 __THROW __asm ("wcswcs") __attribute_pure__;
233 # else
234 extern wchar_t *wcswcs (const wchar_t *__haystack, const wchar_t *__needle)
235 __THROW __attribute_pure__;
236 # endif
237 #endif
239 #ifdef __USE_XOPEN2K8
240 /* Return the number of wide characters in S, but at most MAXLEN. */
241 extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen)
242 __THROW __attribute_pure__;
243 #endif
246 /* Search N wide characters of S for C. */
247 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
248 extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n)
249 __THROW __asm ("wmemchr") __attribute_pure__;
250 extern "C++" const wchar_t *wmemchr (const wchar_t *__s, wchar_t __c,
251 size_t __n)
252 __THROW __asm ("wmemchr") __attribute_pure__;
253 #else
254 extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n)
255 __THROW __attribute_pure__;
256 #endif
258 /* Compare N wide characters of S1 and S2. */
259 extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
260 __THROW __attribute_pure__;
262 /* Copy N wide characters of SRC to DEST. */
263 extern wchar_t *wmemcpy (wchar_t *__restrict __s1,
264 const wchar_t *__restrict __s2, size_t __n) __THROW;
266 /* Copy N wide characters of SRC to DEST, guaranteeing
267 correct behavior for overlapping strings. */
268 extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)
269 __THROW;
271 /* Set N wide characters of S to C. */
272 extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
274 #ifdef __USE_GNU
275 /* Copy N wide characters of SRC to DEST and return pointer to following
276 wide character. */
277 extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
278 const wchar_t *__restrict __s2, size_t __n)
279 __THROW;
280 #endif
283 /* Determine whether C constitutes a valid (one-byte) multibyte
284 character. */
285 extern wint_t btowc (int __c) __THROW;
287 /* Determine whether C corresponds to a member of the extended
288 character set whose multibyte representation is a single byte. */
289 extern int wctob (wint_t __c) __THROW;
291 /* Determine whether PS points to an object representing the initial
292 state. */
293 extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__;
295 /* Write wide character representation of multibyte character pointed
296 to by S to PWC. */
297 extern size_t mbrtowc (wchar_t *__restrict __pwc,
298 const char *__restrict __s, size_t __n,
299 mbstate_t *__restrict __p) __THROW;
301 /* Write multibyte representation of wide character WC to S. */
302 extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
303 mbstate_t *__restrict __ps) __THROW;
305 /* Return number of bytes in multibyte character pointed to by S. */
306 extern size_t __mbrlen (const char *__restrict __s, size_t __n,
307 mbstate_t *__restrict __ps) __THROW;
308 extern size_t mbrlen (const char *__restrict __s, size_t __n,
309 mbstate_t *__restrict __ps) __THROW;
311 #ifdef __USE_EXTERN_INLINES
312 /* Define inline function as optimization. */
314 /* We can use the BTOWC and WCTOB optimizations since we know that all
315 locales must use ASCII encoding for the values in the ASCII range
316 and because the wchar_t encoding is always ISO 10646. */
317 extern wint_t __btowc_alias (int __c) __asm ("btowc");
318 __extern_inline wint_t
319 __NTH (btowc (int __c))
320 { return (__builtin_constant_p (__c) && __c >= '\0' && __c <= '\x7f'
321 ? (wint_t) __c : __btowc_alias (__c)); }
323 extern int __wctob_alias (wint_t __c) __asm ("wctob");
324 __extern_inline int
325 __NTH (wctob (wint_t __wc))
326 { return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f'
327 ? (int) __wc : __wctob_alias (__wc)); }
329 __extern_inline size_t
330 __NTH (mbrlen (const char *__restrict __s, size_t __n,
331 mbstate_t *__restrict __ps))
332 { return (__ps != NULL
333 ? mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); }
334 #endif
336 /* Write wide character representation of multibyte character string
337 SRC to DST. */
338 extern size_t mbsrtowcs (wchar_t *__restrict __dst,
339 const char **__restrict __src, size_t __len,
340 mbstate_t *__restrict __ps) __THROW;
342 /* Write multibyte character representation of wide character string
343 SRC to DST. */
344 extern size_t wcsrtombs (char *__restrict __dst,
345 const wchar_t **__restrict __src, size_t __len,
346 mbstate_t *__restrict __ps) __THROW;
349 #ifdef __USE_XOPEN2K8
350 /* Write wide character representation of at most NMC bytes of the
351 multibyte character string SRC to DST. */
352 extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
353 const char **__restrict __src, size_t __nmc,
354 size_t __len, mbstate_t *__restrict __ps) __THROW;
356 /* Write multibyte character representation of at most NWC characters
357 from the wide character string SRC to DST. */
358 extern size_t wcsnrtombs (char *__restrict __dst,
359 const wchar_t **__restrict __src,
360 size_t __nwc, size_t __len,
361 mbstate_t *__restrict __ps) __THROW;
362 #endif /* use POSIX 2008 */
365 /* The following functions are extensions found in X/Open CAE. */
366 #ifdef __USE_XOPEN
367 /* Determine number of column positions required for C. */
368 extern int wcwidth (wchar_t __c) __THROW;
370 /* Determine number of column positions required for first N wide
371 characters (or fewer if S ends before this) in S. */
372 extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
373 #endif /* Use X/Open. */
376 /* Convert initial portion of the wide string NPTR to `double'
377 representation. */
378 extern double wcstod (const wchar_t *__restrict __nptr,
379 wchar_t **__restrict __endptr) __THROW;
381 #ifdef __USE_ISOC99
382 /* Likewise for `float' and `long double' sizes of floating-point numbers. */
383 extern float wcstof (const wchar_t *__restrict __nptr,
384 wchar_t **__restrict __endptr) __THROW;
385 extern long double wcstold (const wchar_t *__restrict __nptr,
386 wchar_t **__restrict __endptr) __THROW;
387 #endif /* C99 */
389 #if __GLIBC_USE (IEC_60559_TYPES_EXT) && __GLIBC_USE (ISOC2X)
390 /* Likewise for `_FloatN' and `_FloatNx' when support is enabled. */
392 # if __HAVE_FLOAT16
393 extern _Float16 wcstof16 (const wchar_t *__restrict __nptr,
394 wchar_t **__restrict __endptr) __THROW;
395 # endif
397 # if __HAVE_FLOAT32
398 extern _Float32 wcstof32 (const wchar_t *__restrict __nptr,
399 wchar_t **__restrict __endptr) __THROW;
400 # endif
402 # if __HAVE_FLOAT64
403 extern _Float64 wcstof64 (const wchar_t *__restrict __nptr,
404 wchar_t **__restrict __endptr) __THROW;
405 # endif
407 # if __HAVE_FLOAT128
408 extern _Float128 wcstof128 (const wchar_t *__restrict __nptr,
409 wchar_t **__restrict __endptr) __THROW;
410 # endif
412 # if __HAVE_FLOAT32X
413 extern _Float32x wcstof32x (const wchar_t *__restrict __nptr,
414 wchar_t **__restrict __endptr) __THROW;
415 # endif
417 # if __HAVE_FLOAT64X
418 extern _Float64x wcstof64x (const wchar_t *__restrict __nptr,
419 wchar_t **__restrict __endptr) __THROW;
420 # endif
422 # if __HAVE_FLOAT128X
423 extern _Float128x wcstof128x (const wchar_t *__restrict __nptr,
424 wchar_t **__restrict __endptr) __THROW;
425 # endif
426 #endif /* __GLIBC_USE (IEC_60559_TYPES_EXT) && __GLIBC_USE (ISOC2X) */
429 /* Convert initial portion of wide string NPTR to `long int'
430 representation. */
431 extern long int wcstol (const wchar_t *__restrict __nptr,
432 wchar_t **__restrict __endptr, int __base) __THROW;
434 /* Convert initial portion of wide string NPTR to `unsigned long int'
435 representation. */
436 extern unsigned long int wcstoul (const wchar_t *__restrict __nptr,
437 wchar_t **__restrict __endptr, int __base)
438 __THROW;
440 #ifdef __USE_ISOC99
441 /* Convert initial portion of wide string NPTR to `long long int'
442 representation. */
443 __extension__
444 extern long long int wcstoll (const wchar_t *__restrict __nptr,
445 wchar_t **__restrict __endptr, int __base)
446 __THROW;
448 /* Convert initial portion of wide string NPTR to `unsigned long long int'
449 representation. */
450 __extension__
451 extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr,
452 wchar_t **__restrict __endptr,
453 int __base) __THROW;
454 #endif /* ISO C99. */
456 #ifdef __USE_GNU
457 /* Convert initial portion of wide string NPTR to `long long int'
458 representation. */
459 __extension__
460 extern long long int wcstoq (const wchar_t *__restrict __nptr,
461 wchar_t **__restrict __endptr, int __base)
462 __THROW;
464 /* Convert initial portion of wide string NPTR to `unsigned long long int'
465 representation. */
466 __extension__
467 extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr,
468 wchar_t **__restrict __endptr,
469 int __base) __THROW;
470 #endif /* Use GNU. */
472 /* Versions of the above functions that handle '0b' and '0B' prefixes
473 in base 0 or 2. */
474 #if __GLIBC_USE (C2X_STRTOL)
475 # ifdef __REDIRECT
476 extern long int __REDIRECT_NTH (wcstol, (const wchar_t *__restrict __nptr,
477 wchar_t **__restrict __endptr,
478 int __base), __isoc23_wcstol);
479 extern unsigned long int __REDIRECT_NTH (wcstoul,
480 (const wchar_t *__restrict __nptr,
481 wchar_t **__restrict __endptr,
482 int __base), __isoc23_wcstoul);
483 __extension__
484 extern long long int __REDIRECT_NTH (wcstoll,
485 (const wchar_t *__restrict __nptr,
486 wchar_t **__restrict __endptr,
487 int __base), __isoc23_wcstoll);
488 __extension__
489 extern unsigned long long int __REDIRECT_NTH (wcstoull,
490 (const wchar_t *__restrict __nptr,
491 wchar_t **__restrict __endptr,
492 int __base), __isoc23_wcstoull);
493 # ifdef __USE_GNU
494 __extension__
495 extern long long int __REDIRECT_NTH (wcstoq, (const wchar_t *__restrict __nptr,
496 wchar_t **__restrict __endptr,
497 int __base), __isoc23_wcstoll);
498 __extension__
499 extern unsigned long long int __REDIRECT_NTH (wcstouq,
500 (const wchar_t *__restrict __nptr,
501 wchar_t **__restrict __endptr,
502 int __base), __isoc23_wcstoull);
503 # endif
504 # else
505 extern long int __isoc23_wcstol (const wchar_t *__restrict __nptr,
506 wchar_t **__restrict __endptr, int __base)
507 __THROW;
508 extern unsigned long int __isoc23_wcstoul (const wchar_t *__restrict __nptr,
509 wchar_t **__restrict __endptr,
510 int __base)
511 __THROW;
512 __extension__
513 extern long long int __isoc23_wcstoll (const wchar_t *__restrict __nptr,
514 wchar_t **__restrict __endptr,
515 int __base)
516 __THROW;
517 __extension__
518 extern unsigned long long int __isoc23_wcstoull (const wchar_t *__restrict __nptr,
519 wchar_t **__restrict __endptr,
520 int __base)
521 __THROW;
522 # define wcstol __isoc23_wcstol
523 # define wcstoul __isoc23_wcstoul
524 # define wcstoll __isoc23_wcstoll
525 # define wcstoull __isoc23_wcstoull
526 # ifdef __USE_GNU
527 # define wcstoq __isoc23_wcstoll
528 # define wcstouq __isoc23_wcstoull
529 # endif
530 # endif
531 #endif
533 #ifdef __USE_GNU
534 /* Parallel versions of the functions above which take the locale to
535 use as an additional parameter. These are GNU extensions inspired
536 by the POSIX.1-2008 extended locale API. */
537 extern long int wcstol_l (const wchar_t *__restrict __nptr,
538 wchar_t **__restrict __endptr, int __base,
539 locale_t __loc) __THROW;
541 extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr,
542 wchar_t **__restrict __endptr,
543 int __base, locale_t __loc) __THROW;
545 __extension__
546 extern long long int wcstoll_l (const wchar_t *__restrict __nptr,
547 wchar_t **__restrict __endptr,
548 int __base, locale_t __loc) __THROW;
550 __extension__
551 extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr,
552 wchar_t **__restrict __endptr,
553 int __base, locale_t __loc)
554 __THROW;
556 /* Versions of the above functions that handle '0b' and '0B' prefixes
557 in base 0 or 2. */
558 # if __GLIBC_USE (C2X_STRTOL)
559 # ifdef __REDIRECT
560 extern long int __REDIRECT_NTH (wcstol_l, (const wchar_t *__restrict __nptr,
561 wchar_t **__restrict __endptr,
562 int __base, locale_t __loc),
563 __isoc23_wcstol_l);
564 extern unsigned long int __REDIRECT_NTH (wcstoul_l,
565 (const wchar_t *__restrict __nptr,
566 wchar_t **__restrict __endptr,
567 int __base, locale_t __loc),
568 __isoc23_wcstoul_l);
569 __extension__
570 extern long long int __REDIRECT_NTH (wcstoll_l,
571 (const wchar_t *__restrict __nptr,
572 wchar_t **__restrict __endptr,
573 int __base, locale_t __loc),
574 __isoc23_wcstoll_l);
575 __extension__
576 extern unsigned long long int __REDIRECT_NTH (wcstoull_l,
577 (const wchar_t *__restrict __nptr,
578 wchar_t **__restrict __endptr,
579 int __base, locale_t __loc),
580 __isoc23_wcstoull_l);
581 # else
582 extern long int __isoc23_wcstol_l (const wchar_t *__restrict __nptr,
583 wchar_t **__restrict __endptr, int __base,
584 locale_t __loc) __THROW;
585 extern unsigned long int __isoc23_wcstoul_l (const wchar_t *__restrict __nptr,
586 wchar_t **__restrict __endptr,
587 int __base, locale_t __loc)
588 __THROW;
589 __extension__
590 extern long long int __isoc23_wcstoll_l (const wchar_t *__restrict __nptr,
591 wchar_t **__restrict __endptr,
592 int __base, locale_t __loc)
593 __THROW;
594 __extension__
595 extern unsigned long long int __isoc23_wcstoull_l (const wchar_t *__restrict __nptr,
596 wchar_t **__restrict __endptr,
597 int __base, locale_t __loc)
598 __THROW;
599 # define wcstol_l __isoc23_wcstol_l
600 # define wcstoul_l __isoc23_wcstoul_l
601 # define wcstoll_l __isoc23_wcstoll_l
602 # define wcstoull_l __isoc23_wcstoull_l
603 # endif
604 # endif
606 extern double wcstod_l (const wchar_t *__restrict __nptr,
607 wchar_t **__restrict __endptr, locale_t __loc)
608 __THROW;
610 extern float wcstof_l (const wchar_t *__restrict __nptr,
611 wchar_t **__restrict __endptr, locale_t __loc)
612 __THROW;
614 extern long double wcstold_l (const wchar_t *__restrict __nptr,
615 wchar_t **__restrict __endptr,
616 locale_t __loc) __THROW;
618 # if __HAVE_FLOAT16
619 extern _Float16 wcstof16_l (const wchar_t *__restrict __nptr,
620 wchar_t **__restrict __endptr,
621 locale_t __loc) __THROW;
622 # endif
624 # if __HAVE_FLOAT32
625 extern _Float32 wcstof32_l (const wchar_t *__restrict __nptr,
626 wchar_t **__restrict __endptr,
627 locale_t __loc) __THROW;
628 # endif
630 # if __HAVE_FLOAT64
631 extern _Float64 wcstof64_l (const wchar_t *__restrict __nptr,
632 wchar_t **__restrict __endptr,
633 locale_t __loc) __THROW;
634 # endif
636 # if __HAVE_FLOAT128
637 extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr,
638 wchar_t **__restrict __endptr,
639 locale_t __loc) __THROW;
640 # endif
642 # if __HAVE_FLOAT32X
643 extern _Float32x wcstof32x_l (const wchar_t *__restrict __nptr,
644 wchar_t **__restrict __endptr,
645 locale_t __loc) __THROW;
646 # endif
648 # if __HAVE_FLOAT64X
649 extern _Float64x wcstof64x_l (const wchar_t *__restrict __nptr,
650 wchar_t **__restrict __endptr,
651 locale_t __loc) __THROW;
652 # endif
654 # if __HAVE_FLOAT128X
655 extern _Float128x wcstof128x_l (const wchar_t *__restrict __nptr,
656 wchar_t **__restrict __endptr,
657 locale_t __loc) __THROW;
658 # endif
659 #endif /* use GNU */
662 #ifdef __USE_XOPEN2K8
663 /* Copy SRC to DEST, returning the address of the terminating L'\0' in
664 DEST. */
665 extern wchar_t *wcpcpy (wchar_t *__restrict __dest,
666 const wchar_t *__restrict __src) __THROW;
668 /* Copy no more than N characters of SRC to DEST, returning the address of
669 the last character written into DEST. */
670 extern wchar_t *wcpncpy (wchar_t *__restrict __dest,
671 const wchar_t *__restrict __src, size_t __n)
672 __THROW;
673 #endif
676 /* Wide character I/O functions. */
678 #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
679 # ifndef __attr_dealloc_fclose
680 # if defined __has_builtin
681 # if __has_builtin (__builtin_fclose)
682 /* If the attribute macro hasn't been defined yet (by <stdio.h>) and
683 fclose is a built-in, use it. */
684 # define __attr_dealloc_fclose __attr_dealloc (__builtin_fclose, 1)
685 # endif
686 # endif
687 # endif
688 # ifndef __attr_dealloc_fclose
689 # define __attr_dealloc_fclose /* empty */
690 # endif
692 /* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
693 a wide character string. */
694 extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW
695 __attribute_malloc__ __attr_dealloc_fclose;
696 #endif
698 #if defined __USE_ISOC95 || defined __USE_UNIX98
700 /* Select orientation for stream. */
701 extern int fwide (__FILE *__fp, int __mode) __THROW;
704 /* Write formatted output to STREAM.
706 This function is a possible cancellation point and therefore not
707 marked with __THROW. */
708 extern int fwprintf (__FILE *__restrict __stream,
709 const wchar_t *__restrict __format, ...)
710 /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
711 /* Write formatted output to stdout.
713 This function is a possible cancellation point and therefore not
714 marked with __THROW. */
715 extern int wprintf (const wchar_t *__restrict __format, ...)
716 /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
717 /* Write formatted output of at most N characters to S. */
718 extern int swprintf (wchar_t *__restrict __s, size_t __n,
719 const wchar_t *__restrict __format, ...)
720 __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
722 /* Write formatted output to S from argument list ARG.
724 This function is a possible cancellation point and therefore not
725 marked with __THROW. */
726 extern int vfwprintf (__FILE *__restrict __s,
727 const wchar_t *__restrict __format,
728 __gnuc_va_list __arg)
729 /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
730 /* Write formatted output to stdout from argument list ARG.
732 This function is a possible cancellation point and therefore not
733 marked with __THROW. */
734 extern int vwprintf (const wchar_t *__restrict __format,
735 __gnuc_va_list __arg)
736 /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */;
737 /* Write formatted output of at most N character to S from argument
738 list ARG. */
739 extern int vswprintf (wchar_t *__restrict __s, size_t __n,
740 const wchar_t *__restrict __format,
741 __gnuc_va_list __arg)
742 __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
745 /* Read formatted input from STREAM.
747 This function is a possible cancellation point and therefore not
748 marked with __THROW. */
749 extern int fwscanf (__FILE *__restrict __stream,
750 const wchar_t *__restrict __format, ...)
751 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
752 /* Read formatted input from stdin.
754 This function is a possible cancellation point and therefore not
755 marked with __THROW. */
756 extern int wscanf (const wchar_t *__restrict __format, ...)
757 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
758 /* Read formatted input from S. */
759 extern int swscanf (const wchar_t *__restrict __s,
760 const wchar_t *__restrict __format, ...)
761 __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
763 /* For historical reasons, the C99-compliant versions of the scanf
764 functions are at alternative names. When __LDBL_COMPAT or
765 __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI are in effect, this is handled in
766 bits/wchar-ldbl.h. */
767 # if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
768 && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
769 # if __GLIBC_USE (C2X_STRTOL)
770 # ifdef __REDIRECT
771 extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
772 const wchar_t *__restrict __format, ...),
773 __isoc23_fwscanf)
774 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
775 extern int __REDIRECT (wscanf, (const wchar_t *__restrict __format, ...),
776 __isoc23_wscanf)
777 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
778 extern int __REDIRECT_NTH (swscanf, (const wchar_t *__restrict __s,
779 const wchar_t *__restrict __format,
780 ...), __isoc23_swscanf)
781 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
782 # else
783 extern int __isoc23_fwscanf (__FILE *__restrict __stream,
784 const wchar_t *__restrict __format, ...);
785 extern int __isoc23_wscanf (const wchar_t *__restrict __format, ...);
786 extern int __isoc23_swscanf (const wchar_t *__restrict __s,
787 const wchar_t *__restrict __format, ...)
788 __THROW;
789 # define fwscanf __isoc23_fwscanf
790 # define wscanf __isoc23_wscanf
791 # define swscanf __isoc23_swscanf
792 # endif
793 # else
794 # ifdef __REDIRECT
795 extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
796 const wchar_t *__restrict __format, ...),
797 __isoc99_fwscanf)
798 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
799 extern int __REDIRECT (wscanf, (const wchar_t *__restrict __format, ...),
800 __isoc99_wscanf)
801 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
802 extern int __REDIRECT_NTH (swscanf, (const wchar_t *__restrict __s,
803 const wchar_t *__restrict __format,
804 ...), __isoc99_swscanf)
805 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
806 # else
807 extern int __isoc99_fwscanf (__FILE *__restrict __stream,
808 const wchar_t *__restrict __format, ...);
809 extern int __isoc99_wscanf (const wchar_t *__restrict __format, ...);
810 extern int __isoc99_swscanf (const wchar_t *__restrict __s,
811 const wchar_t *__restrict __format, ...)
812 __THROW;
813 # define fwscanf __isoc99_fwscanf
814 # define wscanf __isoc99_wscanf
815 # define swscanf __isoc99_swscanf
816 # endif
817 # endif
818 # endif
820 #endif /* Use ISO C95, C99 and Unix98. */
822 #ifdef __USE_ISOC99
823 /* Read formatted input from S into argument list ARG.
825 This function is a possible cancellation point and therefore not
826 marked with __THROW. */
827 extern int vfwscanf (__FILE *__restrict __s,
828 const wchar_t *__restrict __format,
829 __gnuc_va_list __arg)
830 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
831 /* Read formatted input from stdin into argument list ARG.
833 This function is a possible cancellation point and therefore not
834 marked with __THROW. */
835 extern int vwscanf (const wchar_t *__restrict __format,
836 __gnuc_va_list __arg)
837 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
838 /* Read formatted input from S into argument list ARG. */
839 extern int vswscanf (const wchar_t *__restrict __s,
840 const wchar_t *__restrict __format,
841 __gnuc_va_list __arg)
842 __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
844 /* Same redirection as above for the v*wscanf family. */
845 # if !__GLIBC_USE (DEPRECATED_SCANF) \
846 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
847 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) \
848 && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
849 # if __GLIBC_USE (C2X_STRTOL)
850 # ifdef __REDIRECT
851 extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
852 const wchar_t *__restrict __format,
853 __gnuc_va_list __arg), __isoc23_vfwscanf)
854 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
855 extern int __REDIRECT (vwscanf, (const wchar_t *__restrict __format,
856 __gnuc_va_list __arg), __isoc23_vwscanf)
857 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
858 extern int __REDIRECT_NTH (vswscanf, (const wchar_t *__restrict __s,
859 const wchar_t *__restrict __format,
860 __gnuc_va_list __arg), __isoc23_vswscanf)
861 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
862 # else
863 extern int __isoc23_vfwscanf (__FILE *__restrict __s,
864 const wchar_t *__restrict __format,
865 __gnuc_va_list __arg);
866 extern int __isoc23_vwscanf (const wchar_t *__restrict __format,
867 __gnuc_va_list __arg);
868 extern int __isoc23_vswscanf (const wchar_t *__restrict __s,
869 const wchar_t *__restrict __format,
870 __gnuc_va_list __arg) __THROW;
871 # define vfwscanf __isoc23_vfwscanf
872 # define vwscanf __isoc23_vwscanf
873 # define vswscanf __isoc23_vswscanf
874 # endif
875 # else
876 # ifdef __REDIRECT
877 extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
878 const wchar_t *__restrict __format,
879 __gnuc_va_list __arg), __isoc99_vfwscanf)
880 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
881 extern int __REDIRECT (vwscanf, (const wchar_t *__restrict __format,
882 __gnuc_va_list __arg), __isoc99_vwscanf)
883 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
884 extern int __REDIRECT_NTH (vswscanf, (const wchar_t *__restrict __s,
885 const wchar_t *__restrict __format,
886 __gnuc_va_list __arg), __isoc99_vswscanf)
887 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
888 # else
889 extern int __isoc99_vfwscanf (__FILE *__restrict __s,
890 const wchar_t *__restrict __format,
891 __gnuc_va_list __arg);
892 extern int __isoc99_vwscanf (const wchar_t *__restrict __format,
893 __gnuc_va_list __arg);
894 extern int __isoc99_vswscanf (const wchar_t *__restrict __s,
895 const wchar_t *__restrict __format,
896 __gnuc_va_list __arg) __THROW;
897 # define vfwscanf __isoc99_vfwscanf
898 # define vwscanf __isoc99_vwscanf
899 # define vswscanf __isoc99_vswscanf
900 # endif
901 # endif
902 # endif
904 #endif /* Use ISO C99. */
907 /* Read a character from STREAM.
909 These functions are possible cancellation points and therefore not
910 marked with __THROW. */
911 extern wint_t fgetwc (__FILE *__stream);
912 extern wint_t getwc (__FILE *__stream);
914 /* Read a character from stdin.
916 This function is a possible cancellation point and therefore not
917 marked with __THROW. */
918 extern wint_t getwchar (void);
921 /* Write a character to STREAM.
923 These functions are possible cancellation points and therefore not
924 marked with __THROW. */
925 extern wint_t fputwc (wchar_t __wc, __FILE *__stream);
926 extern wint_t putwc (wchar_t __wc, __FILE *__stream);
928 /* Write a character to stdout.
930 This function is a possible cancellation point and therefore not
931 marked with __THROW. */
932 extern wint_t putwchar (wchar_t __wc);
935 /* Get a newline-terminated wide character string of finite length
936 from STREAM.
938 This function is a possible cancellation point and therefore not
939 marked with __THROW. */
940 extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
941 __FILE *__restrict __stream);
943 /* Write a string to STREAM.
945 This function is a possible cancellation point and therefore not
946 marked with __THROW. */
947 extern int fputws (const wchar_t *__restrict __ws,
948 __FILE *__restrict __stream);
951 /* Push a character back onto the input buffer of STREAM.
953 This function is a possible cancellation point and therefore not
954 marked with __THROW. */
955 extern wint_t ungetwc (wint_t __wc, __FILE *__stream);
958 #ifdef __USE_GNU
959 /* These are defined to be equivalent to the `char' functions defined
960 in POSIX.1:1996.
962 These functions are not part of POSIX and therefore no official
963 cancellation point. But due to similarity with an POSIX interface
964 or due to the implementation they are cancellation points and
965 therefore not marked with __THROW. */
966 extern wint_t getwc_unlocked (__FILE *__stream);
967 extern wint_t getwchar_unlocked (void);
969 /* This is the wide character version of a GNU extension.
971 This function is not part of POSIX and therefore no official
972 cancellation point. But due to similarity with an POSIX interface
973 or due to the implementation it is a cancellation point and
974 therefore not marked with __THROW. */
975 extern wint_t fgetwc_unlocked (__FILE *__stream);
977 /* Faster version when locking is not necessary.
979 This function is not part of POSIX and therefore no official
980 cancellation point. But due to similarity with an POSIX interface
981 or due to the implementation it is a cancellation point and
982 therefore not marked with __THROW. */
983 extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream);
985 /* These are defined to be equivalent to the `char' functions defined
986 in POSIX.1:1996.
988 These functions are not part of POSIX and therefore no official
989 cancellation point. But due to similarity with an POSIX interface
990 or due to the implementation they are cancellation points and
991 therefore not marked with __THROW. */
992 extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream);
993 extern wint_t putwchar_unlocked (wchar_t __wc);
996 /* This function does the same as `fgetws' but does not lock the stream.
998 This function is not part of POSIX and therefore no official
999 cancellation point. But due to similarity with an POSIX interface
1000 or due to the implementation it is a cancellation point and
1001 therefore not marked with __THROW. */
1002 extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
1003 __FILE *__restrict __stream);
1005 /* This function does the same as `fputws' but does not lock the stream.
1007 This function is not part of POSIX and therefore no official
1008 cancellation point. But due to similarity with an POSIX interface
1009 or due to the implementation it is a cancellation point and
1010 therefore not marked with __THROW. */
1011 extern int fputws_unlocked (const wchar_t *__restrict __ws,
1012 __FILE *__restrict __stream);
1013 #endif
1016 /* Format TP into S according to FORMAT.
1017 Write no more than MAXSIZE wide characters and return the number
1018 of wide characters written, or 0 if it would exceed MAXSIZE. */
1019 extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
1020 const wchar_t *__restrict __format,
1021 const struct tm *__restrict __tp) __THROW;
1023 # ifdef __USE_GNU
1024 /* Similar to `wcsftime' but takes the information from
1025 the provided locale and not the global locale. */
1026 extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
1027 const wchar_t *__restrict __format,
1028 const struct tm *__restrict __tp,
1029 locale_t __loc) __THROW;
1030 # endif
1032 /* Define some macros helping to catch buffer overflows. */
1033 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
1034 /* Declare all functions from bits/wchar2-decl.h first. */
1035 # include <bits/wchar2-decl.h>
1036 #endif
1038 /* The following headers provide asm redirections. These redirections must
1039 appear before the first usage of these functions, e.g. in bits/wchar.h. */
1040 #if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
1041 # include <bits/wchar-ldbl.h>
1042 #endif
1044 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
1045 /* Now include the function definitions and redirects too. */
1046 # include <bits/wchar2.h>
1047 #endif
1049 __END_DECLS
1051 #endif /* wchar.h */