2011-02-12 05:22:29 +00:00
|
|
|
#ifndef _WCHAR_H
|
|
|
|
#define _WCHAR_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-09-08 03:13:55 +00:00
|
|
|
#include <features.h>
|
2012-09-07 02:44:55 +00:00
|
|
|
|
2011-02-12 05:22:29 +00:00
|
|
|
#define __NEED_FILE
|
2013-06-26 02:26:20 +00:00
|
|
|
#define __NEED___isoc_va_list
|
2011-02-12 05:22:29 +00:00
|
|
|
#define __NEED_size_t
|
|
|
|
#define __NEED_wchar_t
|
|
|
|
#define __NEED_wint_t
|
2014-10-14 00:59:42 +00:00
|
|
|
#define __NEED_mbstate_t
|
2011-02-15 00:33:11 +00:00
|
|
|
|
2019-03-12 19:24:00 +00:00
|
|
|
#if __STDC_VERSION__ < 201112L
|
|
|
|
#define __NEED_struct__IO_FILE
|
|
|
|
#endif
|
|
|
|
|
2012-03-02 04:24:45 +00:00
|
|
|
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|
2013-08-02 22:14:44 +00:00
|
|
|
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
2012-03-02 04:24:45 +00:00
|
|
|
#define __NEED_locale_t
|
2013-06-26 02:26:20 +00:00
|
|
|
#define __NEED_va_list
|
2012-03-02 04:24:45 +00:00
|
|
|
#endif
|
|
|
|
|
2013-08-02 22:14:44 +00:00
|
|
|
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
2011-02-12 05:22:29 +00:00
|
|
|
#define __NEED_wctype_t
|
2011-02-15 00:33:11 +00:00
|
|
|
#endif
|
2011-02-12 05:22:29 +00:00
|
|
|
|
|
|
|
#include <bits/alltypes.h>
|
|
|
|
|
2013-04-04 23:57:23 +00:00
|
|
|
#if L'\0'-1 > 0
|
|
|
|
#define WCHAR_MAX (0xffffffffu+L'\0')
|
|
|
|
#define WCHAR_MIN (0+L'\0')
|
|
|
|
#else
|
|
|
|
#define WCHAR_MAX (0x7fffffff+L'\0')
|
|
|
|
#define WCHAR_MIN (-1-0x7fffffff+L'\0')
|
|
|
|
#endif
|
fix the type of wchar_t on arm; support wchar_t varying with arch
really wchar_t should never vary, but the ARM EABI defines it as an
unsigned 32-bit int instead of a signed one, and gcc follows this
nonsense. thus, to give a conformant environment, we have to follow
(otherwise L""[0] and L'\0' would be 0U rather than 0, but the
application would be unaware due to a mismatched definition for
WCHAR_MIN and WCHAR_MAX, and Bad Things could happen with respect to
signed/unsigned comparisons, promotions, etc.).
fortunately no rules are imposed by the C standard on the relationship
between wchar_t and wint_t, and WEOF has type wint_t, so we can still
make wint_t always-signed and use -1 for WEOF.
2011-09-19 21:39:51 +00:00
|
|
|
|
2021-08-15 15:51:57 +00:00
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
#define NULL nullptr
|
|
|
|
#elif defined(__cplusplus)
|
use a common definition of NULL as 0L for C and C++
the historical mess of having different definitions for C and C++
comes from the historical C definition as (void *)0 and the fact that
(void *)0 can't be used in C++ because it does not convert to other
pointer types implicitly. however, using plain 0 in C++ exposed bugs
in C++ programs that call variadic functions with NULL as an argument
and (wrongly; this is UB) expect it to arrive as a null pointer. on
64-bit machines, the high bits end up containing junk. glibc dodges
the issue by using a GCC extension __null to define NULL; this is
observably non-conforming because a conforming application could
observe the definition of NULL via stringizing and see that it is
neither an integer constant expression with value zero nor such an
expression cast to void.
switching to 0L eliminates the issue and provides compatibility with
broken applications, since on all musl targets, long and pointers have
the same size, representation, and argument-passing convention. we
could maintain separate C and C++ definitions of NULL (i.e. just use
0L on C++ and use (void *)0 on C) but after careful analysis, it seems
extremely difficult for a C program to even determine whether NULL has
integer or pointer type, much less depend in subtle, unintentional
ways, on whether it does. C89 seems to have no way to make the
distinction. on C99, the fact that (int)(void *)0 is not an integer
constant expression, along with subtle VLA/sizeof semantics, can be
used to make the distinction, but many compilers are non-conforming
and give the wrong result to this test anyway. on C11, _Generic can
trivially make the distinction, but it seems unlikely that code
targetting C11 would be so backwards in caring which definition of
NULL an implementation uses.
as such, the simplest path of using the same definition for NULL in
both C and C++ was chosen. the #undef directive was also removed so
that the compiler can catch and give a warning or error on
redefinition if buggy programs have defined their own versions of
NULL prior to inclusion of standard headers.
2013-01-19 01:35:26 +00:00
|
|
|
#define NULL 0L
|
2013-11-25 02:42:55 +00:00
|
|
|
#else
|
|
|
|
#define NULL ((void*)0)
|
|
|
|
#endif
|
2011-02-12 05:22:29 +00:00
|
|
|
|
|
|
|
#undef WEOF
|
2013-07-22 17:05:41 +00:00
|
|
|
#define WEOF 0xffffffffU
|
2011-02-12 05:22:29 +00:00
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
wchar_t *wcscpy (wchar_t *__restrict, const wchar_t *__restrict);
|
|
|
|
wchar_t *wcsncpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
wchar_t *wcscat (wchar_t *__restrict, const wchar_t *__restrict);
|
|
|
|
wchar_t *wcsncat (wchar_t *__restrict, const wchar_t *__restrict, size_t);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
|
|
|
int wcscmp (const wchar_t *, const wchar_t *);
|
|
|
|
int wcsncmp (const wchar_t *, const wchar_t *, size_t);
|
|
|
|
|
2011-03-29 22:30:27 +00:00
|
|
|
int wcscoll(const wchar_t *, const wchar_t *);
|
2016-10-20 21:04:37 +00:00
|
|
|
size_t wcsxfrm (wchar_t *__restrict, const wchar_t *__restrict, size_t);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
|
|
|
wchar_t *wcschr (const wchar_t *, wchar_t);
|
|
|
|
wchar_t *wcsrchr (const wchar_t *, wchar_t);
|
|
|
|
|
|
|
|
size_t wcscspn (const wchar_t *, const wchar_t *);
|
|
|
|
size_t wcsspn (const wchar_t *, const wchar_t *);
|
|
|
|
wchar_t *wcspbrk (const wchar_t *, const wchar_t *);
|
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
wchar_t *wcstok (wchar_t *__restrict, const wchar_t *__restrict, wchar_t **__restrict);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
|
|
|
size_t wcslen (const wchar_t *);
|
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
wchar_t *wcsstr (const wchar_t *__restrict, const wchar_t *__restrict);
|
2011-02-12 05:22:29 +00:00
|
|
|
wchar_t *wcswcs (const wchar_t *, const wchar_t *);
|
|
|
|
|
|
|
|
wchar_t *wmemchr (const wchar_t *, wchar_t, size_t);
|
|
|
|
int wmemcmp (const wchar_t *, const wchar_t *, size_t);
|
2012-09-07 02:44:55 +00:00
|
|
|
wchar_t *wmemcpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
|
2011-02-12 05:22:29 +00:00
|
|
|
wchar_t *wmemmove (wchar_t *, const wchar_t *, size_t);
|
|
|
|
wchar_t *wmemset (wchar_t *, wchar_t, size_t);
|
|
|
|
|
|
|
|
wint_t btowc (int);
|
|
|
|
int wctob (wint_t);
|
|
|
|
|
|
|
|
int mbsinit (const mbstate_t *);
|
2012-09-07 02:44:55 +00:00
|
|
|
size_t mbrtowc (wchar_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
|
|
|
|
size_t wcrtomb (char *__restrict, wchar_t, mbstate_t *__restrict);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
size_t mbrlen (const char *__restrict, size_t, mbstate_t *__restrict);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
size_t mbsrtowcs (wchar_t *__restrict, const char **__restrict, size_t, mbstate_t *__restrict);
|
|
|
|
size_t wcsrtombs (char *__restrict, const wchar_t **__restrict, size_t, mbstate_t *__restrict);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
float wcstof (const wchar_t *__restrict, wchar_t **__restrict);
|
|
|
|
double wcstod (const wchar_t *__restrict, wchar_t **__restrict);
|
|
|
|
long double wcstold (const wchar_t *__restrict, wchar_t **__restrict);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
long wcstol (const wchar_t *__restrict, wchar_t **__restrict, int);
|
|
|
|
unsigned long wcstoul (const wchar_t *__restrict, wchar_t **__restrict, int);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
long long wcstoll (const wchar_t *__restrict, wchar_t **__restrict, int);
|
|
|
|
unsigned long long wcstoull (const wchar_t *__restrict, wchar_t **__restrict, int);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int fwide (FILE *, int);
|
|
|
|
|
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
int wprintf (const wchar_t *__restrict, ...);
|
|
|
|
int fwprintf (FILE *__restrict, const wchar_t *__restrict, ...);
|
|
|
|
int swprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, ...);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
2013-06-26 02:26:20 +00:00
|
|
|
int vwprintf (const wchar_t *__restrict, __isoc_va_list);
|
|
|
|
int vfwprintf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list);
|
|
|
|
int vswprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, __isoc_va_list);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
int wscanf (const wchar_t *__restrict, ...);
|
|
|
|
int fwscanf (FILE *__restrict, const wchar_t *__restrict, ...);
|
|
|
|
int swscanf (const wchar_t *__restrict, const wchar_t *__restrict, ...);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
2013-06-26 02:26:20 +00:00
|
|
|
int vwscanf (const wchar_t *__restrict, __isoc_va_list);
|
|
|
|
int vfwscanf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list);
|
|
|
|
int vswscanf (const wchar_t *__restrict, const wchar_t *__restrict, __isoc_va_list);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
|
|
|
wint_t fgetwc (FILE *);
|
|
|
|
wint_t getwc (FILE *);
|
|
|
|
wint_t getwchar (void);
|
|
|
|
|
|
|
|
wint_t fputwc (wchar_t, FILE *);
|
|
|
|
wint_t putwc (wchar_t, FILE *);
|
|
|
|
wint_t putwchar (wchar_t);
|
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
wchar_t *fgetws (wchar_t *__restrict, int, FILE *__restrict);
|
|
|
|
int fputws (const wchar_t *__restrict, FILE *__restrict);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
|
|
|
wint_t ungetwc (wint_t, FILE *);
|
|
|
|
|
|
|
|
struct tm;
|
2012-09-07 02:44:55 +00:00
|
|
|
size_t wcsftime (wchar_t *__restrict, size_t, const wchar_t *__restrict, const struct tm *__restrict);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
|
|
|
#undef iswdigit
|
|
|
|
|
2016-09-10 01:23:17 +00:00
|
|
|
#if defined(_GNU_SOURCE)
|
|
|
|
wint_t fgetwc_unlocked (FILE *);
|
|
|
|
wint_t getwc_unlocked (FILE *);
|
|
|
|
wint_t getwchar_unlocked (void);
|
|
|
|
wint_t fputwc_unlocked (wchar_t, FILE *);
|
|
|
|
wint_t putwc_unlocked (wchar_t, FILE *);
|
|
|
|
wint_t putwchar_unlocked (wchar_t);
|
|
|
|
wchar_t *fgetws_unlocked (wchar_t *__restrict, int, FILE *__restrict);
|
|
|
|
int fputws_unlocked (const wchar_t *__restrict, FILE *__restrict);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
|
|
|
size_t wcsftime_l (wchar_t *__restrict, size_t, const wchar_t *__restrict, const struct tm *__restrict, locale_t);
|
|
|
|
#endif
|
|
|
|
|
2011-05-30 17:32:40 +00:00
|
|
|
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|
2013-08-02 22:14:44 +00:00
|
|
|
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
2011-09-03 23:49:46 +00:00
|
|
|
FILE *open_wmemstream(wchar_t **, size_t *);
|
2012-09-07 02:44:55 +00:00
|
|
|
size_t mbsnrtowcs(wchar_t *__restrict, const char **__restrict, size_t, size_t, mbstate_t *__restrict);
|
|
|
|
size_t wcsnrtombs(char *__restrict, const wchar_t **__restrict, size_t, size_t, mbstate_t *__restrict);
|
2012-03-02 04:24:45 +00:00
|
|
|
wchar_t *wcsdup(const wchar_t *);
|
|
|
|
size_t wcsnlen (const wchar_t *, size_t);
|
2012-09-07 02:44:55 +00:00
|
|
|
wchar_t *wcpcpy (wchar_t *__restrict, const wchar_t *__restrict);
|
|
|
|
wchar_t *wcpncpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
|
2012-03-02 04:24:45 +00:00
|
|
|
int wcscasecmp(const wchar_t *, const wchar_t *);
|
|
|
|
int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
|
|
|
|
int wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
|
|
|
|
int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
|
|
|
|
int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
|
2016-10-20 21:04:37 +00:00
|
|
|
size_t wcsxfrm_l(wchar_t *__restrict, const wchar_t *__restrict, size_t, locale_t);
|
2011-05-30 17:32:40 +00:00
|
|
|
#endif
|
|
|
|
|
2013-08-02 22:14:44 +00:00
|
|
|
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
2011-02-15 00:33:11 +00:00
|
|
|
int wcwidth (wchar_t);
|
|
|
|
int wcswidth (const wchar_t *, size_t);
|
2011-02-12 05:22:29 +00:00
|
|
|
int iswalnum(wint_t);
|
|
|
|
int iswalpha(wint_t);
|
|
|
|
int iswblank(wint_t);
|
|
|
|
int iswcntrl(wint_t);
|
|
|
|
int iswdigit(wint_t);
|
|
|
|
int iswgraph(wint_t);
|
|
|
|
int iswlower(wint_t);
|
|
|
|
int iswprint(wint_t);
|
|
|
|
int iswpunct(wint_t);
|
|
|
|
int iswspace(wint_t);
|
|
|
|
int iswupper(wint_t);
|
|
|
|
int iswxdigit(wint_t);
|
|
|
|
int iswctype(wint_t, wctype_t);
|
|
|
|
wint_t towlower(wint_t);
|
|
|
|
wint_t towupper(wint_t);
|
|
|
|
wctype_t wctype(const char *);
|
2014-10-14 16:30:50 +00:00
|
|
|
|
|
|
|
#ifndef __cplusplus
|
2011-02-15 00:33:11 +00:00
|
|
|
#undef iswdigit
|
2015-05-03 01:17:19 +00:00
|
|
|
#define iswdigit(a) (0 ? iswdigit(a) : ((unsigned)(a)-'0') < 10)
|
2011-02-15 00:33:11 +00:00
|
|
|
#endif
|
2014-10-14 16:30:50 +00:00
|
|
|
#endif
|
2011-02-12 05:22:29 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|