]> git.ipfire.org Git - thirdparty/glibc.git/blame - wcsmbs/wchar.h
Rename __LONG_DOUBLE_USES_FLOAT128 to __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI
[thirdparty/glibc.git] / wcsmbs / wchar.h
CommitLineData
d614a753 1/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
b5791037 2 This file is part of the GNU C Library.
30de3b18 3
b5791037 4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
30de3b18 8
b5791037
UD
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
41bdb6e2 12 Lesser General Public License for more details.
30de3b18 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6 15 License along with the GNU C Library; if not, see
5a82c748 16 <https://www.gnu.org/licenses/>. */
30de3b18
RM
17
18/*
d1646309
UD
19 * ISO C99 Standard: 7.24
20 * Extended multibyte and wide character utilities <wchar.h>
30de3b18
RM
21 */
22
23#ifndef _WCHAR_H
199fc19d 24#define _WCHAR_H 1
5107cf1d 25
199fc19d
ZW
26#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
27#include <bits/libc-header-start.h>
30de3b18 28
45f39d45
PM
29/* Gather machine dependent type support. */
30#include <bits/floatn.h>
31
199fc19d
ZW
32#define __need_size_t
33#define __need_wchar_t
34#define __need_NULL
35#include <stddef.h>
30de3b18 36
199fc19d
ZW
37#define __need___va_list
38#include <stdarg.h>
7b503bcc 39
199fc19d
ZW
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>
9ac9129d 44
199fc19d
ZW
45#if defined __USE_UNIX98 || defined __USE_XOPEN2K
46# include <bits/types/FILE.h>
71a40c74 47#endif
f0be25b6
ZW
48#ifdef __USE_XOPEN2K8
49# include <bits/types/locale_t.h>
50#endif
71a40c74 51
199fc19d
ZW
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
d64b6ad0 55#endif
db6af3eb 56
cc3fa755
UD
57#ifndef WCHAR_MIN
58/* These constants might also be defined in <inttypes.h>. */
417bafec
UD
59# define WCHAR_MIN __WCHAR_MIN
60# define WCHAR_MAX __WCHAR_MAX
cc3fa755 61#endif
30de3b18
RM
62
63#ifndef WEOF
64# define WEOF (0xffffffffu)
65#endif
66
199fc19d
ZW
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>
e918a7fe
UD
77#endif
78
7a5affeb
UD
79__BEGIN_DECLS
80
9756dfe1
UD
81/* This incomplete type is defined in <time.h> but needed here because
82 of `wcsftime'. */
83struct tm;
84
85
30de3b18 86/* Copy SRC to DEST. */
c1422e5b 87extern wchar_t *wcscpy (wchar_t *__restrict __dest,
a6ab6ccd
DM
88 const wchar_t *__restrict __src)
89 __THROW __nonnull ((1, 2));
90
30de3b18 91/* Copy no more than N wide-characters of SRC to DEST. */
c1422e5b 92extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
a784e502 93 const wchar_t *__restrict __src, size_t __n)
a6ab6ccd 94 __THROW __nonnull ((1, 2));
30de3b18
RM
95
96/* Append SRC onto DEST. */
c1422e5b 97extern wchar_t *wcscat (wchar_t *__restrict __dest,
aeb47bbc
DM
98 const wchar_t *__restrict __src)
99 __THROW __nonnull ((1, 2));
30de3b18 100/* Append no more than N wide-characters of SRC onto DEST. */
c1422e5b 101extern wchar_t *wcsncat (wchar_t *__restrict __dest,
a784e502 102 const wchar_t *__restrict __src, size_t __n)
aeb47bbc 103 __THROW __nonnull ((1, 2));
30de3b18
RM
104
105/* Compare S1 and S2. */
a784e502 106extern int wcscmp (const wchar_t *__s1, const wchar_t *__s2)
aeb47bbc 107 __THROW __attribute_pure__ __nonnull ((1, 2));
30de3b18 108/* Compare N wide-characters of S1 and S2. */
a784e502 109extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
aeb47bbc 110 __THROW __attribute_pure__ __nonnull ((1, 2));
30de3b18 111
6cbe890a 112#ifdef __USE_XOPEN2K8
2f6d1f1b 113/* Compare S1 and S2, ignoring case. */
a784e502 114extern int wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) __THROW;
2f6d1f1b
UD
115
116/* Compare no more than N chars of S1 and S2, ignoring case. */
a784e502 117extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2,
c1422e5b 118 size_t __n) __THROW;
0501d603
UD
119
120/* Similar to the two functions above but take the information from
121 the provided locale and not the global locale. */
a784e502 122extern int wcscasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
af85385f 123 locale_t __loc) __THROW;
0501d603 124
a784e502 125extern int wcsncasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
af85385f 126 size_t __n, locale_t __loc) __THROW;
2f6d1f1b
UD
127#endif
128
75cd5204
RM
129/* Compare S1 and S2, both interpreted as appropriate to the
130 LC_COLLATE category of the current locale. */
a784e502 131extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW;
75cd5204
RM
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. */
c1422e5b 135extern size_t wcsxfrm (wchar_t *__restrict __s1,
a784e502 136 const wchar_t *__restrict __s2, size_t __n) __THROW;
75cd5204 137
6cbe890a 138#ifdef __USE_XOPEN2K8
c84142e8
UD
139/* Similar to the two functions above but take the information from
140 the provided locale and not the global locale. */
c84142e8
UD
141
142/* Compare S1 and S2, both interpreted as appropriate to the
143 LC_COLLATE category of the given locale. */
a784e502 144extern int wcscoll_l (const wchar_t *__s1, const wchar_t *__s2,
af85385f 145 locale_t __loc) __THROW;
1ab62b32 146
c84142e8
UD
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. */
a784e502 150extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2,
af85385f 151 size_t __n, locale_t __loc) __THROW;
c84142e8 152
30de3b18 153/* Duplicate S, returning an identical malloc'd string. */
a784e502 154extern wchar_t *wcsdup (const wchar_t *__s) __THROW __attribute_malloc__;
1618c590 155#endif
30de3b18 156
6d52618b 157/* Find the first occurrence of WC in WCS. */
d8387c7b
UD
158#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
159extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc)
160 __THROW __asm ("wcschr") __attribute_pure__;
a784e502 161extern "C++" const wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
9ac9129d 162 __THROW __asm ("wcschr") __attribute_pure__;
d8387c7b 163#else
a784e502 164extern wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
fb4dfa0c 165 __THROW __attribute_pure__;
d8387c7b 166#endif
6d52618b 167/* Find the last occurrence of WC in WCS. */
d8387c7b
UD
168#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
169extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc)
170 __THROW __asm ("wcsrchr") __attribute_pure__;
a784e502 171extern "C++" const wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
d8387c7b
UD
172 __THROW __asm ("wcsrchr") __attribute_pure__;
173#else
a784e502 174extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
fb4dfa0c 175 __THROW __attribute_pure__;
d8387c7b 176#endif
30de3b18 177
d64b6ad0 178#ifdef __USE_GNU
557a9213 179/* This function is similar to `wcschr'. But it returns a pointer to
d64b6ad0 180 the closing NUL wide character in case C is not found in S. */
a784e502 181extern wchar_t *wcschrnul (const wchar_t *__s, wchar_t __wc)
fb4dfa0c 182 __THROW __attribute_pure__;
d64b6ad0
UD
183#endif
184
30de3b18 185/* Return the length of the initial segmet of WCS which
1618c590 186 consists entirely of wide characters not in REJECT. */
a784e502 187extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject)
fb4dfa0c 188 __THROW __attribute_pure__;
30de3b18 189/* Return the length of the initial segmet of WCS which
1618c590 190 consists entirely of wide characters in ACCEPT. */
a784e502 191extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept)
fb4dfa0c 192 __THROW __attribute_pure__;
6d52618b 193/* Find the first occurrence in WCS of any character in ACCEPT. */
d8387c7b 194#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
a784e502 195extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, const wchar_t *__accept)
d8387c7b 196 __THROW __asm ("wcspbrk") __attribute_pure__;
a784e502
UD
197extern "C++" const wchar_t *wcspbrk (const wchar_t *__wcs,
198 const wchar_t *__accept)
d8387c7b
UD
199 __THROW __asm ("wcspbrk") __attribute_pure__;
200#else
a784e502 201extern wchar_t *wcspbrk (const wchar_t *__wcs, const wchar_t *__accept)
fb4dfa0c 202 __THROW __attribute_pure__;
d8387c7b 203#endif
6d52618b 204/* Find the first occurrence of NEEDLE in HAYSTACK. */
d8387c7b 205#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
a784e502 206extern "C++" wchar_t *wcsstr (wchar_t *__haystack, const wchar_t *__needle)
d8387c7b 207 __THROW __asm ("wcsstr") __attribute_pure__;
a784e502
UD
208extern "C++" const wchar_t *wcsstr (const wchar_t *__haystack,
209 const wchar_t *__needle)
d8387c7b
UD
210 __THROW __asm ("wcsstr") __attribute_pure__;
211#else
a784e502 212extern wchar_t *wcsstr (const wchar_t *__haystack, const wchar_t *__needle)
fb4dfa0c 213 __THROW __attribute_pure__;
d8387c7b 214#endif
e918a7fe 215
30de3b18 216/* Divide WCS into tokens separated by characters in DELIM. */
c1422e5b 217extern wchar_t *wcstok (wchar_t *__restrict __s,
a784e502 218 const wchar_t *__restrict __delim,
c1422e5b 219 wchar_t **__restrict __ptr) __THROW;
30de3b18 220
1618c590 221/* Return the number of wide characters in S. */
a784e502 222extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__;
7a5affeb
UD
223
224#ifdef __USE_XOPEN
225/* Another name for `wcsstr' from XPG4. */
d8387c7b 226# ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
a784e502 227extern "C++" wchar_t *wcswcs (wchar_t *__haystack, const wchar_t *__needle)
d8387c7b 228 __THROW __asm ("wcswcs") __attribute_pure__;
a784e502
UD
229extern "C++" const wchar_t *wcswcs (const wchar_t *__haystack,
230 const wchar_t *__needle)
d8387c7b
UD
231 __THROW __asm ("wcswcs") __attribute_pure__;
232# else
a784e502 233extern wchar_t *wcswcs (const wchar_t *__haystack, const wchar_t *__needle)
7a5affeb 234 __THROW __attribute_pure__;
d8387c7b 235# endif
7a5affeb 236#endif
30de3b18 237
6cbe890a 238#ifdef __USE_XOPEN2K8
4bca4c17 239/* Return the number of wide characters in S, but at most MAXLEN. */
a784e502 240extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen)
fb4dfa0c 241 __THROW __attribute_pure__;
4bca4c17
UD
242#endif
243
30de3b18 244
1618c590 245/* Search N wide characters of S for C. */
d8387c7b
UD
246#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
247extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n)
248 __THROW __asm ("wmemchr") __attribute_pure__;
a784e502
UD
249extern "C++" const wchar_t *wmemchr (const wchar_t *__s, wchar_t __c,
250 size_t __n)
d8387c7b
UD
251 __THROW __asm ("wmemchr") __attribute_pure__;
252#else
a784e502 253extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n)
fb4dfa0c 254 __THROW __attribute_pure__;
d8387c7b 255#endif
30de3b18 256
1618c590 257/* Compare N wide characters of S1 and S2. */
a784e502 258extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
fb4dfa0c 259 __THROW __attribute_pure__;
30de3b18 260
1618c590 261/* Copy N wide characters of SRC to DEST. */
c1422e5b 262extern wchar_t *wmemcpy (wchar_t *__restrict __s1,
a784e502 263 const wchar_t *__restrict __s2, size_t __n) __THROW;
30de3b18 264
1618c590 265/* Copy N wide characters of SRC to DEST, guaranteeing
30de3b18 266 correct behavior for overlapping strings. */
a784e502 267extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)
c1422e5b 268 __THROW;
30de3b18 269
1618c590 270/* Set N wide characters of S to C. */
c1422e5b 271extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
30de3b18 272
d64b6ad0
UD
273#ifdef __USE_GNU
274/* Copy N wide characters of SRC to DEST and return pointer to following
275 wide character. */
c1422e5b 276extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
a784e502 277 const wchar_t *__restrict __s2, size_t __n)
c1422e5b 278 __THROW;
d64b6ad0
UD
279#endif
280
30de3b18
RM
281
282/* Determine whether C constitutes a valid (one-byte) multibyte
283 character. */
c1422e5b 284extern wint_t btowc (int __c) __THROW;
30de3b18
RM
285
286/* Determine whether C corresponds to a member of the extended
287 character set whose multibyte representation is a single byte. */
c1422e5b 288extern int wctob (wint_t __c) __THROW;
30de3b18
RM
289
290/* Determine whether PS points to an object representing the initial
291 state. */
a784e502 292extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__;
30de3b18 293
30de3b18
RM
294/* Write wide character representation of multibyte character pointed
295 to by S to PWC. */
c1422e5b 296extern size_t mbrtowc (wchar_t *__restrict __pwc,
a784e502 297 const char *__restrict __s, size_t __n,
dadebdae 298 mbstate_t *__restrict __p) __THROW;
30de3b18
RM
299
300/* Write multibyte representation of wide character WC to S. */
c1422e5b
UD
301extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
302 mbstate_t *__restrict __ps) __THROW;
30de3b18 303
07a4742f 304/* Return number of bytes in multibyte character pointed to by S. */
a784e502 305extern size_t __mbrlen (const char *__restrict __s, size_t __n,
c1422e5b 306 mbstate_t *__restrict __ps) __THROW;
a784e502 307extern size_t mbrlen (const char *__restrict __s, size_t __n,
c1422e5b 308 mbstate_t *__restrict __ps) __THROW;
07a4742f 309
07c416ed 310#ifdef __USE_EXTERN_INLINES
07a4742f 311/* Define inline function as optimization. */
91682d70
UD
312
313/* We can use the BTOWC and WCTOB optimizations since we know that all
314 locales must use ASCII encoding for the values in the ASCII range
315 and because the wchar_t encoding is always ISO 10646. */
316extern wint_t __btowc_alias (int __c) __asm ("btowc");
b037a293 317__extern_inline wint_t
91682d70
UD
318__NTH (btowc (int __c))
319{ return (__builtin_constant_p (__c) && __c >= '\0' && __c <= '\x7f'
320 ? (wint_t) __c : __btowc_alias (__c)); }
321
322extern int __wctob_alias (wint_t __c) __asm ("wctob");
b037a293 323__extern_inline int
91682d70
UD
324__NTH (wctob (wint_t __wc))
325{ return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f'
326 ? (int) __wc : __wctob_alias (__wc)); }
327
b037a293 328__extern_inline size_t
a784e502 329__NTH (mbrlen (const char *__restrict __s, size_t __n,
f377d022 330 mbstate_t *__restrict __ps))
2f6d1f1b 331{ return (__ps != NULL
bdbf022d 332 ? mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); }
07a4742f
RM
333#endif
334
036cc82f
RM
335/* Write wide character representation of multibyte character string
336 SRC to DST. */
c1422e5b 337extern size_t mbsrtowcs (wchar_t *__restrict __dst,
a784e502 338 const char **__restrict __src, size_t __len,
c1422e5b 339 mbstate_t *__restrict __ps) __THROW;
30de3b18
RM
340
341/* Write multibyte character representation of wide character string
342 SRC to DST. */
c1422e5b 343extern size_t wcsrtombs (char *__restrict __dst,
a784e502 344 const wchar_t **__restrict __src, size_t __len,
c1422e5b 345 mbstate_t *__restrict __ps) __THROW;
30de3b18 346
75cd5204 347
6cbe890a 348#ifdef __USE_XOPEN2K8
036cc82f
RM
349/* Write wide character representation of at most NMC bytes of the
350 multibyte character string SRC to DST. */
c1422e5b 351extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
a784e502 352 const char **__restrict __src, size_t __nmc,
c1422e5b 353 size_t __len, mbstate_t *__restrict __ps) __THROW;
036cc82f
RM
354
355/* Write multibyte character representation of at most NWC characters
356 from the wide character string SRC to DST. */
c1422e5b 357extern size_t wcsnrtombs (char *__restrict __dst,
a784e502 358 const wchar_t **__restrict __src,
c1422e5b
UD
359 size_t __nwc, size_t __len,
360 mbstate_t *__restrict __ps) __THROW;
6cbe890a 361#endif /* use POSIX 2008 */
e34b0f29 362
036cc82f 363
75cd5204 364/* The following functions are extensions found in X/Open CAE. */
9756dfe1 365#ifdef __USE_XOPEN
75cd5204 366/* Determine number of column positions required for C. */
b6d64fb0 367extern int wcwidth (wchar_t __c) __THROW;
75cd5204
RM
368
369/* Determine number of column positions required for first N wide
370 characters (or fewer if S ends before this) in S. */
a784e502 371extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
9756dfe1 372#endif /* Use X/Open. */
75cd5204
RM
373
374
375/* Convert initial portion of the wide string NPTR to `double'
376 representation. */
a784e502 377extern double wcstod (const wchar_t *__restrict __nptr,
c1422e5b 378 wchar_t **__restrict __endptr) __THROW;
75cd5204 379
ec751a23 380#ifdef __USE_ISOC99
75cd5204 381/* Likewise for `float' and `long double' sizes of floating-point numbers. */
a784e502 382extern float wcstof (const wchar_t *__restrict __nptr,
c1422e5b 383 wchar_t **__restrict __endptr) __THROW;
a784e502 384extern long double wcstold (const wchar_t *__restrict __nptr,
c1422e5b 385 wchar_t **__restrict __endptr) __THROW;
91bc38d0 386#endif /* C99 */
75cd5204 387
43ddff2e
JM
388/* Likewise for `_FloatN' and `_FloatNx' when support is enabled. */
389
390#if __HAVE_FLOAT16 && defined __USE_GNU
391extern _Float16 wcstof16 (const wchar_t *__restrict __nptr,
392 wchar_t **__restrict __endptr) __THROW;
393#endif
394
395#if __HAVE_FLOAT32 && defined __USE_GNU
396extern _Float32 wcstof32 (const wchar_t *__restrict __nptr,
397 wchar_t **__restrict __endptr) __THROW;
398#endif
399
400#if __HAVE_FLOAT64 && defined __USE_GNU
401extern _Float64 wcstof64 (const wchar_t *__restrict __nptr,
402 wchar_t **__restrict __endptr) __THROW;
403#endif
404
45f39d45
PM
405#if __HAVE_FLOAT128 && defined __USE_GNU
406extern _Float128 wcstof128 (const wchar_t *__restrict __nptr,
407 wchar_t **__restrict __endptr) __THROW;
408#endif
409
43ddff2e
JM
410#if __HAVE_FLOAT32X && defined __USE_GNU
411extern _Float32x wcstof32x (const wchar_t *__restrict __nptr,
412 wchar_t **__restrict __endptr) __THROW;
413#endif
414
415#if __HAVE_FLOAT64X && defined __USE_GNU
416extern _Float64x wcstof64x (const wchar_t *__restrict __nptr,
417 wchar_t **__restrict __endptr) __THROW;
418#endif
419
420#if __HAVE_FLOAT128X && defined __USE_GNU
421extern _Float128x wcstof128x (const wchar_t *__restrict __nptr,
422 wchar_t **__restrict __endptr) __THROW;
423#endif
424
75cd5204
RM
425
426/* Convert initial portion of wide string NPTR to `long int'
427 representation. */
a784e502 428extern long int wcstol (const wchar_t *__restrict __nptr,
c1422e5b 429 wchar_t **__restrict __endptr, int __base) __THROW;
75cd5204
RM
430
431/* Convert initial portion of wide string NPTR to `unsigned long int'
432 representation. */
a784e502 433extern unsigned long int wcstoul (const wchar_t *__restrict __nptr,
c1422e5b
UD
434 wchar_t **__restrict __endptr, int __base)
435 __THROW;
75cd5204 436
fed0faa1 437#ifdef __USE_ISOC99
9e6e344e 438/* Convert initial portion of wide string NPTR to `long long int'
75cd5204 439 representation. */
7782d0bf 440__extension__
a784e502 441extern long long int wcstoll (const wchar_t *__restrict __nptr,
7a5affeb 442 wchar_t **__restrict __endptr, int __base)
c1422e5b 443 __THROW;
75cd5204
RM
444
445/* Convert initial portion of wide string NPTR to `unsigned long long int'
446 representation. */
7782d0bf 447__extension__
a784e502 448extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr,
7a5affeb
UD
449 wchar_t **__restrict __endptr,
450 int __base) __THROW;
fed0faa1 451#endif /* ISO C99. */
75cd5204 452
fed0faa1 453#ifdef __USE_GNU
9e6e344e 454/* Convert initial portion of wide string NPTR to `long long int'
2f6d1f1b 455 representation. */
7782d0bf 456__extension__
a784e502 457extern long long int wcstoq (const wchar_t *__restrict __nptr,
7a5affeb 458 wchar_t **__restrict __endptr, int __base)
c1422e5b 459 __THROW;
2f6d1f1b
UD
460
461/* Convert initial portion of wide string NPTR to `unsigned long long int'
462 representation. */
7782d0bf 463__extension__
a784e502 464extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr,
7a5affeb
UD
465 wchar_t **__restrict __endptr,
466 int __base) __THROW;
fed0faa1 467#endif /* Use GNU. */
2f6d1f1b 468
0501d603 469#ifdef __USE_GNU
f0be25b6
ZW
470/* Parallel versions of the functions above which take the locale to
471 use as an additional parameter. These are GNU extensions inspired
472 by the POSIX.1-2008 extended locale API. */
a784e502 473extern long int wcstol_l (const wchar_t *__restrict __nptr,
1ab62b32 474 wchar_t **__restrict __endptr, int __base,
af85385f 475 locale_t __loc) __THROW;
0501d603 476
a784e502 477extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr,
1ab62b32 478 wchar_t **__restrict __endptr,
af85385f 479 int __base, locale_t __loc) __THROW;
0501d603 480
7782d0bf 481__extension__
a784e502 482extern long long int wcstoll_l (const wchar_t *__restrict __nptr,
1ab62b32 483 wchar_t **__restrict __endptr,
af85385f 484 int __base, locale_t __loc) __THROW;
0501d603 485
7782d0bf 486__extension__
a784e502 487extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr,
1ab62b32 488 wchar_t **__restrict __endptr,
af85385f 489 int __base, locale_t __loc)
1ab62b32 490 __THROW;
0501d603 491
a784e502 492extern double wcstod_l (const wchar_t *__restrict __nptr,
af85385f 493 wchar_t **__restrict __endptr, locale_t __loc)
1ab62b32 494 __THROW;
0501d603 495
a784e502 496extern float wcstof_l (const wchar_t *__restrict __nptr,
af85385f 497 wchar_t **__restrict __endptr, locale_t __loc)
1ab62b32 498 __THROW;
0501d603 499
a784e502 500extern long double wcstold_l (const wchar_t *__restrict __nptr,
1ab62b32 501 wchar_t **__restrict __endptr,
af85385f 502 locale_t __loc) __THROW;
45f39d45 503
43ddff2e
JM
504# if __HAVE_FLOAT16
505extern _Float16 wcstof16_l (const wchar_t *__restrict __nptr,
506 wchar_t **__restrict __endptr,
507 locale_t __loc) __THROW;
508# endif
509
510# if __HAVE_FLOAT32
511extern _Float32 wcstof32_l (const wchar_t *__restrict __nptr,
512 wchar_t **__restrict __endptr,
513 locale_t __loc) __THROW;
514# endif
515
516# if __HAVE_FLOAT64
517extern _Float64 wcstof64_l (const wchar_t *__restrict __nptr,
518 wchar_t **__restrict __endptr,
519 locale_t __loc) __THROW;
520# endif
521
45f39d45
PM
522# if __HAVE_FLOAT128
523extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr,
524 wchar_t **__restrict __endptr,
af85385f 525 locale_t __loc) __THROW;
45f39d45 526# endif
43ddff2e
JM
527
528# if __HAVE_FLOAT32X
529extern _Float32x wcstof32x_l (const wchar_t *__restrict __nptr,
530 wchar_t **__restrict __endptr,
531 locale_t __loc) __THROW;
532# endif
533
534# if __HAVE_FLOAT64X
535extern _Float64x wcstof64x_l (const wchar_t *__restrict __nptr,
536 wchar_t **__restrict __endptr,
537 locale_t __loc) __THROW;
538# endif
539
540# if __HAVE_FLOAT128X
541extern _Float128x wcstof128x_l (const wchar_t *__restrict __nptr,
542 wchar_t **__restrict __endptr,
543 locale_t __loc) __THROW;
544# endif
8593482f 545#endif /* use GNU */
0501d603 546
75cd5204 547
8593482f 548#ifdef __USE_XOPEN2K8
75cd5204
RM
549/* Copy SRC to DEST, returning the address of the terminating L'\0' in
550 DEST. */
4f197237 551extern wchar_t *wcpcpy (wchar_t *__restrict __dest,
a784e502 552 const wchar_t *__restrict __src) __THROW;
75cd5204
RM
553
554/* Copy no more than N characters of SRC to DEST, returning the address of
555 the last character written into DEST. */
4f197237 556extern wchar_t *wcpncpy (wchar_t *__restrict __dest,
a784e502 557 const wchar_t *__restrict __src, size_t __n)
c1422e5b 558 __THROW;
48789000 559#endif
75cd5204
RM
560
561
d64b6ad0 562/* Wide character I/O functions. */
1c31aa79 563
48789000 564#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
1c31aa79
UD
565/* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
566 a wide character string. */
567extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW;
568#endif
569
087722b8 570#if defined __USE_ISOC95 || defined __USE_UNIX98
d64b6ad0
UD
571
572/* Select orientation for stream. */
d1646309 573extern int fwide (__FILE *__fp, int __mode) __THROW;
d64b6ad0
UD
574
575
2c008571
UD
576/* Write formatted output to STREAM.
577
578 This function is a possible cancellation point and therefore not
579 marked with __THROW. */
d1646309 580extern int fwprintf (__FILE *__restrict __stream,
a784e502 581 const wchar_t *__restrict __format, ...)
2c008571
UD
582 /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
583/* Write formatted output to stdout.
584
585 This function is a possible cancellation point and therefore not
586 marked with __THROW. */
a784e502 587extern int wprintf (const wchar_t *__restrict __format, ...)
2c008571 588 /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
d64b6ad0 589/* Write formatted output of at most N characters to S. */
c1422e5b 590extern int swprintf (wchar_t *__restrict __s, size_t __n,
a784e502 591 const wchar_t *__restrict __format, ...)
c1422e5b 592 __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
d64b6ad0 593
2c008571
UD
594/* Write formatted output to S from argument list ARG.
595
596 This function is a possible cancellation point and therefore not
597 marked with __THROW. */
d1646309 598extern int vfwprintf (__FILE *__restrict __s,
a784e502 599 const wchar_t *__restrict __format,
c1422e5b 600 __gnuc_va_list __arg)
2c008571
UD
601 /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
602/* Write formatted output to stdout from argument list ARG.
603
604 This function is a possible cancellation point and therefore not
605 marked with __THROW. */
a784e502 606extern int vwprintf (const wchar_t *__restrict __format,
c1422e5b 607 __gnuc_va_list __arg)
2c008571 608 /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */;
d64b6ad0
UD
609/* Write formatted output of at most N character to S from argument
610 list ARG. */
c1422e5b 611extern int vswprintf (wchar_t *__restrict __s, size_t __n,
a784e502 612 const wchar_t *__restrict __format,
c1422e5b
UD
613 __gnuc_va_list __arg)
614 __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
d64b6ad0
UD
615
616
2c008571
UD
617/* Read formatted input from STREAM.
618
619 This function is a possible cancellation point and therefore not
620 marked with __THROW. */
d1646309 621extern int fwscanf (__FILE *__restrict __stream,
a784e502 622 const wchar_t *__restrict __format, ...)
2c008571
UD
623 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
624/* Read formatted input from stdin.
625
626 This function is a possible cancellation point and therefore not
627 marked with __THROW. */
a784e502 628extern int wscanf (const wchar_t *__restrict __format, ...)
2c008571 629 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
d64b6ad0 630/* Read formatted input from S. */
a784e502
UD
631extern int swscanf (const wchar_t *__restrict __s,
632 const wchar_t *__restrict __format, ...)
c1422e5b 633 __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
7a5affeb 634
03992356 635/* For historical reasons, the C99-compliant versions of the scanf
e4a39992 636 functions are at alternative names. When __LDBL_COMPAT or
e2239af3 637 __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI are in effect, this is handled in
e4a39992
GG
638 bits/wchar-ldbl.h. */
639#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
e2239af3 640 && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
874aa523 641# ifdef __REDIRECT
874aa523 642extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
a784e502 643 const wchar_t *__restrict __format, ...),
874aa523
UD
644 __isoc99_fwscanf)
645 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
a784e502 646extern int __REDIRECT (wscanf, (const wchar_t *__restrict __format, ...),
874aa523
UD
647 __isoc99_wscanf)
648 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
a784e502
UD
649extern int __REDIRECT_NTH (swscanf, (const wchar_t *__restrict __s,
650 const wchar_t *__restrict __format,
f32f2869
JJ
651 ...), __isoc99_swscanf)
652 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
874aa523
UD
653# else
654extern int __isoc99_fwscanf (__FILE *__restrict __stream,
a784e502
UD
655 const wchar_t *__restrict __format, ...);
656extern int __isoc99_wscanf (const wchar_t *__restrict __format, ...);
657extern int __isoc99_swscanf (const wchar_t *__restrict __s,
658 const wchar_t *__restrict __format, ...)
874aa523
UD
659 __THROW;
660# define fwscanf __isoc99_fwscanf
661# define wscanf __isoc99_wscanf
662# define swscanf __isoc99_swscanf
663# endif
664# endif
665
087722b8 666#endif /* Use ISO C95, C99 and Unix98. */
d64b6ad0 667
91bc38d0 668#ifdef __USE_ISOC99
2c008571
UD
669/* Read formatted input from S into argument list ARG.
670
671 This function is a possible cancellation point and therefore not
672 marked with __THROW. */
d1646309 673extern int vfwscanf (__FILE *__restrict __s,
a784e502 674 const wchar_t *__restrict __format,
c1422e5b 675 __gnuc_va_list __arg)
2c008571
UD
676 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
677/* Read formatted input from stdin into argument list ARG.
678
679 This function is a possible cancellation point and therefore not
680 marked with __THROW. */
a784e502 681extern int vwscanf (const wchar_t *__restrict __format,
c1422e5b 682 __gnuc_va_list __arg)
2c008571 683 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
d64b6ad0 684/* Read formatted input from S into argument list ARG. */
a784e502
UD
685extern int vswscanf (const wchar_t *__restrict __s,
686 const wchar_t *__restrict __format,
c1422e5b
UD
687 __gnuc_va_list __arg)
688 __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
7a5affeb 689
93486ba5
GG
690/* Same redirection as above for the v*wscanf family. */
691# if !__GLIBC_USE (DEPRECATED_SCANF) \
874aa523 692 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
e4a39992 693 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) \
e2239af3 694 && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
874aa523
UD
695# ifdef __REDIRECT
696extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
a784e502 697 const wchar_t *__restrict __format,
874aa523
UD
698 __gnuc_va_list __arg), __isoc99_vfwscanf)
699 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
a784e502 700extern int __REDIRECT (vwscanf, (const wchar_t *__restrict __format,
874aa523
UD
701 __gnuc_va_list __arg), __isoc99_vwscanf)
702 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
a784e502
UD
703extern int __REDIRECT_NTH (vswscanf, (const wchar_t *__restrict __s,
704 const wchar_t *__restrict __format,
f32f2869
JJ
705 __gnuc_va_list __arg), __isoc99_vswscanf)
706 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
874aa523
UD
707# else
708extern int __isoc99_vfwscanf (__FILE *__restrict __s,
a784e502 709 const wchar_t *__restrict __format,
874aa523 710 __gnuc_va_list __arg);
a784e502 711extern int __isoc99_vwscanf (const wchar_t *__restrict __format,
874aa523 712 __gnuc_va_list __arg);
a784e502
UD
713extern int __isoc99_vswscanf (const wchar_t *__restrict __s,
714 const wchar_t *__restrict __format,
874aa523
UD
715 __gnuc_va_list __arg) __THROW;
716# define vfwscanf __isoc99_vfwscanf
717# define vwscanf __isoc99_vwscanf
718# define vswscanf __isoc99_vswscanf
719# endif
720# endif
721
91bc38d0 722#endif /* Use ISO C99. */
d64b6ad0
UD
723
724
2c008571
UD
725/* Read a character from STREAM.
726
727 These functions are possible cancellation points and therefore not
728 marked with __THROW. */
729extern wint_t fgetwc (__FILE *__stream);
730extern wint_t getwc (__FILE *__stream);
d64b6ad0 731
2c008571 732/* Read a character from stdin.
d64b6ad0 733
2c008571
UD
734 This function is a possible cancellation point and therefore not
735 marked with __THROW. */
736extern wint_t getwchar (void);
d64b6ad0 737
d64b6ad0 738
2c008571
UD
739/* Write a character to STREAM.
740
741 These functions are possible cancellation points and therefore not
742 marked with __THROW. */
743extern wint_t fputwc (wchar_t __wc, __FILE *__stream);
744extern wint_t putwc (wchar_t __wc, __FILE *__stream);
745
746/* Write a character to stdout.
747
4c1423ed 748 This function is a possible cancellation point and therefore not
2c008571
UD
749 marked with __THROW. */
750extern wint_t putwchar (wchar_t __wc);
d64b6ad0 751
91bc38d0
UD
752
753/* Get a newline-terminated wide character string of finite length
2c008571
UD
754 from STREAM.
755
4c1423ed 756 This function is a possible cancellation point and therefore not
2c008571 757 marked with __THROW. */
91bc38d0 758extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
2c008571
UD
759 __FILE *__restrict __stream);
760
761/* Write a string to STREAM.
91bc38d0 762
4c1423ed 763 This function is a possible cancellation point and therefore not
2c008571 764 marked with __THROW. */
a784e502 765extern int fputws (const wchar_t *__restrict __ws,
2c008571
UD
766 __FILE *__restrict __stream);
767
91bc38d0 768
2c008571 769/* Push a character back onto the input buffer of STREAM.
91bc38d0 770
4c1423ed 771 This function is a possible cancellation point and therefore not
2c008571
UD
772 marked with __THROW. */
773extern wint_t ungetwc (wint_t __wc, __FILE *__stream);
91bc38d0
UD
774
775
d64b6ad0 776#ifdef __USE_GNU
91bc38d0 777/* These are defined to be equivalent to the `char' functions defined
2c008571 778 in POSIX.1:1996.
91bc38d0 779
2c008571
UD
780 These functions are not part of POSIX and therefore no official
781 cancellation point. But due to similarity with an POSIX interface
782 or due to the implementation they are cancellation points and
783 therefore not marked with __THROW. */
784extern wint_t getwc_unlocked (__FILE *__stream);
785extern wint_t getwchar_unlocked (void);
91bc38d0 786
2c008571
UD
787/* This is the wide character version of a GNU extension.
788
789 This function is not part of POSIX and therefore no official
790 cancellation point. But due to similarity with an POSIX interface
791 or due to the implementation it is a cancellation point and
792 therefore not marked with __THROW. */
793extern wint_t fgetwc_unlocked (__FILE *__stream);
794
795/* Faster version when locking is not necessary.
796
797 This function is not part of POSIX and therefore no official
798 cancellation point. But due to similarity with an POSIX interface
799 or due to the implementation it is a cancellation point and
800 therefore not marked with __THROW. */
801extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream);
d64b6ad0
UD
802
803/* These are defined to be equivalent to the `char' functions defined
2c008571 804 in POSIX.1:1996.
d64b6ad0 805
2c008571
UD
806 These functions are not part of POSIX and therefore no official
807 cancellation point. But due to similarity with an POSIX interface
808 or due to the implementation they are cancellation points and
809 therefore not marked with __THROW. */
810extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream);
811extern wint_t putwchar_unlocked (wchar_t __wc);
d64b6ad0 812
2c008571
UD
813
814/* This function does the same as `fgetws' but does not lock the stream.
815
816 This function is not part of POSIX and therefore no official
817 cancellation point. But due to similarity with an POSIX interface
818 or due to the implementation it is a cancellation point and
819 therefore not marked with __THROW. */
c1422e5b 820extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
2c008571
UD
821 __FILE *__restrict __stream);
822
823/* This function does the same as `fputws' but does not lock the stream.
d64b6ad0 824
2c008571
UD
825 This function is not part of POSIX and therefore no official
826 cancellation point. But due to similarity with an POSIX interface
827 or due to the implementation it is a cancellation point and
828 therefore not marked with __THROW. */
a784e502 829extern int fputws_unlocked (const wchar_t *__restrict __ws,
2c008571 830 __FILE *__restrict __stream);
d64b6ad0
UD
831#endif
832
833
d64b6ad0
UD
834/* Format TP into S according to FORMAT.
835 Write no more than MAXSIZE wide characters and return the number
836 of wide characters written, or 0 if it would exceed MAXSIZE. */
c1422e5b 837extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
a784e502
UD
838 const wchar_t *__restrict __format,
839 const struct tm *__restrict __tp) __THROW;
d64b6ad0 840
c4d6f155 841# ifdef __USE_GNU
c4d6f155
RM
842/* Similar to `wcsftime' but takes the information from
843 the provided locale and not the global locale. */
c4d6f155 844extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
a784e502
UD
845 const wchar_t *__restrict __format,
846 const struct tm *__restrict __tp,
af85385f 847 locale_t __loc) __THROW;
c4d6f155
RM
848# endif
849
8215c9ec 850/* Define some macros helping to catch buffer overflows. */
5ac3ea17 851#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
8215c9ec
UD
852# include <bits/wchar2.h>
853#endif
854
e4a39992 855#include <bits/floatn.h>
e2239af3 856#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
54e98f69
RM
857# include <bits/wchar-ldbl.h>
858#endif
859
30de3b18
RM
860__END_DECLS
861
0f2ae55c 862#endif /* wchar.h */