wchar.h 13 KB

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