1/* This file is automatically generated.  DO NOT EDIT! */
2/* Generated from: NetBSD: mknative-gdb,v 1.16 2023/07/31 17:09:59 christos Exp  */
3/* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
4
5/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
6/* A GNU-like <string.h>.
7
8   Copyright (C) 1995-1996, 2001-2022 Free Software Foundation, Inc.
9
10   This file is free software: you can redistribute it and/or modify
11   it under the terms of the GNU Lesser General Public License as
12   published by the Free Software Foundation; either version 2.1 of the
13   License, or (at your option) any later version.
14
15   This file is distributed in the hope that it will be useful,
16   but WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   GNU Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
22
23#if __GNUC__ >= 3
24#pragma GCC system_header
25#endif
26
27
28#if defined _GL_ALREADY_INCLUDING_STRING_H
29/* Special invocation convention:
30   - On OS X/NetBSD we have a sequence of nested includes
31       <string.h> -> <strings.h> -> "string.h"
32     In this situation system _chk variants due to -D_FORTIFY_SOURCE
33     might be used after any replacements defined here.  */
34
35#include_next <string.h>
36
37#else
38/* Normal invocation convention.  */
39
40#ifndef _GL_STRING_H
41
42#define _GL_ALREADY_INCLUDING_STRING_H
43
44/* The include_next requires a split double-inclusion guard.  */
45#include_next <string.h>
46
47#undef _GL_ALREADY_INCLUDING_STRING_H
48
49#ifndef _GL_STRING_H
50#define _GL_STRING_H
51
52/* NetBSD 5.0 mis-defines NULL.  */
53#include <stddef.h>
54
55/* MirBSD defines mbslen as a macro.  */
56#if 0 && defined __MirBSD__
57# include <wchar.h>
58#endif
59
60/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>.  */
61/* But in any case avoid namespace pollution on glibc systems.  */
62#if (0 || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
63    && ! defined __GLIBC__
64# include <unistd.h>
65#endif
66
67/* AIX 7.2 declares ffsl and ffsll in <strings.h>, not in <string.h>.  */
68/* But in any case avoid namespace pollution on glibc systems.  */
69#if ((0 || 0 || defined GNULIB_POSIXCHECK) \
70     && defined _AIX) \
71    && ! defined __GLIBC__
72# include <strings.h>
73#endif
74
75/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
76   that can be freed by passing them as the Ith argument to the
77   function F.  */
78#ifndef _GL_ATTRIBUTE_DEALLOC
79# if __GNUC__ >= 11
80#  define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
81# else
82#  define _GL_ATTRIBUTE_DEALLOC(f, i)
83# endif
84#endif
85
86/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
87   can be freed via 'free'; it can be used only after declaring 'free'.  */
88/* Applies to: functions.  Cannot be used on inline functions.  */
89#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
90# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
91#endif
92
93/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
94   allocated memory.  */
95/* Applies to: functions.  */
96#ifndef _GL_ATTRIBUTE_MALLOC
97# if __GNUC__ >= 3 || defined __clang__
98#  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
99# else
100#  define _GL_ATTRIBUTE_MALLOC
101# endif
102#endif
103
104/* The __attribute__ feature is available in gcc versions 2.5 and later.
105   The attribute __pure__ was added in gcc 2.96.  */
106#ifndef _GL_ATTRIBUTE_PURE
107# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
108#  define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
109# else
110#  define _GL_ATTRIBUTE_PURE /* empty */
111# endif
112#endif
113
114/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
115/* C++ compatible function declaration macros.
116   Copyright (C) 2010-2022 Free Software Foundation, Inc.
117
118   This program is free software: you can redistribute it and/or modify it
119   under the terms of the GNU Lesser General Public License as published
120   by the Free Software Foundation; either version 2 of the License, or
121   (at your option) any later version.
122
123   This program is distributed in the hope that it will be useful,
124   but WITHOUT ANY WARRANTY; without even the implied warranty of
125   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
126   Lesser General Public License for more details.
127
128   You should have received a copy of the GNU Lesser General Public License
129   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
130
131#ifndef _GL_CXXDEFS_H
132#define _GL_CXXDEFS_H
133
134/* Begin/end the GNULIB_NAMESPACE namespace.  */
135#if defined __cplusplus && defined GNULIB_NAMESPACE
136# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
137# define _GL_END_NAMESPACE }
138#else
139# define _GL_BEGIN_NAMESPACE
140# define _GL_END_NAMESPACE
141#endif
142
143/* The three most frequent use cases of these macros are:
144
145   * For providing a substitute for a function that is missing on some
146     platforms, but is declared and works fine on the platforms on which
147     it exists:
148
149       #if @GNULIB_FOO@
150       # if !@HAVE_FOO@
151       _GL_FUNCDECL_SYS (foo, ...);
152       # endif
153       _GL_CXXALIAS_SYS (foo, ...);
154       _GL_CXXALIASWARN (foo);
155       #elif defined GNULIB_POSIXCHECK
156       ...
157       #endif
158
159   * For providing a replacement for a function that exists on all platforms,
160     but is broken/insufficient and needs to be replaced on some platforms:
161
162       #if @GNULIB_FOO@
163       # if @REPLACE_FOO@
164       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
165       #   undef foo
166       #   define foo rpl_foo
167       #  endif
168       _GL_FUNCDECL_RPL (foo, ...);
169       _GL_CXXALIAS_RPL (foo, ...);
170       # else
171       _GL_CXXALIAS_SYS (foo, ...);
172       # endif
173       _GL_CXXALIASWARN (foo);
174       #elif defined GNULIB_POSIXCHECK
175       ...
176       #endif
177
178   * For providing a replacement for a function that exists on some platforms
179     but is broken/insufficient and needs to be replaced on some of them and
180     is additionally either missing or undeclared on some other platforms:
181
182       #if @GNULIB_FOO@
183       # if @REPLACE_FOO@
184       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
185       #   undef foo
186       #   define foo rpl_foo
187       #  endif
188       _GL_FUNCDECL_RPL (foo, ...);
189       _GL_CXXALIAS_RPL (foo, ...);
190       # else
191       #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
192       _GL_FUNCDECL_SYS (foo, ...);
193       #  endif
194       _GL_CXXALIAS_SYS (foo, ...);
195       # endif
196       _GL_CXXALIASWARN (foo);
197       #elif defined GNULIB_POSIXCHECK
198       ...
199       #endif
200*/
201
202/* _GL_EXTERN_C declaration;
203   performs the declaration with C linkage.  */
204#if defined __cplusplus
205# define _GL_EXTERN_C extern "C"
206#else
207# define _GL_EXTERN_C extern
208#endif
209
210/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
211   declares a replacement function, named rpl_func, with the given prototype,
212   consisting of return type, parameters, and attributes.
213   Example:
214     _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
215                                  _GL_ARG_NONNULL ((1)));
216 */
217#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
218  _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
219#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
220  _GL_EXTERN_C rettype rpl_func parameters_and_attributes
221
222/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
223   declares the system function, named func, with the given prototype,
224   consisting of return type, parameters, and attributes.
225   Example:
226     _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
227                                  _GL_ARG_NONNULL ((1)));
228 */
229#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
230  _GL_EXTERN_C rettype func parameters_and_attributes
231
232/* _GL_CXXALIAS_RPL (func, rettype, parameters);
233   declares a C++ alias called GNULIB_NAMESPACE::func
234   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
235   Example:
236     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
237
238   Wrapping rpl_func in an object with an inline conversion operator
239   avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
240   actually used in the program.  */
241#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
242  _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
243#if defined __cplusplus && defined GNULIB_NAMESPACE
244# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
245    namespace GNULIB_NAMESPACE                                \
246    {                                                         \
247      static const struct _gl_ ## func ## _wrapper            \
248      {                                                       \
249        typedef rettype (*type) parameters;                   \
250                                                              \
251        inline operator type () const                         \
252        {                                                     \
253          return ::rpl_func;                                  \
254        }                                                     \
255      } func = {};                                            \
256    }                                                         \
257    _GL_EXTERN_C int _gl_cxxalias_dummy
258#else
259# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
260    _GL_EXTERN_C int _gl_cxxalias_dummy
261#endif
262
263/* _GL_CXXALIAS_MDA (func, rettype, parameters);
264   is to be used when func is a Microsoft deprecated alias, on native Windows.
265   It declares a C++ alias called GNULIB_NAMESPACE::func
266   that redirects to _func, if GNULIB_NAMESPACE is defined.
267   Example:
268     _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
269 */
270#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
271  _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
272
273/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
274   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
275   except that the C function rpl_func may have a slightly different
276   declaration.  A cast is used to silence the "invalid conversion" error
277   that would otherwise occur.  */
278#if defined __cplusplus && defined GNULIB_NAMESPACE
279# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
280    namespace GNULIB_NAMESPACE                                     \
281    {                                                              \
282      static const struct _gl_ ## func ## _wrapper                 \
283      {                                                            \
284        typedef rettype (*type) parameters;                        \
285                                                                   \
286        inline operator type () const                              \
287        {                                                          \
288          return reinterpret_cast<type>(::rpl_func);               \
289        }                                                          \
290      } func = {};                                                 \
291    }                                                              \
292    _GL_EXTERN_C int _gl_cxxalias_dummy
293#else
294# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
295    _GL_EXTERN_C int _gl_cxxalias_dummy
296#endif
297
298/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
299   is like  _GL_CXXALIAS_MDA (func, rettype, parameters);
300   except that the C function func may have a slightly different declaration.
301   A cast is used to silence the "invalid conversion" error that would
302   otherwise occur.  */
303#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
304  _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
305
306/* _GL_CXXALIAS_SYS (func, rettype, parameters);
307   declares a C++ alias called GNULIB_NAMESPACE::func
308   that redirects to the system provided function func, if GNULIB_NAMESPACE
309   is defined.
310   Example:
311     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
312
313   Wrapping func in an object with an inline conversion operator
314   avoids a reference to func unless GNULIB_NAMESPACE::func is
315   actually used in the program.  */
316#if defined __cplusplus && defined GNULIB_NAMESPACE
317# define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
318    namespace GNULIB_NAMESPACE                                \
319    {                                                         \
320      static const struct _gl_ ## func ## _wrapper            \
321      {                                                       \
322        typedef rettype (*type) parameters;                   \
323                                                              \
324        inline operator type () const                         \
325        {                                                     \
326          return ::func;                                      \
327        }                                                     \
328      } func = {};                                            \
329    }                                                         \
330    _GL_EXTERN_C int _gl_cxxalias_dummy
331#else
332# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
333    _GL_EXTERN_C int _gl_cxxalias_dummy
334#endif
335
336/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
337   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
338   except that the C function func may have a slightly different declaration.
339   A cast is used to silence the "invalid conversion" error that would
340   otherwise occur.  */
341#if defined __cplusplus && defined GNULIB_NAMESPACE
342# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
343    namespace GNULIB_NAMESPACE                          \
344    {                                                   \
345      static const struct _gl_ ## func ## _wrapper      \
346      {                                                 \
347        typedef rettype (*type) parameters;             \
348                                                        \
349        inline operator type () const                   \
350        {                                               \
351          return reinterpret_cast<type>(::func);        \
352        }                                               \
353      } func = {};                                      \
354    }                                                   \
355    _GL_EXTERN_C int _gl_cxxalias_dummy
356#else
357# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
358    _GL_EXTERN_C int _gl_cxxalias_dummy
359#endif
360
361/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
362   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
363   except that the C function is picked among a set of overloaded functions,
364   namely the one with rettype2 and parameters2.  Two consecutive casts
365   are used to silence the "cannot find a match" and "invalid conversion"
366   errors that would otherwise occur.  */
367#if defined __cplusplus && defined GNULIB_NAMESPACE
368  /* The outer cast must be a reinterpret_cast.
369     The inner cast: When the function is defined as a set of overloaded
370     functions, it works as a static_cast<>, choosing the designated variant.
371     When the function is defined as a single variant, it works as a
372     reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
373# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
374    namespace GNULIB_NAMESPACE                                                \
375    {                                                                         \
376      static const struct _gl_ ## func ## _wrapper                            \
377      {                                                                       \
378        typedef rettype (*type) parameters;                                   \
379                                                                              \
380        inline operator type () const                                         \
381        {                                                                     \
382          return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
383        }                                                                     \
384      } func = {};                                                            \
385    }                                                                         \
386    _GL_EXTERN_C int _gl_cxxalias_dummy
387#else
388# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
389    _GL_EXTERN_C int _gl_cxxalias_dummy
390#endif
391
392/* _GL_CXXALIASWARN (func);
393   causes a warning to be emitted when ::func is used but not when
394   GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
395   variants.  */
396#if defined __cplusplus && defined GNULIB_NAMESPACE
397# define _GL_CXXALIASWARN(func) \
398   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
399# define _GL_CXXALIASWARN_1(func,namespace) \
400   _GL_CXXALIASWARN_2 (func, namespace)
401/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
402   we enable the warning only when not optimizing.  */
403# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
404#  define _GL_CXXALIASWARN_2(func,namespace) \
405    _GL_WARN_ON_USE (func, \
406                     "The symbol ::" #func " refers to the system function. " \
407                     "Use " #namespace "::" #func " instead.")
408# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
409#  define _GL_CXXALIASWARN_2(func,namespace) \
410     extern __typeof__ (func) func
411# else
412#  define _GL_CXXALIASWARN_2(func,namespace) \
413     _GL_EXTERN_C int _gl_cxxalias_dummy
414# endif
415#else
416# define _GL_CXXALIASWARN(func) \
417    _GL_EXTERN_C int _gl_cxxalias_dummy
418#endif
419
420/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
421   causes a warning to be emitted when the given overloaded variant of ::func
422   is used but not when GNULIB_NAMESPACE::func is used.  */
423#if defined __cplusplus && defined GNULIB_NAMESPACE
424# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
425   _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
426                        GNULIB_NAMESPACE)
427# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
428   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
429/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
430   we enable the warning only when not optimizing.  */
431# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
432#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
433    _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
434                         "The symbol ::" #func " refers to the system function. " \
435                         "Use " #namespace "::" #func " instead.")
436# else
437#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
438     _GL_EXTERN_C int _gl_cxxalias_dummy
439# endif
440#else
441# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
442    _GL_EXTERN_C int _gl_cxxalias_dummy
443#endif
444
445#endif /* _GL_CXXDEFS_H */
446
447/* The definition of _GL_ARG_NONNULL is copied here.  */
448/* A C macro for declaring that specific arguments must not be NULL.
449   Copyright (C) 2009-2022 Free Software Foundation, Inc.
450
451   This program is free software: you can redistribute it and/or modify it
452   under the terms of the GNU Lesser General Public License as published
453   by the Free Software Foundation; either version 2 of the License, or
454   (at your option) any later version.
455
456   This program is distributed in the hope that it will be useful,
457   but WITHOUT ANY WARRANTY; without even the implied warranty of
458   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
459   Lesser General Public License for more details.
460
461   You should have received a copy of the GNU Lesser General Public License
462   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
463
464/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
465   that the values passed as arguments n, ..., m must be non-NULL pointers.
466   n = 1 stands for the first argument, n = 2 for the second argument etc.  */
467#ifndef _GL_ARG_NONNULL
468# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
469#  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
470# else
471#  define _GL_ARG_NONNULL(params)
472# endif
473#endif
474
475/* The definition of _GL_WARN_ON_USE is copied here.  */
476/* A C macro for emitting warnings if a function is used.
477   Copyright (C) 2010-2022 Free Software Foundation, Inc.
478
479   This program is free software: you can redistribute it and/or modify it
480   under the terms of the GNU Lesser General Public License as published
481   by the Free Software Foundation; either version 2 of the License, or
482   (at your option) any later version.
483
484   This program is distributed in the hope that it will be useful,
485   but WITHOUT ANY WARRANTY; without even the implied warranty of
486   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
487   Lesser General Public License for more details.
488
489   You should have received a copy of the GNU Lesser General Public License
490   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
491
492/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
493   for FUNCTION which will then trigger a compiler warning containing
494   the text of "literal string" anywhere that function is called, if
495   supported by the compiler.  If the compiler does not support this
496   feature, the macro expands to an unused extern declaration.
497
498   _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
499   attribute used in _GL_WARN_ON_USE.  If the compiler does not support
500   this feature, it expands to empty.
501
502   These macros are useful for marking a function as a potential
503   portability trap, with the intent that "literal string" include
504   instructions on the replacement function that should be used
505   instead.
506   _GL_WARN_ON_USE is for functions with 'extern' linkage.
507   _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
508   linkage.
509
510   However, one of the reasons that a function is a portability trap is
511   if it has the wrong signature.  Declaring FUNCTION with a different
512   signature in C is a compilation error, so this macro must use the
513   same type as any existing declaration so that programs that avoid
514   the problematic FUNCTION do not fail to compile merely because they
515   included a header that poisoned the function.  But this implies that
516   _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
517   have a declaration.  Use of this macro implies that there must not
518   be any other macro hiding the declaration of FUNCTION; but
519   undefining FUNCTION first is part of the poisoning process anyway
520   (although for symbols that are provided only via a macro, the result
521   is a compilation error rather than a warning containing
522   "literal string").  Also note that in C++, it is only safe to use if
523   FUNCTION has no overloads.
524
525   For an example, it is possible to poison 'getline' by:
526   - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
527     [getline]) in configure.ac, which potentially defines
528     HAVE_RAW_DECL_GETLINE
529   - adding this code to a header that wraps the system <stdio.h>:
530     #undef getline
531     #if HAVE_RAW_DECL_GETLINE
532     _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
533       "not universally present; use the gnulib module getline");
534     #endif
535
536   It is not possible to directly poison global variables.  But it is
537   possible to write a wrapper accessor function, and poison that
538   (less common usage, like &environ, will cause a compilation error
539   rather than issue the nice warning, but the end result of informing
540   the developer about their portability problem is still achieved):
541     #if HAVE_RAW_DECL_ENVIRON
542     static char ***
543     rpl_environ (void) { return &environ; }
544     _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
545     # undef environ
546     # define environ (*rpl_environ ())
547     #endif
548   or better (avoiding contradictory use of 'static' and 'extern'):
549     #if HAVE_RAW_DECL_ENVIRON
550     static char ***
551     _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
552     rpl_environ (void) { return &environ; }
553     # undef environ
554     # define environ (*rpl_environ ())
555     #endif
556   */
557#ifndef _GL_WARN_ON_USE
558
559# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
560/* A compiler attribute is available in gcc versions 4.3.0 and later.  */
561#  define _GL_WARN_ON_USE(function, message) \
562_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
563#  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
564  __attribute__ ((__warning__ (message)))
565# elif __clang_major__ >= 4
566/* Another compiler attribute is available in clang.  */
567#  define _GL_WARN_ON_USE(function, message) \
568_GL_WARN_EXTERN_C __typeof__ (function) function \
569  __attribute__ ((__diagnose_if__ (1, message, "warning")))
570#  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
571  __attribute__ ((__diagnose_if__ (1, message, "warning")))
572# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
573/* Verify the existence of the function.  */
574#  define _GL_WARN_ON_USE(function, message) \
575_GL_WARN_EXTERN_C __typeof__ (function) function
576#  define _GL_WARN_ON_USE_ATTRIBUTE(message)
577# else /* Unsupported.  */
578#  define _GL_WARN_ON_USE(function, message) \
579_GL_WARN_EXTERN_C int _gl_warn_on_use
580#  define _GL_WARN_ON_USE_ATTRIBUTE(message)
581# endif
582#endif
583
584/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
585   is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
586   function is declared with the given prototype, consisting of return type,
587   parameters, and attributes.
588   This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
589   not work in this case.  */
590#ifndef _GL_WARN_ON_USE_CXX
591# if !defined __cplusplus
592#  define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
593     _GL_WARN_ON_USE (function, msg)
594# else
595#  if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
596/* A compiler attribute is available in gcc versions 4.3.0 and later.  */
597#   define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
598extern rettype_gcc function parameters_and_attributes \
599  __attribute__ ((__warning__ (msg)))
600#  elif __clang_major__ >= 4
601/* Another compiler attribute is available in clang.  */
602#   define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
603extern rettype_clang function parameters_and_attributes \
604  __attribute__ ((__diagnose_if__ (1, msg, "warning")))
605#  elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
606/* Verify the existence of the function.  */
607#   define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
608extern rettype_gcc function parameters_and_attributes
609#  else /* Unsupported.  */
610#   define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
611_GL_WARN_EXTERN_C int _gl_warn_on_use
612#  endif
613# endif
614#endif
615
616/* _GL_WARN_EXTERN_C declaration;
617   performs the declaration with C linkage.  */
618#ifndef _GL_WARN_EXTERN_C
619# if defined __cplusplus
620#  define _GL_WARN_EXTERN_C extern "C"
621# else
622#  define _GL_WARN_EXTERN_C extern
623# endif
624#endif
625
626/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
627   been included yet.  */
628#if 1
629# if (1 && !defined free \
630      && !(defined __cplusplus && defined GNULIB_NAMESPACE))
631/* We can't do '#define free rpl_free' here.  */
632_GL_EXTERN_C void rpl_free (void *);
633#  undef _GL_ATTRIBUTE_DEALLOC_FREE
634#  define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
635# else
636#  if defined _MSC_VER
637_GL_EXTERN_C void __cdecl free (void *);
638#  else
639#   if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
640_GL_EXTERN_C void free (void *) throw ();
641#   else
642_GL_EXTERN_C void free (void *);
643#   endif
644#  endif
645# endif
646#else
647# if defined _MSC_VER
648_GL_EXTERN_C void __cdecl free (void *);
649# else
650#  if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
651_GL_EXTERN_C void free (void *) throw ();
652#  else
653_GL_EXTERN_C void free (void *);
654#  endif
655# endif
656#endif
657
658/* Clear a block of memory.  The compiler will not delete a call to
659   this function, even if the block is dead after the call.  */
660#if 0
661# if ! 1
662_GL_FUNCDECL_SYS (explicit_bzero, void,
663                  (void *__dest, size_t __n) _GL_ARG_NONNULL ((1)));
664# endif
665_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
666_GL_CXXALIASWARN (explicit_bzero);
667#elif defined GNULIB_POSIXCHECK
668# undef explicit_bzero
669# if HAVE_RAW_DECL_EXPLICIT_BZERO
670_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
671                 "use gnulib module explicit_bzero for portability");
672# endif
673#endif
674
675/* Find the index of the least-significant set bit.  */
676#if 0
677# if !1
678_GL_FUNCDECL_SYS (ffsl, int, (long int i));
679# endif
680_GL_CXXALIAS_SYS (ffsl, int, (long int i));
681_GL_CXXALIASWARN (ffsl);
682#elif defined GNULIB_POSIXCHECK
683# undef ffsl
684# if HAVE_RAW_DECL_FFSL
685_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
686# endif
687#endif
688
689
690/* Find the index of the least-significant set bit.  */
691#if 0
692# if 0
693#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
694#   define ffsll rpl_ffsll
695#  endif
696_GL_FUNCDECL_RPL (ffsll, int, (long long int i));
697_GL_CXXALIAS_RPL (ffsll, int, (long long int i));
698# else
699#  if !1
700_GL_FUNCDECL_SYS (ffsll, int, (long long int i));
701#  endif
702_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
703# endif
704_GL_CXXALIASWARN (ffsll);
705#elif defined GNULIB_POSIXCHECK
706# undef ffsll
707# if HAVE_RAW_DECL_FFSLL
708_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
709# endif
710#endif
711
712
713#if 1
714/* On native Windows, map 'memccpy' to '_memccpy', so that -loldnames is not
715   required.  In C++ with GNULIB_NAMESPACE, avoid differences between
716   platforms by defining GNULIB_NAMESPACE::memccpy always.  */
717# if defined _WIN32 && !defined __CYGWIN__
718#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
719#   undef memccpy
720#   define memccpy _memccpy
721#  endif
722_GL_CXXALIAS_MDA (memccpy, void *,
723                  (void *dest, const void *src, int c, size_t n));
724# else
725_GL_CXXALIAS_SYS (memccpy, void *,
726                  (void *dest, const void *src, int c, size_t n));
727# endif
728_GL_CXXALIASWARN (memccpy);
729#endif
730
731
732/* Return the first instance of C within N bytes of S, or NULL.  */
733#if 1
734# if 1
735#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
736#   undef memchr
737#   define memchr rpl_memchr
738#  endif
739_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
740                                  _GL_ATTRIBUTE_PURE
741                                  _GL_ARG_NONNULL ((1)));
742_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
743# else
744  /* On some systems, this function is defined as an overloaded function:
745       extern "C" { const void * std::memchr (const void *, int, size_t); }
746       extern "C++" { void * std::memchr (void *, int, size_t); }  */
747_GL_CXXALIAS_SYS_CAST2 (memchr,
748                        void *, (void const *__s, int __c, size_t __n),
749                        void const *, (void const *__s, int __c, size_t __n));
750# endif
751# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
752     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
753         || defined __clang__)
754_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n) throw ());
755_GL_CXXALIASWARN1 (memchr, void const *,
756                   (void const *__s, int __c, size_t __n) throw ());
757# elif __GLIBC__ >= 2
758_GL_CXXALIASWARN (memchr);
759# endif
760#elif defined GNULIB_POSIXCHECK
761# undef memchr
762/* Assume memchr is always declared.  */
763_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
764                 "use gnulib module memchr for portability" );
765#endif
766
767/* Return the first occurrence of NEEDLE in HAYSTACK.  */
768#if 1
769# if 1
770#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
771#   define memmem rpl_memmem
772#  endif
773_GL_FUNCDECL_RPL (memmem, void *,
774                  (void const *__haystack, size_t __haystack_len,
775                   void const *__needle, size_t __needle_len)
776                  _GL_ATTRIBUTE_PURE
777                  _GL_ARG_NONNULL ((1, 3)));
778_GL_CXXALIAS_RPL (memmem, void *,
779                  (void const *__haystack, size_t __haystack_len,
780                   void const *__needle, size_t __needle_len));
781# else
782#  if ! 1
783_GL_FUNCDECL_SYS (memmem, void *,
784                  (void const *__haystack, size_t __haystack_len,
785                   void const *__needle, size_t __needle_len)
786                  _GL_ATTRIBUTE_PURE
787                  _GL_ARG_NONNULL ((1, 3)));
788#  endif
789_GL_CXXALIAS_SYS (memmem, void *,
790                  (void const *__haystack, size_t __haystack_len,
791                   void const *__needle, size_t __needle_len));
792# endif
793_GL_CXXALIASWARN (memmem);
794#elif defined GNULIB_POSIXCHECK
795# undef memmem
796# if HAVE_RAW_DECL_MEMMEM
797_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
798                 "use gnulib module memmem-simple for portability, "
799                 "and module memmem for speed" );
800# endif
801#endif
802
803/* Copy N bytes of SRC to DEST, return pointer to bytes after the
804   last written byte.  */
805#if 1
806# if ! 1
807_GL_FUNCDECL_SYS (mempcpy, void *,
808                  (void *restrict __dest, void const *restrict __src,
809                   size_t __n)
810                  _GL_ARG_NONNULL ((1, 2)));
811# endif
812_GL_CXXALIAS_SYS (mempcpy, void *,
813                  (void *restrict __dest, void const *restrict __src,
814                   size_t __n));
815_GL_CXXALIASWARN (mempcpy);
816#elif defined GNULIB_POSIXCHECK
817# undef mempcpy
818# if HAVE_RAW_DECL_MEMPCPY
819_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
820                 "use gnulib module mempcpy for portability");
821# endif
822#endif
823
824/* Search backwards through a block for a byte (specified as an int).  */
825#if 1
826# if ! 1
827_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
828                                   _GL_ATTRIBUTE_PURE
829                                   _GL_ARG_NONNULL ((1)));
830# endif
831  /* On some systems, this function is defined as an overloaded function:
832       extern "C++" { const void * std::memrchr (const void *, int, size_t); }
833       extern "C++" { void * std::memrchr (void *, int, size_t); }  */
834_GL_CXXALIAS_SYS_CAST2 (memrchr,
835                        void *, (void const *, int, size_t),
836                        void const *, (void const *, int, size_t));
837# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
838     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
839         || defined __clang__)
840_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t) throw ());
841_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t) throw ());
842# else
843_GL_CXXALIASWARN (memrchr);
844# endif
845#elif defined GNULIB_POSIXCHECK
846# undef memrchr
847# if HAVE_RAW_DECL_MEMRCHR
848_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
849                 "use gnulib module memrchr for portability");
850# endif
851#endif
852
853/* Find the first occurrence of C in S.  More efficient than
854   memchr(S,C,N), at the expense of undefined behavior if C does not
855   occur within N bytes.  */
856#if 1
857# if ! 0
858_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
859                                     _GL_ATTRIBUTE_PURE
860                                     _GL_ARG_NONNULL ((1)));
861# endif
862  /* On some systems, this function is defined as an overloaded function:
863       extern "C++" { const void * std::rawmemchr (const void *, int); }
864       extern "C++" { void * std::rawmemchr (void *, int); }  */
865_GL_CXXALIAS_SYS_CAST2 (rawmemchr,
866                        void *, (void const *__s, int __c_in),
867                        void const *, (void const *__s, int __c_in));
868# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
869     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
870         || defined __clang__)
871_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in) throw ());
872_GL_CXXALIASWARN1 (rawmemchr, void const *,
873                   (void const *__s, int __c_in) throw ());
874# else
875_GL_CXXALIASWARN (rawmemchr);
876# endif
877#elif defined GNULIB_POSIXCHECK
878# undef rawmemchr
879# if HAVE_RAW_DECL_RAWMEMCHR
880_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
881                 "use gnulib module rawmemchr for portability");
882# endif
883#endif
884
885/* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
886#if 0
887# if ! 1
888_GL_FUNCDECL_SYS (stpcpy, char *,
889                  (char *restrict __dst, char const *restrict __src)
890                  _GL_ARG_NONNULL ((1, 2)));
891# endif
892_GL_CXXALIAS_SYS (stpcpy, char *,
893                  (char *restrict __dst, char const *restrict __src));
894_GL_CXXALIASWARN (stpcpy);
895#elif defined GNULIB_POSIXCHECK
896# undef stpcpy
897# if HAVE_RAW_DECL_STPCPY
898_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
899                 "use gnulib module stpcpy for portability");
900# endif
901#endif
902
903/* Copy no more than N bytes of SRC to DST, returning a pointer past the
904   last non-NUL byte written into DST.  */
905#if 0
906# if 0
907#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
908#   undef stpncpy
909#   define stpncpy rpl_stpncpy
910#  endif
911_GL_FUNCDECL_RPL (stpncpy, char *,
912                  (char *restrict __dst, char const *restrict __src,
913                   size_t __n)
914                  _GL_ARG_NONNULL ((1, 2)));
915_GL_CXXALIAS_RPL (stpncpy, char *,
916                  (char *restrict __dst, char const *restrict __src,
917                   size_t __n));
918# else
919#  if ! 1
920_GL_FUNCDECL_SYS (stpncpy, char *,
921                  (char *restrict __dst, char const *restrict __src,
922                   size_t __n)
923                  _GL_ARG_NONNULL ((1, 2)));
924#  endif
925_GL_CXXALIAS_SYS (stpncpy, char *,
926                  (char *restrict __dst, char const *restrict __src,
927                   size_t __n));
928# endif
929_GL_CXXALIASWARN (stpncpy);
930#elif defined GNULIB_POSIXCHECK
931# undef stpncpy
932# if HAVE_RAW_DECL_STPNCPY
933_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
934                 "use gnulib module stpncpy for portability");
935# endif
936#endif
937
938#if defined GNULIB_POSIXCHECK
939/* strchr() does not work with multibyte strings if the locale encoding is
940   GB18030 and the character to be searched is a digit.  */
941# undef strchr
942/* Assume strchr is always declared.  */
943_GL_WARN_ON_USE_CXX (strchr,
944                     const char *, char *, (const char *, int),
945                     "strchr cannot work correctly on character strings "
946                     "in some multibyte locales - "
947                     "use mbschr if you care about internationalization");
948#endif
949
950/* Find the first occurrence of C in S or the final NUL byte.  */
951#if 1
952# if 0
953#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
954#   define strchrnul rpl_strchrnul
955#  endif
956_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
957                                     _GL_ATTRIBUTE_PURE
958                                     _GL_ARG_NONNULL ((1)));
959_GL_CXXALIAS_RPL (strchrnul, char *,
960                  (const char *str, int ch));
961# else
962#  if ! 1
963_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
964                                     _GL_ATTRIBUTE_PURE
965                                     _GL_ARG_NONNULL ((1)));
966#  endif
967  /* On some systems, this function is defined as an overloaded function:
968       extern "C++" { const char * std::strchrnul (const char *, int); }
969       extern "C++" { char * std::strchrnul (char *, int); }  */
970_GL_CXXALIAS_SYS_CAST2 (strchrnul,
971                        char *, (char const *__s, int __c_in),
972                        char const *, (char const *__s, int __c_in));
973# endif
974# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
975     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
976         || defined __clang__)
977_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in) throw ());
978_GL_CXXALIASWARN1 (strchrnul, char const *,
979                   (char const *__s, int __c_in) throw ());
980# else
981_GL_CXXALIASWARN (strchrnul);
982# endif
983#elif defined GNULIB_POSIXCHECK
984# undef strchrnul
985# if HAVE_RAW_DECL_STRCHRNUL
986_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
987                 "use gnulib module strchrnul for portability");
988# endif
989#endif
990
991/* Duplicate S, returning an identical malloc'd string.  */
992#if 1
993# if 0
994#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
995#   undef strdup
996#   define strdup rpl_strdup
997#  endif
998_GL_FUNCDECL_RPL (strdup, char *,
999                  (char const *__s)
1000                  _GL_ARG_NONNULL ((1))
1001                  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1002_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
1003# elif defined _WIN32 && !defined __CYGWIN__
1004#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1005#   undef strdup
1006#   define strdup _strdup
1007#  endif
1008_GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
1009# else
1010#  if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
1011    /* strdup exists as a function and as a macro.  Get rid of the macro.  */
1012#   undef strdup
1013#  endif
1014#  if (!1 || __GNUC__ >= 11) && !defined strdup
1015_GL_FUNCDECL_SYS (strdup, char *,
1016                  (char const *__s)
1017                  _GL_ARG_NONNULL ((1))
1018                  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1019#  endif
1020_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
1021# endif
1022_GL_CXXALIASWARN (strdup);
1023#else
1024# if __GNUC__ >= 11 && !defined strdup
1025/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free.  */
1026_GL_FUNCDECL_SYS (strdup, char *,
1027                  (char const *__s)
1028                  _GL_ARG_NONNULL ((1))
1029                  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1030# endif
1031# if defined GNULIB_POSIXCHECK
1032#  undef strdup
1033#  if HAVE_RAW_DECL_STRDUP
1034_GL_WARN_ON_USE (strdup, "strdup is unportable - "
1035                 "use gnulib module strdup for portability");
1036#  endif
1037# elif 1
1038/* On native Windows, map 'creat' to '_creat', so that -loldnames is not
1039   required.  In C++ with GNULIB_NAMESPACE, avoid differences between
1040   platforms by defining GNULIB_NAMESPACE::strdup always.  */
1041#  if defined _WIN32 && !defined __CYGWIN__
1042#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1043#    undef strdup
1044#    define strdup _strdup
1045#   endif
1046_GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
1047#  else
1048#   if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
1049#    undef strdup
1050#   endif
1051_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
1052#  endif
1053_GL_CXXALIASWARN (strdup);
1054# endif
1055#endif
1056
1057/* Append no more than N characters from SRC onto DEST.  */
1058#if 0
1059# if 0
1060#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1061#   undef strncat
1062#   define strncat rpl_strncat
1063#  endif
1064_GL_FUNCDECL_RPL (strncat, char *,
1065                  (char *restrict dest, const char *restrict src, size_t n)
1066                  _GL_ARG_NONNULL ((1, 2)));
1067_GL_CXXALIAS_RPL (strncat, char *,
1068                  (char *restrict dest, const char *restrict src, size_t n));
1069# else
1070_GL_CXXALIAS_SYS (strncat, char *,
1071                  (char *restrict dest, const char *restrict src, size_t n));
1072# endif
1073# if __GLIBC__ >= 2
1074_GL_CXXALIASWARN (strncat);
1075# endif
1076#elif defined GNULIB_POSIXCHECK
1077# undef strncat
1078# if HAVE_RAW_DECL_STRNCAT
1079_GL_WARN_ON_USE (strncat, "strncat is unportable - "
1080                 "use gnulib module strncat for portability");
1081# endif
1082#endif
1083
1084/* Return a newly allocated copy of at most N bytes of STRING.  */
1085#if 0
1086# if 0
1087#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1088#   undef strndup
1089#   define strndup rpl_strndup
1090#  endif
1091_GL_FUNCDECL_RPL (strndup, char *,
1092                  (char const *__s, size_t __n)
1093                  _GL_ARG_NONNULL ((1))
1094                  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1095_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
1096# else
1097#  if !1 || (__GNUC__ >= 11 && !defined strndup)
1098_GL_FUNCDECL_SYS (strndup, char *,
1099                  (char const *__s, size_t __n)
1100                  _GL_ARG_NONNULL ((1))
1101                  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1102#  endif
1103_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
1104# endif
1105_GL_CXXALIASWARN (strndup);
1106#else
1107# if __GNUC__ >= 11 && !defined strndup
1108/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free.  */
1109_GL_FUNCDECL_SYS (strndup, char *,
1110                  (char const *__s, size_t __n)
1111                  _GL_ARG_NONNULL ((1))
1112                  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1113# endif
1114# if defined GNULIB_POSIXCHECK
1115#  undef strndup
1116#  if HAVE_RAW_DECL_STRNDUP
1117_GL_WARN_ON_USE (strndup, "strndup is unportable - "
1118                 "use gnulib module strndup for portability");
1119#  endif
1120# endif
1121#endif
1122
1123/* Find the length (number of bytes) of STRING, but scan at most
1124   MAXLEN bytes.  If no '\0' terminator is found in that many bytes,
1125   return MAXLEN.  */
1126#if 1
1127# if 0
1128#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1129#   undef strnlen
1130#   define strnlen rpl_strnlen
1131#  endif
1132_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)
1133                                   _GL_ATTRIBUTE_PURE
1134                                   _GL_ARG_NONNULL ((1)));
1135_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
1136# else
1137#  if ! 1
1138_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)
1139                                   _GL_ATTRIBUTE_PURE
1140                                   _GL_ARG_NONNULL ((1)));
1141#  endif
1142_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
1143# endif
1144_GL_CXXALIASWARN (strnlen);
1145#elif defined GNULIB_POSIXCHECK
1146# undef strnlen
1147# if HAVE_RAW_DECL_STRNLEN
1148_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
1149                 "use gnulib module strnlen for portability");
1150# endif
1151#endif
1152
1153#if defined GNULIB_POSIXCHECK
1154/* strcspn() assumes the second argument is a list of single-byte characters.
1155   Even in this simple case, it does not work with multibyte strings if the
1156   locale encoding is GB18030 and one of the characters to be searched is a
1157   digit.  */
1158# undef strcspn
1159/* Assume strcspn is always declared.  */
1160_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
1161                 "in multibyte locales - "
1162                 "use mbscspn if you care about internationalization");
1163#endif
1164
1165/* Find the first occurrence in S of any character in ACCEPT.  */
1166#if 0
1167# if ! 1
1168_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
1169                                   _GL_ATTRIBUTE_PURE
1170                                   _GL_ARG_NONNULL ((1, 2)));
1171# endif
1172  /* On some systems, this function is defined as an overloaded function:
1173       extern "C" { const char * strpbrk (const char *, const char *); }
1174       extern "C++" { char * strpbrk (char *, const char *); }  */
1175_GL_CXXALIAS_SYS_CAST2 (strpbrk,
1176                        char *, (char const *__s, char const *__accept),
1177                        const char *, (char const *__s, char const *__accept));
1178# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1179     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
1180         || defined __clang__)
1181_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept) throw ());
1182_GL_CXXALIASWARN1 (strpbrk, char const *,
1183                   (char const *__s, char const *__accept) throw ());
1184# elif __GLIBC__ >= 2
1185_GL_CXXALIASWARN (strpbrk);
1186# endif
1187# if defined GNULIB_POSIXCHECK
1188/* strpbrk() assumes the second argument is a list of single-byte characters.
1189   Even in this simple case, it does not work with multibyte strings if the
1190   locale encoding is GB18030 and one of the characters to be searched is a
1191   digit.  */
1192#  undef strpbrk
1193_GL_WARN_ON_USE_CXX (strpbrk,
1194                     const char *, char *, (const char *, const char *),
1195                     "strpbrk cannot work correctly on character strings "
1196                     "in multibyte locales - "
1197                     "use mbspbrk if you care about internationalization");
1198# endif
1199#elif defined GNULIB_POSIXCHECK
1200# undef strpbrk
1201# if HAVE_RAW_DECL_STRPBRK
1202_GL_WARN_ON_USE_CXX (strpbrk,
1203                     const char *, char *, (const char *, const char *),
1204                     "strpbrk is unportable - "
1205                     "use gnulib module strpbrk for portability");
1206# endif
1207#endif
1208
1209#if defined GNULIB_POSIXCHECK
1210/* strspn() assumes the second argument is a list of single-byte characters.
1211   Even in this simple case, it cannot work with multibyte strings.  */
1212# undef strspn
1213/* Assume strspn is always declared.  */
1214_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
1215                 "in multibyte locales - "
1216                 "use mbsspn if you care about internationalization");
1217#endif
1218
1219#if defined GNULIB_POSIXCHECK
1220/* strrchr() does not work with multibyte strings if the locale encoding is
1221   GB18030 and the character to be searched is a digit.  */
1222# undef strrchr
1223/* Assume strrchr is always declared.  */
1224_GL_WARN_ON_USE_CXX (strrchr,
1225                     const char *, char *, (const char *, int),
1226                     "strrchr cannot work correctly on character strings "
1227                     "in some multibyte locales - "
1228                     "use mbsrchr if you care about internationalization");
1229#endif
1230
1231/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
1232   If one is found, overwrite it with a NUL, and advance *STRINGP
1233   to point to the next char after it.  Otherwise, set *STRINGP to NULL.
1234   If *STRINGP was already NULL, nothing happens.
1235   Return the old value of *STRINGP.
1236
1237   This is a variant of strtok() that is multithread-safe and supports
1238   empty fields.
1239
1240   Caveat: It modifies the original string.
1241   Caveat: These functions cannot be used on constant strings.
1242   Caveat: The identity of the delimiting character is lost.
1243   Caveat: It doesn't work with multibyte strings unless all of the delimiter
1244           characters are ASCII characters < 0x30.
1245
1246   See also strtok_r().  */
1247#if 0
1248# if ! 1
1249_GL_FUNCDECL_SYS (strsep, char *,
1250                  (char **restrict __stringp, char const *restrict __delim)
1251                  _GL_ARG_NONNULL ((1, 2)));
1252# endif
1253_GL_CXXALIAS_SYS (strsep, char *,
1254                  (char **restrict __stringp, char const *restrict __delim));
1255_GL_CXXALIASWARN (strsep);
1256# if defined GNULIB_POSIXCHECK
1257#  undef strsep
1258_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
1259                 "in multibyte locales - "
1260                 "use mbssep if you care about internationalization");
1261# endif
1262#elif defined GNULIB_POSIXCHECK
1263# undef strsep
1264# if HAVE_RAW_DECL_STRSEP
1265_GL_WARN_ON_USE (strsep, "strsep is unportable - "
1266                 "use gnulib module strsep for portability");
1267# endif
1268#endif
1269
1270#if 1
1271# if 1
1272#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1273#   define strstr rpl_strstr
1274#  endif
1275_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
1276                                  _GL_ATTRIBUTE_PURE
1277                                  _GL_ARG_NONNULL ((1, 2)));
1278_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
1279# else
1280  /* On some systems, this function is defined as an overloaded function:
1281       extern "C++" { const char * strstr (const char *, const char *); }
1282       extern "C++" { char * strstr (char *, const char *); }  */
1283_GL_CXXALIAS_SYS_CAST2 (strstr,
1284                        char *, (const char *haystack, const char *needle),
1285                        const char *, (const char *haystack, const char *needle));
1286# endif
1287# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1288     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
1289         || defined __clang__)
1290_GL_CXXALIASWARN1 (strstr, char *,
1291                   (char *haystack, const char *needle) throw ());
1292_GL_CXXALIASWARN1 (strstr, const char *,
1293                   (const char *haystack, const char *needle) throw ());
1294# elif __GLIBC__ >= 2
1295_GL_CXXALIASWARN (strstr);
1296# endif
1297#elif defined GNULIB_POSIXCHECK
1298/* strstr() does not work with multibyte strings if the locale encoding is
1299   different from UTF-8:
1300   POSIX says that it operates on "strings", and "string" in POSIX is defined
1301   as a sequence of bytes, not of characters.  */
1302# undef strstr
1303/* Assume strstr is always declared.  */
1304_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
1305                 "work correctly on character strings in most "
1306                 "multibyte locales - "
1307                 "use mbsstr if you care about internationalization, "
1308                 "or use strstr if you care about speed");
1309#endif
1310
1311/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
1312   comparison.  */
1313#if 0
1314# if 0
1315#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1316#   define strcasestr rpl_strcasestr
1317#  endif
1318_GL_FUNCDECL_RPL (strcasestr, char *,
1319                  (const char *haystack, const char *needle)
1320                  _GL_ATTRIBUTE_PURE
1321                  _GL_ARG_NONNULL ((1, 2)));
1322_GL_CXXALIAS_RPL (strcasestr, char *,
1323                  (const char *haystack, const char *needle));
1324# else
1325#  if ! 1
1326_GL_FUNCDECL_SYS (strcasestr, char *,
1327                  (const char *haystack, const char *needle)
1328                  _GL_ATTRIBUTE_PURE
1329                  _GL_ARG_NONNULL ((1, 2)));
1330#  endif
1331  /* On some systems, this function is defined as an overloaded function:
1332       extern "C++" { const char * strcasestr (const char *, const char *); }
1333       extern "C++" { char * strcasestr (char *, const char *); }  */
1334_GL_CXXALIAS_SYS_CAST2 (strcasestr,
1335                        char *, (const char *haystack, const char *needle),
1336                        const char *, (const char *haystack, const char *needle));
1337# endif
1338# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1339     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
1340         || defined __clang__)
1341_GL_CXXALIASWARN1 (strcasestr, char *,
1342                   (char *haystack, const char *needle) throw ());
1343_GL_CXXALIASWARN1 (strcasestr, const char *,
1344                   (const char *haystack, const char *needle) throw ());
1345# else
1346_GL_CXXALIASWARN (strcasestr);
1347# endif
1348#elif defined GNULIB_POSIXCHECK
1349/* strcasestr() does not work with multibyte strings:
1350   It is a glibc extension, and glibc implements it only for unibyte
1351   locales.  */
1352# undef strcasestr
1353# if HAVE_RAW_DECL_STRCASESTR
1354_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
1355                 "strings in multibyte locales - "
1356                 "use mbscasestr if you care about "
1357                 "internationalization, or use c-strcasestr if you want "
1358                 "a locale independent function");
1359# endif
1360#endif
1361
1362/* Parse S into tokens separated by characters in DELIM.
1363   If S is NULL, the saved pointer in SAVE_PTR is used as
1364   the next starting point.  For example:
1365        char s[] = "-abc-=-def";
1366        char *sp;
1367        x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
1368        x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
1369        x = strtok_r(NULL, "=", &sp);   // x = NULL
1370                // s = "abc\0-def\0"
1371
1372   This is a variant of strtok() that is multithread-safe.
1373
1374   For the POSIX documentation for this function, see:
1375   https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html
1376
1377   Caveat: It modifies the original string.
1378   Caveat: These functions cannot be used on constant strings.
1379   Caveat: The identity of the delimiting character is lost.
1380   Caveat: It doesn't work with multibyte strings unless all of the delimiter
1381           characters are ASCII characters < 0x30.
1382
1383   See also strsep().  */
1384#if 1
1385# if 0
1386#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1387#   undef strtok_r
1388#   define strtok_r rpl_strtok_r
1389#  endif
1390_GL_FUNCDECL_RPL (strtok_r, char *,
1391                  (char *restrict s, char const *restrict delim,
1392                   char **restrict save_ptr)
1393                  _GL_ARG_NONNULL ((2, 3)));
1394_GL_CXXALIAS_RPL (strtok_r, char *,
1395                  (char *restrict s, char const *restrict delim,
1396                   char **restrict save_ptr));
1397# else
1398#  if 0 || defined GNULIB_POSIXCHECK
1399#   undef strtok_r
1400#  endif
1401#  if ! 1
1402_GL_FUNCDECL_SYS (strtok_r, char *,
1403                  (char *restrict s, char const *restrict delim,
1404                   char **restrict save_ptr)
1405                  _GL_ARG_NONNULL ((2, 3)));
1406#  endif
1407_GL_CXXALIAS_SYS (strtok_r, char *,
1408                  (char *restrict s, char const *restrict delim,
1409                   char **restrict save_ptr));
1410# endif
1411_GL_CXXALIASWARN (strtok_r);
1412# if defined GNULIB_POSIXCHECK
1413_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
1414                 "strings in multibyte locales - "
1415                 "use mbstok_r if you care about internationalization");
1416# endif
1417#elif defined GNULIB_POSIXCHECK
1418# undef strtok_r
1419# if HAVE_RAW_DECL_STRTOK_R
1420_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
1421                 "use gnulib module strtok_r for portability");
1422# endif
1423#endif
1424
1425
1426/* The following functions are not specified by POSIX.  They are gnulib
1427   extensions.  */
1428
1429#if 0
1430/* Return the number of multibyte characters in the character string STRING.
1431   This considers multibyte characters, unlike strlen, which counts bytes.  */
1432# ifdef __MirBSD__  /* MirBSD defines mbslen as a macro.  Override it.  */
1433#  undef mbslen
1434# endif
1435# if 0  /* AIX, OSF/1, MirBSD define mbslen already in libc.  */
1436#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1437#   define mbslen rpl_mbslen
1438#  endif
1439_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string)
1440                                  _GL_ATTRIBUTE_PURE
1441                                  _GL_ARG_NONNULL ((1)));
1442_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
1443# else
1444_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
1445                                  _GL_ATTRIBUTE_PURE
1446                                  _GL_ARG_NONNULL ((1)));
1447_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
1448# endif
1449_GL_CXXALIASWARN (mbslen);
1450#endif
1451
1452#if 0
1453/* Return the number of multibyte characters in the character string starting
1454   at STRING and ending at STRING + LEN.  */
1455_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
1456     _GL_ATTRIBUTE_PURE
1457     _GL_ARG_NONNULL ((1));
1458#endif
1459
1460#if 0
1461/* Locate the first single-byte character C in the character string STRING,
1462   and return a pointer to it.  Return NULL if C is not found in STRING.
1463   Unlike strchr(), this function works correctly in multibyte locales with
1464   encodings such as GB18030.  */
1465# if defined __hpux
1466#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1467#   define mbschr rpl_mbschr /* avoid collision with HP-UX function */
1468#  endif
1469_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
1470                                  _GL_ATTRIBUTE_PURE
1471                                  _GL_ARG_NONNULL ((1)));
1472_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
1473# else
1474_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
1475                                  _GL_ATTRIBUTE_PURE
1476                                  _GL_ARG_NONNULL ((1)));
1477_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
1478# endif
1479_GL_CXXALIASWARN (mbschr);
1480#endif
1481
1482#if 0
1483/* Locate the last single-byte character C in the character string STRING,
1484   and return a pointer to it.  Return NULL if C is not found in STRING.
1485   Unlike strrchr(), this function works correctly in multibyte locales with
1486   encodings such as GB18030.  */
1487# if defined __hpux || defined __INTERIX
1488#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1489#   define mbsrchr rpl_mbsrchr /* avoid collision with system function */
1490#  endif
1491_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
1492                                   _GL_ATTRIBUTE_PURE
1493                                   _GL_ARG_NONNULL ((1)));
1494_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
1495# else
1496_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
1497                                   _GL_ATTRIBUTE_PURE
1498                                   _GL_ARG_NONNULL ((1)));
1499_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
1500# endif
1501_GL_CXXALIASWARN (mbsrchr);
1502#endif
1503
1504#if 0
1505/* Find the first occurrence of the character string NEEDLE in the character
1506   string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
1507   Unlike strstr(), this function works correctly in multibyte locales with
1508   encodings different from UTF-8.  */
1509_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
1510     _GL_ATTRIBUTE_PURE
1511     _GL_ARG_NONNULL ((1, 2));
1512#endif
1513
1514#if 0
1515/* Compare the character strings S1 and S2, ignoring case, returning less than,
1516   equal to or greater than zero if S1 is lexicographically less than, equal to
1517   or greater than S2.
1518   Note: This function may, in multibyte locales, return 0 for strings of
1519   different lengths!
1520   Unlike strcasecmp(), this function works correctly in multibyte locales.  */
1521_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
1522     _GL_ATTRIBUTE_PURE
1523     _GL_ARG_NONNULL ((1, 2));
1524#endif
1525
1526#if 0
1527/* Compare the initial segment of the character string S1 consisting of at most
1528   N characters with the initial segment of the character string S2 consisting
1529   of at most N characters, ignoring case, returning less than, equal to or
1530   greater than zero if the initial segment of S1 is lexicographically less
1531   than, equal to or greater than the initial segment of S2.
1532   Note: This function may, in multibyte locales, return 0 for initial segments
1533   of different lengths!
1534   Unlike strncasecmp(), this function works correctly in multibyte locales.
1535   But beware that N is not a byte count but a character count!  */
1536_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
1537     _GL_ATTRIBUTE_PURE
1538     _GL_ARG_NONNULL ((1, 2));
1539#endif
1540
1541#if 0
1542/* Compare the initial segment of the character string STRING consisting of
1543   at most mbslen (PREFIX) characters with the character string PREFIX,
1544   ignoring case.  If the two match, return a pointer to the first byte
1545   after this prefix in STRING.  Otherwise, return NULL.
1546   Note: This function may, in multibyte locales, return non-NULL if STRING
1547   is of smaller length than PREFIX!
1548   Unlike strncasecmp(), this function works correctly in multibyte
1549   locales.  */
1550_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1551     _GL_ATTRIBUTE_PURE
1552     _GL_ARG_NONNULL ((1, 2));
1553#endif
1554
1555#if 0
1556/* Find the first occurrence of the character string NEEDLE in the character
1557   string HAYSTACK, using case-insensitive comparison.
1558   Note: This function may, in multibyte locales, return success even if
1559   strlen (haystack) < strlen (needle) !
1560   Unlike strcasestr(), this function works correctly in multibyte locales.  */
1561_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
1562     _GL_ATTRIBUTE_PURE
1563     _GL_ARG_NONNULL ((1, 2));
1564#endif
1565
1566#if 0
1567/* Find the first occurrence in the character string STRING of any character
1568   in the character string ACCEPT.  Return the number of bytes from the
1569   beginning of the string to this occurrence, or to the end of the string
1570   if none exists.
1571   Unlike strcspn(), this function works correctly in multibyte locales.  */
1572_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
1573     _GL_ATTRIBUTE_PURE
1574     _GL_ARG_NONNULL ((1, 2));
1575#endif
1576
1577#if 0
1578/* Find the first occurrence in the character string STRING of any character
1579   in the character string ACCEPT.  Return the pointer to it, or NULL if none
1580   exists.
1581   Unlike strpbrk(), this function works correctly in multibyte locales.  */
1582# if defined __hpux
1583#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1584#   define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
1585#  endif
1586_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
1587                                   _GL_ATTRIBUTE_PURE
1588                                   _GL_ARG_NONNULL ((1, 2)));
1589_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
1590# else
1591_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
1592                                   _GL_ATTRIBUTE_PURE
1593                                   _GL_ARG_NONNULL ((1, 2)));
1594_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
1595# endif
1596_GL_CXXALIASWARN (mbspbrk);
1597#endif
1598
1599#if 0
1600/* Find the first occurrence in the character string STRING of any character
1601   not in the character string REJECT.  Return the number of bytes from the
1602   beginning of the string to this occurrence, or to the end of the string
1603   if none exists.
1604   Unlike strspn(), this function works correctly in multibyte locales.  */
1605_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
1606     _GL_ATTRIBUTE_PURE
1607     _GL_ARG_NONNULL ((1, 2));
1608#endif
1609
1610#if 0
1611/* Search the next delimiter (multibyte character listed in the character
1612   string DELIM) starting at the character string *STRINGP.
1613   If one is found, overwrite it with a NUL, and advance *STRINGP to point
1614   to the next multibyte character after it.  Otherwise, set *STRINGP to NULL.
1615   If *STRINGP was already NULL, nothing happens.
1616   Return the old value of *STRINGP.
1617
1618   This is a variant of mbstok_r() that supports empty fields.
1619
1620   Caveat: It modifies the original string.
1621   Caveat: These functions cannot be used on constant strings.
1622   Caveat: The identity of the delimiting character is lost.
1623
1624   See also mbstok_r().  */
1625_GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
1626     _GL_ARG_NONNULL ((1, 2));
1627#endif
1628
1629#if 0
1630/* Parse the character string STRING into tokens separated by characters in
1631   the character string DELIM.
1632   If STRING is NULL, the saved pointer in SAVE_PTR is used as
1633   the next starting point.  For example:
1634        char s[] = "-abc-=-def";
1635        char *sp;
1636        x = mbstok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
1637        x = mbstok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
1638        x = mbstok_r(NULL, "=", &sp);   // x = NULL
1639                // s = "abc\0-def\0"
1640
1641   Caveat: It modifies the original string.
1642   Caveat: These functions cannot be used on constant strings.
1643   Caveat: The identity of the delimiting character is lost.
1644
1645   See also mbssep().  */
1646_GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
1647                              char **save_ptr)
1648     _GL_ARG_NONNULL ((2, 3));
1649#endif
1650
1651/* Map any int, typically from errno, into an error message.  */
1652#if 1
1653# if 1
1654#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1655#   undef strerror
1656#   define strerror rpl_strerror
1657#  endif
1658_GL_FUNCDECL_RPL (strerror, char *, (int));
1659_GL_CXXALIAS_RPL (strerror, char *, (int));
1660# else
1661_GL_CXXALIAS_SYS (strerror, char *, (int));
1662# endif
1663# if __GLIBC__ >= 2
1664_GL_CXXALIASWARN (strerror);
1665# endif
1666#elif defined GNULIB_POSIXCHECK
1667# undef strerror
1668/* Assume strerror is always declared.  */
1669_GL_WARN_ON_USE (strerror, "strerror is unportable - "
1670                 "use gnulib module strerror to guarantee non-NULL result");
1671#endif
1672
1673/* Map any int, typically from errno, into an error message.  Multithread-safe.
1674   Uses the POSIX declaration, not the glibc declaration.  */
1675#if 1
1676# if 1
1677#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1678#   undef strerror_r
1679#   define strerror_r rpl_strerror_r
1680#  endif
1681_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
1682                                   _GL_ARG_NONNULL ((2)));
1683_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
1684# else
1685#  if !1
1686_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
1687                                   _GL_ARG_NONNULL ((2)));
1688#  endif
1689_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
1690# endif
1691# if 1
1692_GL_CXXALIASWARN (strerror_r);
1693# endif
1694#elif defined GNULIB_POSIXCHECK
1695# undef strerror_r
1696# if HAVE_RAW_DECL_STRERROR_R
1697_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1698                 "use gnulib module strerror_r-posix for portability");
1699# endif
1700#endif
1701
1702/* Return the name of the system error code ERRNUM.  */
1703#if 0
1704# if 0
1705#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1706#   undef strerrorname_np
1707#   define strerrorname_np rpl_strerrorname_np
1708#  endif
1709_GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum));
1710_GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum));
1711# else
1712#  if !1
1713_GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum));
1714#  endif
1715_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum));
1716# endif
1717_GL_CXXALIASWARN (strerrorname_np);
1718#elif defined GNULIB_POSIXCHECK
1719# undef strerrorname_np
1720# if HAVE_RAW_DECL_STRERRORNAME_NP
1721_GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - "
1722                 "use gnulib module strerrorname_np for portability");
1723# endif
1724#endif
1725
1726/* Return an abbreviation string for the signal number SIG.  */
1727#if 0
1728# if ! 1
1729_GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig));
1730# endif
1731_GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig));
1732_GL_CXXALIASWARN (sigabbrev_np);
1733#elif defined GNULIB_POSIXCHECK
1734# undef sigabbrev_np
1735# if HAVE_RAW_DECL_SIGABBREV_NP
1736_GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - "
1737                 "use gnulib module sigabbrev_np for portability");
1738# endif
1739#endif
1740
1741/* Return an English description string for the signal number SIG.  */
1742#if 0
1743# if ! 1
1744_GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig));
1745# endif
1746_GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig));
1747_GL_CXXALIASWARN (sigdescr_np);
1748#elif defined GNULIB_POSIXCHECK
1749# undef sigdescr_np
1750# if HAVE_RAW_DECL_SIGDESCR_NP
1751_GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - "
1752                 "use gnulib module sigdescr_np for portability");
1753# endif
1754#endif
1755
1756#if 0
1757# if 0
1758#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1759#   define strsignal rpl_strsignal
1760#  endif
1761_GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
1762_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
1763# else
1764#  if ! 1
1765_GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
1766#  endif
1767/* Need to cast, because on Cygwin 1.5.x systems, the return type is
1768   'const char *'.  */
1769_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
1770# endif
1771_GL_CXXALIASWARN (strsignal);
1772#elif defined GNULIB_POSIXCHECK
1773# undef strsignal
1774# if HAVE_RAW_DECL_STRSIGNAL
1775_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
1776                 "use gnulib module strsignal for portability");
1777# endif
1778#endif
1779
1780#if 0
1781# if !1
1782_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
1783                                   _GL_ATTRIBUTE_PURE
1784                                   _GL_ARG_NONNULL ((1, 2)));
1785# endif
1786_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
1787_GL_CXXALIASWARN (strverscmp);
1788#elif defined GNULIB_POSIXCHECK
1789# undef strverscmp
1790# if HAVE_RAW_DECL_STRVERSCMP
1791_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1792                 "use gnulib module strverscmp for portability");
1793# endif
1794#endif
1795
1796
1797#endif /* _GL_STRING_H */
1798#endif /* _GL_STRING_H */
1799#endif
1800