summaryrefslogtreecommitdiffstats
path: root/gl/uchar.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/uchar.h')
-rw-r--r--gl/uchar.h1449
1 files changed, 1449 insertions, 0 deletions
diff --git a/gl/uchar.h b/gl/uchar.h
new file mode 100644
index 00000000..a06ed8ab
--- /dev/null
+++ b/gl/uchar.h
@@ -0,0 +1,1449 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* <uchar.h> substitute - 16-bit and 32-bit wide character types.
3 Copyright (C) 2019-2025 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
19
20/*
21 * ISO C 23 <uchar.h> for platforms that lack it.
22 */
23
24#ifndef _GL_UCHAR_H
25
26#if __GNUC__ >= 3
27#pragma GCC system_header
28#endif
29
30
31/* The include_next requires a split double-inclusion guard. */
32#if (defined __cplusplus ? 0 : 1)
33# if defined __HAIKU__
34/* Work around <https://dev.haiku-os.org/ticket/17040>. */
35# include <stdint.h>
36# endif
37/* On AIX 7.2 with xlclang++, /usr/include/uchar.h produces compilation errors
38 because it contains typedef definitions of char16_t and char32_t, however
39 char16_t and char32_t are keywords in this situation. To work around it,
40 define char16_t and char32_t as macros. */
41# if defined __cplusplus && defined _AIX && defined __ibmxl__ && defined __clang__
42# define char16_t gl_char16_t
43# define char32_t gl_char32_t
44# endif
45# include_next <uchar.h>
46#endif
47
48#ifndef _GL_UCHAR_H
49#define _GL_UCHAR_H
50
51/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_BEGIN_C_LINKAGE,
52 _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
53#if !_GL_CONFIG_H_INCLUDED
54 #error "Please include config.h first."
55#endif
56
57/* Get uint_least16_t, uint_least32_t. */
58#include <stdint.h>
59
60/* Get mbstate_t, size_t. */
61#include <wchar.h>
62
63/* For the inline functions. */
64#include <string.h>
65#include <wctype.h>
66
67/* The __attribute__ feature is available in gcc versions 2.5 and later.
68 The attribute __pure__ was added in gcc 2.96. */
69#ifndef _GL_ATTRIBUTE_PURE
70# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
71# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
72# else
73# define _GL_ATTRIBUTE_PURE /* empty */
74# endif
75#endif
76
77/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
78/* C++ compatible function declaration macros.
79 Copyright (C) 2010-2025 Free Software Foundation, Inc.
80
81 This program is free software: you can redistribute it and/or modify it
82 under the terms of the GNU Lesser General Public License as published
83 by the Free Software Foundation; either version 2 of the License, or
84 (at your option) any later version.
85
86 This program is distributed in the hope that it will be useful,
87 but WITHOUT ANY WARRANTY; without even the implied warranty of
88 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
89 Lesser General Public License for more details.
90
91 You should have received a copy of the GNU Lesser General Public License
92 along with this program. If not, see <https://www.gnu.org/licenses/>. */
93
94#ifndef _GL_CXXDEFS_H
95#define _GL_CXXDEFS_H
96
97/* Begin/end the GNULIB_NAMESPACE namespace. */
98#if defined __cplusplus && defined GNULIB_NAMESPACE
99# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
100# define _GL_END_NAMESPACE }
101#else
102# define _GL_BEGIN_NAMESPACE
103# define _GL_END_NAMESPACE
104#endif
105
106/* The three most frequent use cases of these macros are:
107
108 * For providing a substitute for a function that is missing on some
109 platforms, but is declared and works fine on the platforms on which
110 it exists:
111
112 #if @GNULIB_FOO@
113 # if !@HAVE_FOO@
114 _GL_FUNCDECL_SYS (foo, ...);
115 # endif
116 _GL_CXXALIAS_SYS (foo, ...);
117 _GL_CXXALIASWARN (foo);
118 #elif defined GNULIB_POSIXCHECK
119 ...
120 #endif
121
122 * For providing a replacement for a function that exists on all platforms,
123 but is broken/insufficient and needs to be replaced on some platforms:
124
125 #if @GNULIB_FOO@
126 # if @REPLACE_FOO@
127 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
128 # undef foo
129 # define foo rpl_foo
130 # endif
131 _GL_FUNCDECL_RPL (foo, ...);
132 _GL_CXXALIAS_RPL (foo, ...);
133 # else
134 _GL_CXXALIAS_SYS (foo, ...);
135 # endif
136 _GL_CXXALIASWARN (foo);
137 #elif defined GNULIB_POSIXCHECK
138 ...
139 #endif
140
141 * For providing a replacement for a function that exists on some platforms
142 but is broken/insufficient and needs to be replaced on some of them and
143 is additionally either missing or undeclared on some other platforms:
144
145 #if @GNULIB_FOO@
146 # if @REPLACE_FOO@
147 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
148 # undef foo
149 # define foo rpl_foo
150 # endif
151 _GL_FUNCDECL_RPL (foo, ...);
152 _GL_CXXALIAS_RPL (foo, ...);
153 # else
154 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
155 _GL_FUNCDECL_SYS (foo, ...);
156 # endif
157 _GL_CXXALIAS_SYS (foo, ...);
158 # endif
159 _GL_CXXALIASWARN (foo);
160 #elif defined GNULIB_POSIXCHECK
161 ...
162 #endif
163*/
164
165/* _GL_EXTERN_C declaration;
166 performs the declaration with C linkage. */
167#if defined __cplusplus
168# define _GL_EXTERN_C extern "C"
169#else
170# define _GL_EXTERN_C extern
171#endif
172
173/* _GL_EXTERN_C_FUNC declaration;
174 performs the declaration of a function with C linkage. */
175#if defined __cplusplus
176# define _GL_EXTERN_C_FUNC extern "C"
177#else
178/* In C mode, omit the 'extern' keyword, because attributes in bracket syntax
179 are not allowed between 'extern' and the return type (see gnulib-common.m4).
180 */
181# define _GL_EXTERN_C_FUNC
182#endif
183
184/* _GL_FUNCDECL_RPL (func, rettype, parameters, [attributes]);
185 declares a replacement function, named rpl_func, with the given prototype,
186 consisting of return type, parameters, and attributes.
187 Although attributes are optional, the comma before them is required
188 for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
189 if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
190 at the end of the declaration.
191 Examples:
192 _GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
193 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
194 _GL_ARG_NONNULL ((1)));
195
196 Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front
197 of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's
198 because
199 [[...]] extern "C" <declaration>;
200 is invalid syntax in C++.)
201 */
202#define _GL_FUNCDECL_RPL(func,rettype,parameters,...) \
203 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters, __VA_ARGS__)
204#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \
205 _GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters
206
207/* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]);
208 declares the system function, named func, with the given prototype,
209 consisting of return type, parameters, and attributes.
210 Although attributes are optional, the comma before them is required
211 for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
212 if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
213 at the end of the declaration.
214 Examples:
215 _GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
216 _GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
217 */
218#define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \
219 _GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters
220
221/* _GL_CXXALIAS_RPL (func, rettype, parameters);
222 declares a C++ alias called GNULIB_NAMESPACE::func
223 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
224 Example:
225 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
226
227 Wrapping rpl_func in an object with an inline conversion operator
228 avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
229 actually used in the program. */
230#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
231 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
232#if defined __cplusplus && defined GNULIB_NAMESPACE
233# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
234 namespace GNULIB_NAMESPACE \
235 { \
236 static const struct _gl_ ## func ## _wrapper \
237 { \
238 typedef rettype (*type) parameters; \
239 \
240 inline operator type () const \
241 { \
242 return ::rpl_func; \
243 } \
244 } func = {}; \
245 } \
246 _GL_EXTERN_C int _gl_cxxalias_dummy
247#else
248# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
249 _GL_EXTERN_C int _gl_cxxalias_dummy
250#endif
251
252/* _GL_CXXALIAS_MDA (func, rettype, parameters);
253 is to be used when func is a Microsoft deprecated alias, on native Windows.
254 It declares a C++ alias called GNULIB_NAMESPACE::func
255 that redirects to _func, if GNULIB_NAMESPACE is defined.
256 Example:
257 _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
258 */
259#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
260 _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
261
262/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
263 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
264 except that the C function rpl_func may have a slightly different
265 declaration. A cast is used to silence the "invalid conversion" error
266 that would otherwise occur. */
267#if defined __cplusplus && defined GNULIB_NAMESPACE
268# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
269 namespace GNULIB_NAMESPACE \
270 { \
271 static const struct _gl_ ## func ## _wrapper \
272 { \
273 typedef rettype (*type) parameters; \
274 \
275 inline operator type () const \
276 { \
277 return reinterpret_cast<type>(::rpl_func); \
278 } \
279 } func = {}; \
280 } \
281 _GL_EXTERN_C int _gl_cxxalias_dummy
282#else
283# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
284 _GL_EXTERN_C int _gl_cxxalias_dummy
285#endif
286
287/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
288 is like _GL_CXXALIAS_MDA (func, rettype, parameters);
289 except that the C function func may have a slightly different declaration.
290 A cast is used to silence the "invalid conversion" error that would
291 otherwise occur. */
292#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
293 _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
294
295/* _GL_CXXALIAS_SYS (func, rettype, parameters);
296 declares a C++ alias called GNULIB_NAMESPACE::func
297 that redirects to the system provided function func, if GNULIB_NAMESPACE
298 is defined.
299 Example:
300 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
301
302 Wrapping func in an object with an inline conversion operator
303 avoids a reference to func unless GNULIB_NAMESPACE::func is
304 actually used in the program. */
305#if defined __cplusplus && defined GNULIB_NAMESPACE
306# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
307 namespace GNULIB_NAMESPACE \
308 { \
309 static const struct _gl_ ## func ## _wrapper \
310 { \
311 typedef rettype (*type) parameters; \
312 \
313 inline operator type () const \
314 { \
315 return ::func; \
316 } \
317 } func = {}; \
318 } \
319 _GL_EXTERN_C int _gl_cxxalias_dummy
320#else
321# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
322 _GL_EXTERN_C int _gl_cxxalias_dummy
323#endif
324
325/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
326 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
327 except that the C function func may have a slightly different declaration.
328 A cast is used to silence the "invalid conversion" error that would
329 otherwise occur. */
330#if defined __cplusplus && defined GNULIB_NAMESPACE
331# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
332 namespace GNULIB_NAMESPACE \
333 { \
334 static const struct _gl_ ## func ## _wrapper \
335 { \
336 typedef rettype (*type) parameters; \
337 \
338 inline operator type () const \
339 { \
340 return reinterpret_cast<type>(::func); \
341 } \
342 } func = {}; \
343 } \
344 _GL_EXTERN_C int _gl_cxxalias_dummy
345#else
346# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
347 _GL_EXTERN_C int _gl_cxxalias_dummy
348#endif
349
350/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
351 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
352 except that the C function is picked among a set of overloaded functions,
353 namely the one with rettype2 and parameters2. Two consecutive casts
354 are used to silence the "cannot find a match" and "invalid conversion"
355 errors that would otherwise occur. */
356#if defined __cplusplus && defined GNULIB_NAMESPACE
357 /* The outer cast must be a reinterpret_cast.
358 The inner cast: When the function is defined as a set of overloaded
359 functions, it works as a static_cast<>, choosing the designated variant.
360 When the function is defined as a single variant, it works as a
361 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
362# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
363 namespace GNULIB_NAMESPACE \
364 { \
365 static const struct _gl_ ## func ## _wrapper \
366 { \
367 typedef rettype (*type) parameters; \
368 \
369 inline operator type () const \
370 { \
371 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
372 } \
373 } func = {}; \
374 } \
375 _GL_EXTERN_C int _gl_cxxalias_dummy
376#else
377# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
378 _GL_EXTERN_C int _gl_cxxalias_dummy
379#endif
380
381/* _GL_CXXALIASWARN (func);
382 causes a warning to be emitted when ::func is used but not when
383 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
384 variants. */
385#if defined __cplusplus && defined GNULIB_NAMESPACE
386# define _GL_CXXALIASWARN(func) \
387 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
388# define _GL_CXXALIASWARN_1(func,namespace) \
389 _GL_CXXALIASWARN_2 (func, namespace)
390/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
391 we enable the warning only when not optimizing. */
392# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
393# define _GL_CXXALIASWARN_2(func,namespace) \
394 _GL_WARN_ON_USE (func, \
395 "The symbol ::" #func " refers to the system function. " \
396 "Use " #namespace "::" #func " instead.")
397# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
398# define _GL_CXXALIASWARN_2(func,namespace) \
399 extern __typeof__ (func) func
400# else
401# define _GL_CXXALIASWARN_2(func,namespace) \
402 _GL_EXTERN_C int _gl_cxxalias_dummy
403# endif
404#else
405# define _GL_CXXALIASWARN(func) \
406 _GL_EXTERN_C int _gl_cxxalias_dummy
407#endif
408
409/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
410 causes a warning to be emitted when the given overloaded variant of ::func
411 is used but not when GNULIB_NAMESPACE::func is used. */
412#if defined __cplusplus && defined GNULIB_NAMESPACE
413# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
414 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
415 GNULIB_NAMESPACE)
416# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
417 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
418/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
419 we enable the warning only when not optimizing. */
420# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
421# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
422 _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
423 "The symbol ::" #func " refers to the system function. " \
424 "Use " #namespace "::" #func " instead.")
425# else
426# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
427 _GL_EXTERN_C int _gl_cxxalias_dummy
428# endif
429#else
430# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
431 _GL_EXTERN_C int _gl_cxxalias_dummy
432#endif
433
434#endif /* _GL_CXXDEFS_H */
435
436/* The definition of _GL_ARG_NONNULL is copied here. */
437/* A C macro for declaring that specific arguments must not be NULL.
438 Copyright (C) 2009-2025 Free Software Foundation, Inc.
439
440 This program is free software: you can redistribute it and/or modify it
441 under the terms of the GNU Lesser General Public License as published
442 by the Free Software Foundation; either version 2 of the License, or
443 (at your option) any later version.
444
445 This program is distributed in the hope that it will be useful,
446 but WITHOUT ANY WARRANTY; without even the implied warranty of
447 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
448 Lesser General Public License for more details.
449
450 You should have received a copy of the GNU Lesser General Public License
451 along with this program. If not, see <https://www.gnu.org/licenses/>. */
452
453/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
454 that the values passed as arguments n, ..., m must be non-NULL pointers.
455 n = 1 stands for the first argument, n = 2 for the second argument etc. */
456#ifndef _GL_ARG_NONNULL
457# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
458# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
459# else
460# define _GL_ARG_NONNULL(params)
461# endif
462#endif
463
464/* The definition of _GL_WARN_ON_USE is copied here. */
465/* A C macro for emitting warnings if a function is used.
466 Copyright (C) 2010-2025 Free Software Foundation, Inc.
467
468 This program is free software: you can redistribute it and/or modify it
469 under the terms of the GNU Lesser General Public License as published
470 by the Free Software Foundation; either version 2 of the License, or
471 (at your option) any later version.
472
473 This program is distributed in the hope that it will be useful,
474 but WITHOUT ANY WARRANTY; without even the implied warranty of
475 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
476 Lesser General Public License for more details.
477
478 You should have received a copy of the GNU Lesser General Public License
479 along with this program. If not, see <https://www.gnu.org/licenses/>. */
480
481/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
482 for FUNCTION which will then trigger a compiler warning containing
483 the text of "literal string" anywhere that function is called, if
484 supported by the compiler. If the compiler does not support this
485 feature, the macro expands to an unused extern declaration.
486
487 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
488 attribute used in _GL_WARN_ON_USE. If the compiler does not support
489 this feature, it expands to empty.
490
491 These macros are useful for marking a function as a potential
492 portability trap, with the intent that "literal string" include
493 instructions on the replacement function that should be used
494 instead.
495 _GL_WARN_ON_USE is for functions with 'extern' linkage.
496 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
497 linkage.
498
499 _GL_WARN_ON_USE should not be used more than once for a given function
500 in a given compilation unit (because this may generate a warning even
501 if the function is never called).
502
503 However, one of the reasons that a function is a portability trap is
504 if it has the wrong signature. Declaring FUNCTION with a different
505 signature in C is a compilation error, so this macro must use the
506 same type as any existing declaration so that programs that avoid
507 the problematic FUNCTION do not fail to compile merely because they
508 included a header that poisoned the function. But this implies that
509 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
510 have a declaration. Use of this macro implies that there must not
511 be any other macro hiding the declaration of FUNCTION; but
512 undefining FUNCTION first is part of the poisoning process anyway
513 (although for symbols that are provided only via a macro, the result
514 is a compilation error rather than a warning containing
515 "literal string"). Also note that in C++, it is only safe to use if
516 FUNCTION has no overloads.
517
518 For an example, it is possible to poison 'getline' by:
519 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
520 [getline]) in configure.ac, which potentially defines
521 HAVE_RAW_DECL_GETLINE
522 - adding this code to a header that wraps the system <stdio.h>:
523 #undef getline
524 #if HAVE_RAW_DECL_GETLINE
525 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
526 "not universally present; use the gnulib module getline");
527 #endif
528
529 It is not possible to directly poison global variables. But it is
530 possible to write a wrapper accessor function, and poison that
531 (less common usage, like &environ, will cause a compilation error
532 rather than issue the nice warning, but the end result of informing
533 the developer about their portability problem is still achieved):
534 #if HAVE_RAW_DECL_ENVIRON
535 static char ***
536 rpl_environ (void) { return &environ; }
537 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
538 # undef environ
539 # define environ (*rpl_environ ())
540 #endif
541 or better (avoiding contradictory use of 'static' and 'extern'):
542 #if HAVE_RAW_DECL_ENVIRON
543 static char ***
544 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
545 rpl_environ (void) { return &environ; }
546 # undef environ
547 # define environ (*rpl_environ ())
548 #endif
549 */
550#ifndef _GL_WARN_ON_USE
551
552# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
553/* A compiler attribute is available in gcc versions 4.3.0 and later. */
554# define _GL_WARN_ON_USE(function, message) \
555_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
556# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
557 __attribute__ ((__warning__ (message)))
558# elif __clang_major__ >= 4
559/* Another compiler attribute is available in clang. */
560# define _GL_WARN_ON_USE(function, message) \
561_GL_WARN_EXTERN_C __typeof__ (function) function \
562 __attribute__ ((__diagnose_if__ (1, message, "warning")))
563# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
564 __attribute__ ((__diagnose_if__ (1, message, "warning")))
565# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
566/* Verify the existence of the function. */
567# define _GL_WARN_ON_USE(function, message) \
568_GL_WARN_EXTERN_C __typeof__ (function) function
569# define _GL_WARN_ON_USE_ATTRIBUTE(message)
570# else /* Unsupported. */
571# define _GL_WARN_ON_USE(function, message) \
572_GL_WARN_EXTERN_C int _gl_warn_on_use
573# define _GL_WARN_ON_USE_ATTRIBUTE(message)
574# endif
575#endif
576
577/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
578 is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
579 function is declared with the given prototype, consisting of return type,
580 parameters, and attributes.
581 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
582 not work in this case. */
583#ifndef _GL_WARN_ON_USE_CXX
584# if !defined __cplusplus
585# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
586 _GL_WARN_ON_USE (function, msg)
587# else
588# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
589/* A compiler attribute is available in gcc versions 4.3.0 and later. */
590# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
591extern rettype_gcc function parameters_and_attributes \
592 __attribute__ ((__warning__ (msg)))
593# elif __clang_major__ >= 4
594/* Another compiler attribute is available in clang. */
595# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
596extern rettype_clang function parameters_and_attributes \
597 __attribute__ ((__diagnose_if__ (1, msg, "warning")))
598# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
599/* Verify the existence of the function. */
600# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
601extern rettype_gcc function parameters_and_attributes
602# else /* Unsupported. */
603# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
604_GL_WARN_EXTERN_C int _gl_warn_on_use
605# endif
606# endif
607#endif
608
609/* _GL_WARN_EXTERN_C declaration;
610 performs the declaration with C linkage. */
611#ifndef _GL_WARN_EXTERN_C
612# if defined __cplusplus
613# define _GL_WARN_EXTERN_C extern "C"
614# else
615# define _GL_WARN_EXTERN_C extern
616# endif
617#endif
618
619
620_GL_INLINE_HEADER_BEGIN
621
622
623#if !(defined __cplusplus ? 0 || 0 : 1)
624
625/* An 8-bit variant of wchar_t.
626 Note: This type is only mandated by ISO C 23 or newer, and it does
627 denote UTF-8 units. */
628typedef unsigned char char8_t;
629
630#elif 0
631
632typedef unsigned char gl_char8_t;
633# define char8_t gl_char8_t
634
635#endif
636
637#if !(defined __cplusplus ? 0 || 0 : 1)
638
639/* A 16-bit variant of wchar_t.
640 Note: This type is only mandated by ISO C 11 or newer. In ISO C 23
641 and newer, it denotes UTF-16 units; in older versions of ISO C it did
642 so only on platforms on which __STDC_UTF_16__ was defined. */
643typedef uint_least16_t char16_t;
644
645#elif 0
646
647typedef uint_least16_t gl_char16_t;
648# define char16_t gl_char16_t
649
650#endif
651
652#if !(defined __cplusplus ? 0 || 0 : 1)
653
654/* A 32-bit variant of wchar_t.
655 Note: This type is only mandated by ISO C 11 or newer. In ISO C 23
656 and newer, it denotes UTF-32 code points; in older versions of ISO C
657 it did so only on platforms on which __STDC_UTF_32__ was defined.
658 In gnulib, we guarantee that it denotes UTF-32 code points if and
659 only if the module 'uchar-h-c23' is in use. */
660typedef uint_least32_t char32_t;
661
662#elif 0
663
664typedef uint_least32_t gl_char32_t;
665# define char32_t gl_char32_t
666
667#endif
668
669/* Define if a 'char32_t' can hold more characters than a 'wchar_t'. */
670#if 0 /* 32-bit AIX, Cygwin, native Windows */
671# define _GL_SMALL_WCHAR_T 1
672#endif
673
674/* Define if 'wchar_t', like 'char32_t',
675 - is a 32-bit type, and
676 - represents Unicode code points.
677 For this test, we can use __STDC_ISO_10646__ (defined by glibc, musl libc,
678 Cygwin) but need to consider _GL_SMALL_WCHAR_T, so as to exclude Cygwin.
679 We cannot use __STDC_UTF_16__ or __STDC_UTF_32__
680 - because these macros provide info about char16_t and char32_t (not
681 wchar_t!), and
682 - because GCC >= 4.9 defines these macros on all platforms, even on
683 FreeBSD and Solaris.
684 We should better not use __STD_UTF_16__, __STD_UTF_32__ either, because
685 these macros are misspellings, only defined by Android's <uchar.h>. */
686#if defined __STDC_ISO_10646__ && !_GL_SMALL_WCHAR_T
687/* glibc, musl libc */
688# define _GL_WCHAR_T_IS_UCS4 1
689#endif
690#if _GL_WCHAR_T_IS_UCS4
691static_assert (sizeof (char32_t) == sizeof (wchar_t));
692#endif
693
694
695/* Convert a single-byte character to a 32-bit wide character. */
696#if 0
697# if _GL_WCHAR_T_IS_UCS4 && !defined IN_BTOC32
698_GL_BEGIN_C_LINKAGE
699_GL_INLINE _GL_ATTRIBUTE_PURE wint_t
700btoc32 (int c)
701{
702 return
703# if 1 && defined __cplusplus && defined GNULIB_NAMESPACE
704 GNULIB_NAMESPACE::
705# endif
706 btowc (c);
707}
708_GL_END_C_LINKAGE
709# else
710_GL_FUNCDECL_SYS (btoc32, wint_t, (int c), _GL_ATTRIBUTE_PURE);
711# endif
712_GL_CXXALIAS_SYS (btoc32, wint_t, (int c));
713_GL_CXXALIASWARN (btoc32);
714#endif
715
716
717/* Test a specific property of a 32-bit wide character. */
718#if 1
719# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISALNUM
720_GL_BEGIN_C_LINKAGE
721_GL_INLINE int
722c32isalnum (wint_t wc)
723{
724 return
725# if defined __cplusplus && defined GNULIB_NAMESPACE
726 GNULIB_NAMESPACE::
727# endif
728 iswalnum (wc);
729}
730_GL_END_C_LINKAGE
731# else
732_GL_FUNCDECL_SYS (c32isalnum, int, (wint_t wc), );
733# endif
734_GL_CXXALIAS_SYS (c32isalnum, int, (wint_t wc));
735_GL_CXXALIASWARN (c32isalnum);
736#endif
737#if 1
738# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISALPHA
739_GL_BEGIN_C_LINKAGE
740_GL_INLINE int
741c32isalpha (wint_t wc)
742{
743 return
744# if defined __cplusplus && defined GNULIB_NAMESPACE
745 GNULIB_NAMESPACE::
746# endif
747 iswalpha (wc);
748}
749_GL_END_C_LINKAGE
750# else
751_GL_FUNCDECL_SYS (c32isalpha, int, (wint_t wc), );
752# endif
753_GL_CXXALIAS_SYS (c32isalpha, int, (wint_t wc));
754_GL_CXXALIASWARN (c32isalpha);
755#endif
756#if 1
757# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISBLANK
758_GL_BEGIN_C_LINKAGE
759_GL_INLINE int
760c32isblank (wint_t wc)
761{
762 return
763# if defined __cplusplus && defined GNULIB_NAMESPACE
764 GNULIB_NAMESPACE::
765# endif
766 iswblank (wc);
767}
768_GL_END_C_LINKAGE
769# else
770_GL_FUNCDECL_SYS (c32isblank, int, (wint_t wc), );
771# endif
772_GL_CXXALIAS_SYS (c32isblank, int, (wint_t wc));
773_GL_CXXALIASWARN (c32isblank);
774#endif
775#if 1
776# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISCNTRL
777_GL_BEGIN_C_LINKAGE
778_GL_INLINE int
779c32iscntrl (wint_t wc)
780{
781 return
782# if defined __cplusplus && defined GNULIB_NAMESPACE
783 GNULIB_NAMESPACE::
784# endif
785 iswcntrl (wc);
786}
787_GL_END_C_LINKAGE
788# else
789_GL_FUNCDECL_SYS (c32iscntrl, int, (wint_t wc), );
790# endif
791_GL_CXXALIAS_SYS (c32iscntrl, int, (wint_t wc));
792_GL_CXXALIASWARN (c32iscntrl);
793#endif
794#if 1
795# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISDIGIT
796_GL_BEGIN_C_LINKAGE
797_GL_INLINE int
798c32isdigit (wint_t wc)
799{
800 return
801# if 1 && defined __cplusplus && defined GNULIB_NAMESPACE
802 GNULIB_NAMESPACE::
803# endif
804 iswdigit (wc);
805}
806_GL_END_C_LINKAGE
807# else
808_GL_FUNCDECL_SYS (c32isdigit, int, (wint_t wc), );
809# endif
810_GL_CXXALIAS_SYS (c32isdigit, int, (wint_t wc));
811_GL_CXXALIASWARN (c32isdigit);
812#endif
813#if 1
814# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISGRAPH
815_GL_BEGIN_C_LINKAGE
816_GL_INLINE int
817c32isgraph (wint_t wc)
818{
819 return
820# if defined __cplusplus && defined GNULIB_NAMESPACE
821 GNULIB_NAMESPACE::
822# endif
823 iswgraph (wc);
824}
825_GL_END_C_LINKAGE
826# else
827_GL_FUNCDECL_SYS (c32isgraph, int, (wint_t wc), );
828# endif
829_GL_CXXALIAS_SYS (c32isgraph, int, (wint_t wc));
830_GL_CXXALIASWARN (c32isgraph);
831#endif
832#if 1
833# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISLOWER
834_GL_BEGIN_C_LINKAGE
835_GL_INLINE int
836c32islower (wint_t wc)
837{
838 return
839# if defined __cplusplus && defined GNULIB_NAMESPACE
840 GNULIB_NAMESPACE::
841# endif
842 iswlower (wc);
843}
844_GL_END_C_LINKAGE
845# else
846_GL_FUNCDECL_SYS (c32islower, int, (wint_t wc), );
847# endif
848_GL_CXXALIAS_SYS (c32islower, int, (wint_t wc));
849_GL_CXXALIASWARN (c32islower);
850#endif
851#if 1
852# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISPRINT
853_GL_BEGIN_C_LINKAGE
854_GL_INLINE int
855c32isprint (wint_t wc)
856{
857 return
858# if defined __cplusplus && defined GNULIB_NAMESPACE
859 GNULIB_NAMESPACE::
860# endif
861 iswprint (wc);
862}
863_GL_END_C_LINKAGE
864# else
865_GL_FUNCDECL_SYS (c32isprint, int, (wint_t wc), );
866# endif
867_GL_CXXALIAS_SYS (c32isprint, int, (wint_t wc));
868_GL_CXXALIASWARN (c32isprint);
869#endif
870#if 1
871# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISPUNCT
872_GL_BEGIN_C_LINKAGE
873_GL_INLINE int
874c32ispunct (wint_t wc)
875{
876 return
877# if defined __cplusplus && defined GNULIB_NAMESPACE
878 GNULIB_NAMESPACE::
879# endif
880 iswpunct (wc);
881}
882_GL_END_C_LINKAGE
883# else
884_GL_FUNCDECL_SYS (c32ispunct, int, (wint_t wc), );
885# endif
886_GL_CXXALIAS_SYS (c32ispunct, int, (wint_t wc));
887_GL_CXXALIASWARN (c32ispunct);
888#endif
889#if 1
890# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISSPACE
891_GL_BEGIN_C_LINKAGE
892_GL_INLINE int
893c32isspace (wint_t wc)
894{
895 return
896# if defined __cplusplus && defined GNULIB_NAMESPACE
897 GNULIB_NAMESPACE::
898# endif
899 iswspace (wc);
900}
901_GL_END_C_LINKAGE
902# else
903_GL_FUNCDECL_SYS (c32isspace, int, (wint_t wc), );
904# endif
905_GL_CXXALIAS_SYS (c32isspace, int, (wint_t wc));
906_GL_CXXALIASWARN (c32isspace);
907#endif
908#if 1
909# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISUPPER
910_GL_BEGIN_C_LINKAGE
911_GL_INLINE int
912c32isupper (wint_t wc)
913{
914 return
915# if defined __cplusplus && defined GNULIB_NAMESPACE
916 GNULIB_NAMESPACE::
917# endif
918 iswupper (wc);
919}
920_GL_END_C_LINKAGE
921# else
922_GL_FUNCDECL_SYS (c32isupper, int, (wint_t wc), );
923# endif
924_GL_CXXALIAS_SYS (c32isupper, int, (wint_t wc));
925_GL_CXXALIASWARN (c32isupper);
926#endif
927#if 1
928# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISXDIGIT
929_GL_BEGIN_C_LINKAGE
930_GL_INLINE int
931c32isxdigit (wint_t wc)
932{
933 return
934# if 1 && defined __cplusplus && defined GNULIB_NAMESPACE
935 GNULIB_NAMESPACE::
936# endif
937 iswxdigit (wc);
938}
939_GL_END_C_LINKAGE
940# else
941_GL_FUNCDECL_SYS (c32isxdigit, int, (wint_t wc), );
942# endif
943_GL_CXXALIAS_SYS (c32isxdigit, int, (wint_t wc));
944_GL_CXXALIASWARN (c32isxdigit);
945#endif
946
947
948/* Case mapping of a 32-bit wide character. */
949#if 1
950# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32TOLOWER
951_GL_BEGIN_C_LINKAGE
952_GL_INLINE wint_t
953c32tolower (wint_t wc)
954{
955 return
956# if defined __cplusplus && defined GNULIB_NAMESPACE
957 GNULIB_NAMESPACE::
958# endif
959 towlower (wc);
960}
961_GL_END_C_LINKAGE
962# else
963_GL_FUNCDECL_SYS (c32tolower, wint_t, (wint_t wc), );
964# endif
965_GL_CXXALIAS_SYS (c32tolower, wint_t, (wint_t wc));
966_GL_CXXALIASWARN (c32tolower);
967#endif
968#if 0
969# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32TOUPPER
970_GL_BEGIN_C_LINKAGE
971_GL_INLINE wint_t
972c32toupper (wint_t wc)
973{
974 return
975# if defined __cplusplus && defined GNULIB_NAMESPACE
976 GNULIB_NAMESPACE::
977# endif
978 towupper (wc);
979}
980_GL_END_C_LINKAGE
981# else
982_GL_FUNCDECL_SYS (c32toupper, wint_t, (wint_t wc), );
983# endif
984_GL_CXXALIAS_SYS (c32toupper, wint_t, (wint_t wc));
985_GL_CXXALIASWARN (c32toupper);
986#endif
987
988
989/* Number of screen columns needed for a 32-bit wide character. */
990#if 1
991# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32WIDTH
992_GL_BEGIN_C_LINKAGE
993_GL_INLINE int
994c32width (char32_t wc)
995{
996 return
997# if 1 && defined __cplusplus && defined GNULIB_NAMESPACE
998 GNULIB_NAMESPACE::
999# endif
1000 wcwidth (wc);
1001}
1002_GL_END_C_LINKAGE
1003# else
1004_GL_FUNCDECL_SYS (c32width, int, (char32_t wc), );
1005# endif
1006_GL_CXXALIAS_SYS (c32width, int, (char32_t wc));
1007_GL_CXXALIASWARN (c32width);
1008#endif
1009
1010
1011/* Converts a 32-bit wide character to a multibyte character. */
1012#if 0
1013# if 0
1014# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1015# undef c32rtomb
1016# define c32rtomb rpl_c32rtomb
1017# endif
1018_GL_FUNCDECL_RPL (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps), );
1019_GL_CXXALIAS_RPL (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps));
1020# else
1021# if !1
1022_GL_FUNCDECL_SYS (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps), );
1023# endif
1024_GL_CXXALIAS_SYS (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps));
1025# endif
1026# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
1027_GL_CXXALIASWARN (c32rtomb);
1028# endif
1029#elif defined GNULIB_POSIXCHECK
1030# undef c32rtomb
1031# if HAVE_RAW_DECL_C32RTOMB
1032_GL_WARN_ON_USE (c32rtomb, "c32rtomb is not portable - "
1033 "use gnulib module c32rtomb for portability");
1034# endif
1035#endif
1036
1037
1038/* Convert a 32-bit wide string to a string. */
1039#if 0
1040# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32SNRTOMBS
1041_GL_BEGIN_C_LINKAGE
1042_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
1043c32snrtombs (char *dest, const char32_t **srcp, size_t srclen, size_t len,
1044 mbstate_t *ps)
1045{
1046 return
1047# if 0 && defined __cplusplus && defined GNULIB_NAMESPACE
1048 GNULIB_NAMESPACE::
1049# endif
1050 wcsnrtombs (dest, (const wchar_t **) srcp, srclen, len, ps);
1051}
1052_GL_END_C_LINKAGE
1053# else
1054_GL_FUNCDECL_SYS (c32snrtombs, size_t,
1055 (char *dest, const char32_t **srcp, size_t srclen, size_t len,
1056 mbstate_t *ps),
1057 _GL_ARG_NONNULL ((2)));
1058# endif
1059_GL_CXXALIAS_SYS (c32snrtombs, size_t,
1060 (char *dest, const char32_t **srcp, size_t srclen, size_t len,
1061 mbstate_t *ps));
1062_GL_CXXALIASWARN (c32snrtombs);
1063#endif
1064
1065
1066/* Convert a 32-bit wide string to a string. */
1067#if 0
1068# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32SRTOMBS
1069_GL_BEGIN_C_LINKAGE
1070_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
1071c32srtombs (char *dest, const char32_t **srcp, size_t len, mbstate_t *ps)
1072{
1073 return
1074# if 0 && defined __cplusplus && defined GNULIB_NAMESPACE
1075 GNULIB_NAMESPACE::
1076# endif
1077 wcsrtombs (dest, (const wchar_t **) srcp, len, ps);
1078}
1079_GL_END_C_LINKAGE
1080# else
1081_GL_FUNCDECL_SYS (c32srtombs, size_t,
1082 (char *dest, const char32_t **srcp, size_t len,
1083 mbstate_t *ps),
1084 _GL_ARG_NONNULL ((2)));
1085# endif
1086_GL_CXXALIAS_SYS (c32srtombs, size_t,
1087 (char *dest, const char32_t **srcp, size_t len,
1088 mbstate_t *ps));
1089_GL_CXXALIASWARN (c32srtombs);
1090#endif
1091
1092
1093/* Convert a 32-bit wide string to a string. */
1094#if 0
1095# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32STOMBS
1096_GL_BEGIN_C_LINKAGE
1097_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
1098c32stombs (char *dest, const char32_t *src, size_t len)
1099{
1100 mbstate_t state;
1101
1102 mbszero (&state);
1103 return c32srtombs (dest, &src, len, &state);
1104}
1105_GL_END_C_LINKAGE
1106# else
1107_GL_FUNCDECL_SYS (c32stombs, size_t,
1108 (char *dest, const char32_t *src, size_t len),
1109 _GL_ARG_NONNULL ((2)));
1110# endif
1111_GL_CXXALIAS_SYS (c32stombs, size_t,
1112 (char *dest, const char32_t *src, size_t len));
1113_GL_CXXALIASWARN (c32stombs);
1114#endif
1115
1116
1117/* Number of screen columns needed for a size-bounded 32-bit wide string. */
1118#if 0
1119# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32SWIDTH
1120_GL_BEGIN_C_LINKAGE
1121_GL_INLINE _GL_ARG_NONNULL ((1)) int
1122c32swidth (const char32_t *s, size_t n)
1123{
1124 return
1125# if 0 && defined __cplusplus && defined GNULIB_NAMESPACE
1126 GNULIB_NAMESPACE::
1127# endif
1128 wcswidth ((const wchar_t *) s, n);
1129}
1130_GL_END_C_LINKAGE
1131# else
1132_GL_FUNCDECL_SYS (c32swidth, int, (const char32_t *s, size_t n),
1133 _GL_ARG_NONNULL ((1)));
1134# endif
1135_GL_CXXALIAS_SYS (c32swidth, int, (const char32_t *s, size_t n));
1136_GL_CXXALIASWARN (c32swidth);
1137#endif
1138
1139
1140/* Converts a 32-bit wide character to unibyte character.
1141 Returns the single-byte representation of WC if it exists,
1142 or EOF otherwise. */
1143#if 0
1144# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32TOB
1145_GL_BEGIN_C_LINKAGE
1146_GL_INLINE int
1147c32tob (wint_t wc)
1148{
1149 return
1150# if 0 && defined __cplusplus && defined GNULIB_NAMESPACE
1151 GNULIB_NAMESPACE::
1152# endif
1153 wctob (wc);
1154}
1155_GL_END_C_LINKAGE
1156# else
1157_GL_FUNCDECL_SYS (c32tob, int, (wint_t wc), );
1158# endif
1159_GL_CXXALIAS_SYS (c32tob, int, (wint_t wc));
1160_GL_CXXALIASWARN (c32tob);
1161#endif
1162
1163
1164/* Converts a multibyte character to a 32-bit wide character. */
1165#if 1
1166# if 1
1167# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1168# undef mbrtoc32
1169# define mbrtoc32 rpl_mbrtoc32
1170# endif
1171_GL_FUNCDECL_RPL (mbrtoc32, size_t,
1172 (char32_t *pc, const char *s, size_t n, mbstate_t *ps), );
1173_GL_CXXALIAS_RPL (mbrtoc32, size_t,
1174 (char32_t *pc, const char *s, size_t n, mbstate_t *ps));
1175# else
1176# if !1
1177_GL_FUNCDECL_SYS (mbrtoc32, size_t,
1178 (char32_t *pc, const char *s, size_t n, mbstate_t *ps), );
1179# endif
1180_GL_CXXALIAS_SYS (mbrtoc32, size_t,
1181 (char32_t *pc, const char *s, size_t n, mbstate_t *ps));
1182# endif
1183# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
1184_GL_CXXALIASWARN (mbrtoc32);
1185# endif
1186#elif defined GNULIB_POSIXCHECK
1187# undef mbrtoc32
1188# if HAVE_RAW_DECL_MBRTOC32
1189_GL_WARN_ON_USE (mbrtoc32, "mbrtoc32 is not portable - "
1190 "use gnulib module mbrtoc32 for portability");
1191# endif
1192#endif
1193
1194
1195/* Converts a multibyte character and returns the next 16-bit wide
1196 character. */
1197#if 0
1198# if 0
1199# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1200# undef mbrtoc16
1201# define mbrtoc16 rpl_mbrtoc16
1202# endif
1203_GL_FUNCDECL_RPL (mbrtoc16, size_t,
1204 (char16_t *pc, const char *s, size_t n, mbstate_t *ps), );
1205_GL_CXXALIAS_RPL (mbrtoc16, size_t,
1206 (char16_t *pc, const char *s, size_t n, mbstate_t *ps));
1207# else
1208# if !1
1209_GL_FUNCDECL_SYS (mbrtoc16, size_t,
1210 (char16_t *pc, const char *s, size_t n, mbstate_t *ps), );
1211# endif
1212_GL_CXXALIAS_SYS (mbrtoc16, size_t,
1213 (char16_t *pc, const char *s, size_t n, mbstate_t *ps));
1214# endif
1215# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
1216_GL_CXXALIASWARN (mbrtoc16);
1217# endif
1218#elif defined GNULIB_POSIXCHECK
1219# undef mbrtoc16
1220# if HAVE_RAW_DECL_MBRTOC16
1221_GL_WARN_ON_USE (mbrtoc16, "mbrtoc16 is not portable - "
1222 "use gnulib module mbrtoc16 for portability");
1223# endif
1224#endif
1225
1226
1227/* Convert a string to a 32-bit wide string. */
1228#if 0
1229# if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSNRTOC32S
1230_GL_BEGIN_C_LINKAGE
1231_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
1232mbsnrtoc32s (char32_t *dest, const char **srcp, size_t srclen, size_t len,
1233 mbstate_t *ps)
1234{
1235 return
1236# if 0 && defined __cplusplus && defined GNULIB_NAMESPACE
1237 GNULIB_NAMESPACE::
1238# endif
1239 mbsnrtowcs ((wchar_t *) dest, srcp, srclen, len, ps);
1240}
1241_GL_END_C_LINKAGE
1242# else
1243_GL_FUNCDECL_SYS (mbsnrtoc32s, size_t,
1244 (char32_t *dest, const char **srcp, size_t srclen, size_t len,
1245 mbstate_t *ps),
1246 _GL_ARG_NONNULL ((2)));
1247# endif
1248_GL_CXXALIAS_SYS (mbsnrtoc32s, size_t,
1249 (char32_t *dest, const char **srcp, size_t srclen, size_t len,
1250 mbstate_t *ps));
1251_GL_CXXALIASWARN (mbsnrtoc32s);
1252#endif
1253
1254
1255/* Convert a string to a 32-bit wide string. */
1256#if 0
1257# if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSRTOC32S
1258_GL_BEGIN_C_LINKAGE
1259_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
1260mbsrtoc32s (char32_t *dest, const char **srcp, size_t len, mbstate_t *ps)
1261{
1262 return
1263# if 0 && defined __cplusplus && defined GNULIB_NAMESPACE
1264 GNULIB_NAMESPACE::
1265# endif
1266 mbsrtowcs ((wchar_t *) dest, srcp, len, ps);
1267}
1268_GL_END_C_LINKAGE
1269# else
1270_GL_FUNCDECL_SYS (mbsrtoc32s, size_t,
1271 (char32_t *dest, const char **srcp, size_t len,
1272 mbstate_t *ps),
1273 _GL_ARG_NONNULL ((2)));
1274# endif
1275_GL_CXXALIAS_SYS (mbsrtoc32s, size_t,
1276 (char32_t *dest, const char **srcp, size_t len,
1277 mbstate_t *ps));
1278_GL_CXXALIASWARN (mbsrtoc32s);
1279#endif
1280
1281
1282/* Convert a string to a 32-bit wide string. */
1283#if 0
1284# if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSTOC32S
1285_GL_BEGIN_C_LINKAGE
1286_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
1287mbstoc32s (char32_t *dest, const char *src, size_t len)
1288{
1289 mbstate_t state;
1290
1291 mbszero (&state);
1292 return mbsrtoc32s (dest, &src, len, &state);
1293}
1294_GL_END_C_LINKAGE
1295# else
1296_GL_FUNCDECL_SYS (mbstoc32s, size_t,
1297 (char32_t *dest, const char *src, size_t len),
1298 _GL_ARG_NONNULL ((2)));
1299# endif
1300_GL_CXXALIAS_SYS (mbstoc32s, size_t,
1301 (char32_t *dest, const char *src, size_t len));
1302_GL_CXXALIASWARN (mbstoc32s);
1303#endif
1304
1305
1306#if 0 || 0
1307/* A scalar type. Instances of this type, other than (c32_type_test_t) 0,
1308 represent a character property, sometimes also viewed as a "character class".
1309 It can be applied to 32-bit wide characters. It is the counterpart of
1310 type 'wctype_t' for wide characters.
1311 To test whether a given character has a certain property, use the function
1312 'c32_apply_type_test'. */
1313# if _GL_WCHAR_T_IS_UCS4
1314typedef wctype_t c32_type_test_t;
1315# else
1316typedef /*bool*/int (*c32_type_test_t) (wint_t wc);
1317# endif
1318#endif
1319
1320/* Return a character property with the given name, or (c32_type_test_t) 0
1321 if the designated property does not exist.
1322 This function is the counterpart of function 'wctype' for wide characters.
1323 */
1324#if 0
1325# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_GET_TYPE_TEST
1326_GL_BEGIN_C_LINKAGE
1327_GL_INLINE _GL_ARG_NONNULL ((1)) c32_type_test_t
1328c32_get_type_test (const char *name)
1329{
1330 return
1331# if 1 && defined __cplusplus && defined GNULIB_NAMESPACE
1332 GNULIB_NAMESPACE::
1333# endif
1334 wctype (name);
1335}
1336_GL_END_C_LINKAGE
1337# else
1338_GL_FUNCDECL_SYS (c32_get_type_test, c32_type_test_t, (const char *name),
1339 _GL_ARG_NONNULL ((1)));
1340# endif
1341_GL_CXXALIAS_SYS (c32_get_type_test, c32_type_test_t, (const char *name));
1342_GL_CXXALIASWARN (c32_get_type_test);
1343#endif
1344
1345/* Test whether a given 32-bit wide character has the specified character
1346 property.
1347 Return non-zero if true, zero if false or if the argument is WEOF.
1348 This function is the counterpart of function 'iswctype' for wide characters.
1349 */
1350#if 0
1351# if _GL_WCHAR_T_IS_UCS4
1352# if !defined IN_C32_APPLY_TYPE_TEST
1353_GL_BEGIN_C_LINKAGE
1354_GL_INLINE int
1355c32_apply_type_test (wint_t wc, c32_type_test_t property)
1356{
1357 return
1358# if 1 && defined __cplusplus && defined GNULIB_NAMESPACE
1359 GNULIB_NAMESPACE::
1360# endif
1361 iswctype (wc, property);
1362}
1363_GL_END_C_LINKAGE
1364# else
1365_GL_FUNCDECL_SYS (c32_apply_type_test, int,
1366 (wint_t wc, c32_type_test_t property), );
1367# endif
1368# else
1369_GL_FUNCDECL_SYS (c32_apply_type_test, int,
1370 (wint_t wc, c32_type_test_t property),
1371 _GL_ARG_NONNULL ((2)));
1372# endif
1373_GL_CXXALIAS_SYS (c32_apply_type_test, int,
1374 (wint_t wc, c32_type_test_t property));
1375_GL_CXXALIASWARN (c32_apply_type_test);
1376#endif
1377
1378
1379#if 0 || 0
1380/* A scalar type. Instances of this type, other than (c32_mapping_t) 0,
1381 represent a character mapping. It can be applied to 32-bit wide characters.
1382 It is the counterpart of type 'wctrans_t' for wide characters.
1383 To apply a certain mapping to a given character, use the function
1384 'c32_apply_mapping'. */
1385# if _GL_WCHAR_T_IS_UCS4
1386typedef wctrans_t c32_mapping_t;
1387# else
1388typedef wint_t (*c32_mapping_t) (wint_t wc);
1389# endif
1390#endif
1391
1392/* Return a character mapping with the given name, or (c32_mapping_t) 0
1393 if the designated mapping does not exist.
1394 This function is the counterpart of function 'wctrans' for wide characters.
1395 */
1396#if 0
1397# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_GET_MAPPING
1398_GL_BEGIN_C_LINKAGE
1399_GL_INLINE _GL_ARG_NONNULL ((1)) c32_mapping_t
1400c32_get_mapping (const char *name)
1401{
1402 return
1403# if 0 && defined __cplusplus && defined GNULIB_NAMESPACE
1404 GNULIB_NAMESPACE::
1405# endif
1406 wctrans (name);
1407}
1408_GL_END_C_LINKAGE
1409# else
1410_GL_FUNCDECL_SYS (c32_get_mapping, c32_mapping_t, (const char *name),
1411 _GL_ARG_NONNULL ((1)));
1412# endif
1413_GL_CXXALIAS_SYS (c32_get_mapping, c32_mapping_t, (const char *name));
1414_GL_CXXALIASWARN (c32_get_mapping);
1415#endif
1416
1417/* Apply the specified character mapping to a given 32-bit wide character.
1418 Return the result of this mapping. Return the WC argument unchanged if it is
1419 WEOF.
1420 This function is the counterpart of function 'towctrans' for wide characters.
1421 */
1422#if 0
1423# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_APPLY_MAPPING
1424_GL_BEGIN_C_LINKAGE
1425_GL_INLINE _GL_ARG_NONNULL ((2)) wint_t
1426c32_apply_mapping (wint_t wc, c32_mapping_t mapping)
1427{
1428 return
1429# if 0 && defined __cplusplus && defined GNULIB_NAMESPACE
1430 GNULIB_NAMESPACE::
1431# endif
1432 towctrans (wc, mapping);
1433}
1434_GL_END_C_LINKAGE
1435# else
1436_GL_FUNCDECL_SYS (c32_apply_mapping, wint_t,
1437 (wint_t wc, c32_mapping_t mapping),
1438 _GL_ARG_NONNULL ((2)));
1439# endif
1440_GL_CXXALIAS_SYS (c32_apply_mapping, wint_t,
1441 (wint_t wc, c32_mapping_t mapping));
1442_GL_CXXALIASWARN (c32_apply_mapping);
1443#endif
1444
1445
1446_GL_INLINE_HEADER_END
1447
1448#endif /* _GL_UCHAR_H */
1449#endif /* _GL_UCHAR_H */