1145132Sanholt/* This file is automatically generated.  DO NOT EDIT! */
2145132Sanholt/* Generated from: NetBSD: mknative-gdb,v 1.15 2020/12/05 21:27:31 christos Exp  */
3145132Sanholt/* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
4145132Sanholt
5145132Sanholt/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
6145132Sanholt/* A substitute for ISO C99 <ctype.h>, for platforms on which it is incomplete.
7145132Sanholt
8145132Sanholt   Copyright (C) 2009-2020 Free Software Foundation, Inc.
9145132Sanholt
10145132Sanholt   This program is free software; you can redistribute it and/or modify
11145132Sanholt   it under the terms of the GNU General Public License as published by
12145132Sanholt   the Free Software Foundation; either version 3, or (at your option)
13145132Sanholt   any later version.
14145132Sanholt
15145132Sanholt   This program is distributed in the hope that it will be useful,
16145132Sanholt   but WITHOUT ANY WARRANTY; without even the implied warranty of
17145132Sanholt   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18145132Sanholt   GNU General Public License for more details.
19145132Sanholt
20145132Sanholt   You should have received a copy of the GNU General Public License
21145132Sanholt   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
22145132Sanholt
23145132Sanholt/* Written by Bruno Haible.  */
24145132Sanholt
25145132Sanholt/*
26145132Sanholt * ISO C 99 <ctype.h> for platforms on which it is incomplete.
27145132Sanholt * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ctype.h.html>
28145132Sanholt */
29145132Sanholt
30145132Sanholt#ifndef _GL_CTYPE_H
31152909Sanholt
32152909Sanholt#if __GNUC__ >= 3
33152909Sanholt#pragma GCC system_header
34182080Srnoland#endif
35182080Srnoland
36182080Srnoland
37182080Srnoland/* Include the original <ctype.h>.  */
38152909Sanholt/* The include_next requires a split double-inclusion guard.  */
39152909Sanholt#include_next <ctype.h>
40145132Sanholt
41145132Sanholt#ifndef _GL_CTYPE_H
42145132Sanholt#define _GL_CTYPE_H
43145132Sanholt
44145132Sanholt/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
45145132Sanholt/* C++ compatible function declaration macros.
46145132Sanholt   Copyright (C) 2010-2020 Free Software Foundation, Inc.
47145132Sanholt
48145132Sanholt   This program is free software: you can redistribute it and/or modify it
49145132Sanholt   under the terms of the GNU General Public License as published
50145132Sanholt   by the Free Software Foundation; either version 3 of the License, or
51145132Sanholt   (at your option) any later version.
52145132Sanholt
53145132Sanholt   This program is distributed in the hope that it will be useful,
54145132Sanholt   but WITHOUT ANY WARRANTY; without even the implied warranty of
55145132Sanholt   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
56145132Sanholt   General Public License for more details.
57145132Sanholt
58152909Sanholt   You should have received a copy of the GNU General Public License
59152909Sanholt   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
60152909Sanholt
61152909Sanholt#ifndef _GL_CXXDEFS_H
62182080Srnoland#define _GL_CXXDEFS_H
63145132Sanholt
64152909Sanholt/* Begin/end the GNULIB_NAMESPACE namespace.  */
65152909Sanholt#if defined __cplusplus && defined GNULIB_NAMESPACE
66152909Sanholt# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
67152909Sanholt# define _GL_END_NAMESPACE }
68145132Sanholt#else
69152909Sanholt# define _GL_BEGIN_NAMESPACE
70152909Sanholt# define _GL_END_NAMESPACE
71152909Sanholt#endif
72145132Sanholt
73145132Sanholt/* The three most frequent use cases of these macros are:
74145132Sanholt
75152909Sanholt   * For providing a substitute for a function that is missing on some
76152909Sanholt     platforms, but is declared and works fine on the platforms on which
77152909Sanholt     it exists:
78152909Sanholt
79145132Sanholt       #if @GNULIB_FOO@
80152909Sanholt       # if !@HAVE_FOO@
81152909Sanholt       _GL_FUNCDECL_SYS (foo, ...);
82152909Sanholt       # endif
83152909Sanholt       _GL_CXXALIAS_SYS (foo, ...);
84145132Sanholt       _GL_CXXALIASWARN (foo);
85152909Sanholt       #elif defined GNULIB_POSIXCHECK
86145132Sanholt       ...
87145132Sanholt       #endif
88182080Srnoland
89182080Srnoland   * For providing a replacement for a function that exists on all platforms,
90145132Sanholt     but is broken/insufficient and needs to be replaced on some platforms:
91152909Sanholt
92152909Sanholt       #if @GNULIB_FOO@
93145132Sanholt       # if @REPLACE_FOO@
94152909Sanholt       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
95145132Sanholt       #   undef foo
96145132Sanholt       #   define foo rpl_foo
97182080Srnoland       #  endif
98182080Srnoland       _GL_FUNCDECL_RPL (foo, ...);
99145132Sanholt       _GL_CXXALIAS_RPL (foo, ...);
100152909Sanholt       # else
101152909Sanholt       _GL_CXXALIAS_SYS (foo, ...);
102145132Sanholt       # endif
103152909Sanholt       _GL_CXXALIASWARN (foo);
104145132Sanholt       #elif defined GNULIB_POSIXCHECK
105145132Sanholt       ...
106182080Srnoland       #endif
107182080Srnoland
108152909Sanholt   * For providing a replacement for a function that exists on some platforms
109145132Sanholt     but is broken/insufficient and needs to be replaced on some of them and
110145132Sanholt     is additionally either missing or undeclared on some other platforms:
111152909Sanholt
112152909Sanholt       #if @GNULIB_FOO@
113152909Sanholt       # if @REPLACE_FOO@
114145132Sanholt       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
115145132Sanholt       #   undef foo
116145132Sanholt       #   define foo rpl_foo
117145132Sanholt       #  endif
118145132Sanholt       _GL_FUNCDECL_RPL (foo, ...);
119152909Sanholt       _GL_CXXALIAS_RPL (foo, ...);
120152909Sanholt       # else
121145132Sanholt       #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
122152909Sanholt       _GL_FUNCDECL_SYS (foo, ...);
123152909Sanholt       #  endif
124152909Sanholt       _GL_CXXALIAS_SYS (foo, ...);
125152909Sanholt       # endif
126145132Sanholt       _GL_CXXALIASWARN (foo);
127152909Sanholt       #elif defined GNULIB_POSIXCHECK
128152909Sanholt       ...
129152909Sanholt       #endif
130152909Sanholt*/
131145132Sanholt
132152909Sanholt/* _GL_EXTERN_C declaration;
133145132Sanholt   performs the declaration with C linkage.  */
134152909Sanholt#if defined __cplusplus
135152909Sanholt# define _GL_EXTERN_C extern "C"
136145132Sanholt#else
137145132Sanholt# define _GL_EXTERN_C extern
138145132Sanholt#endif
139145132Sanholt
140152909Sanholt/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
141152909Sanholt   declares a replacement function, named rpl_func, with the given prototype,
142145132Sanholt   consisting of return type, parameters, and attributes.
143152909Sanholt   Example:
144152909Sanholt     _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
145152909Sanholt                                  _GL_ARG_NONNULL ((1)));
146152909Sanholt */
147152909Sanholt#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
148145132Sanholt  _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
149145132Sanholt#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
150145132Sanholt  _GL_EXTERN_C rettype rpl_func parameters_and_attributes
151145132Sanholt
152152909Sanholt/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
153145132Sanholt   declares the system function, named func, with the given prototype,
154145132Sanholt   consisting of return type, parameters, and attributes.
155145132Sanholt   Example:
156145132Sanholt     _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
157145132Sanholt                                  _GL_ARG_NONNULL ((1)));
158182080Srnoland */
159182080Srnoland#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
160182080Srnoland  _GL_EXTERN_C rettype func parameters_and_attributes
161182080Srnoland
162145132Sanholt/* _GL_CXXALIAS_RPL (func, rettype, parameters);
163152909Sanholt   declares a C++ alias called GNULIB_NAMESPACE::func
164152909Sanholt   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
165152909Sanholt   Example:
166152909Sanholt     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
167145132Sanholt
168145132Sanholt   Wrapping rpl_func in an object with an inline conversion operator
169145132Sanholt   avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
170145478Sanholt   actually used in the program.  */
171145132Sanholt#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
172145132Sanholt  _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
173145132Sanholt#if defined __cplusplus && defined GNULIB_NAMESPACE
174145132Sanholt# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
175145132Sanholt    namespace GNULIB_NAMESPACE                                \
176145132Sanholt    {                                                         \
177145132Sanholt      static const struct _gl_ ## func ## _wrapper            \
178145132Sanholt      {                                                       \
179145132Sanholt        typedef rettype (*type) parameters;                   \
180145132Sanholt                                                              \
181145132Sanholt        inline operator type () const                         \
182145132Sanholt        {                                                     \
183145132Sanholt          return ::rpl_func;                                  \
184182080Srnoland        }                                                     \
185182080Srnoland      } func = {};                                            \
186145132Sanholt    }                                                         \
187145132Sanholt    _GL_EXTERN_C int _gl_cxxalias_dummy
188145132Sanholt#else
189145132Sanholt# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
190145132Sanholt    _GL_EXTERN_C int _gl_cxxalias_dummy
191145132Sanholt#endif
192145132Sanholt
193145132Sanholt/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
194145132Sanholt   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
195182080Srnoland   except that the C function rpl_func may have a slightly different
196145132Sanholt   declaration.  A cast is used to silence the "invalid conversion" error
197145132Sanholt   that would otherwise occur.  */
198145132Sanholt#if defined __cplusplus && defined GNULIB_NAMESPACE
199145132Sanholt# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
200145132Sanholt    namespace GNULIB_NAMESPACE                                     \
201145132Sanholt    {                                                              \
202152909Sanholt      static const struct _gl_ ## func ## _wrapper                 \
203182080Srnoland      {                                                            \
204182080Srnoland        typedef rettype (*type) parameters;                        \
205182080Srnoland                                                                   \
206182080Srnoland        inline operator type () const                              \
207182080Srnoland        {                                                          \
208182080Srnoland          return reinterpret_cast<type>(::rpl_func);               \
209182080Srnoland        }                                                          \
210182080Srnoland      } func = {};                                                 \
211182080Srnoland    }                                                              \
212182080Srnoland    _GL_EXTERN_C int _gl_cxxalias_dummy
213182080Srnoland#else
214145132Sanholt# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
215152909Sanholt    _GL_EXTERN_C int _gl_cxxalias_dummy
216152909Sanholt#endif
217152909Sanholt
218152909Sanholt/* _GL_CXXALIAS_SYS (func, rettype, parameters);
219152909Sanholt   declares a C++ alias called GNULIB_NAMESPACE::func
220152909Sanholt   that redirects to the system provided function func, if GNULIB_NAMESPACE
221152909Sanholt   is defined.
222152909Sanholt   Example:
223152909Sanholt     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
224152909Sanholt
225182080Srnoland   Wrapping func in an object with an inline conversion operator
226182080Srnoland   avoids a reference to func unless GNULIB_NAMESPACE::func is
227152909Sanholt   actually used in the program.  */
228145132Sanholt#if defined __cplusplus && defined GNULIB_NAMESPACE
229145132Sanholt# define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
230145132Sanholt    namespace GNULIB_NAMESPACE                                \
231145132Sanholt    {                                                         \
232182080Srnoland      static const struct _gl_ ## func ## _wrapper            \
233182080Srnoland      {                                                       \
234145132Sanholt        typedef rettype (*type) parameters;                   \
235145132Sanholt                                                              \
236145132Sanholt        inline operator type () const                         \
237145132Sanholt        {                                                     \
238152909Sanholt          return ::func;                                      \
239152909Sanholt        }                                                     \
240152909Sanholt      } func = {};                                            \
241152909Sanholt    }                                                         \
242152909Sanholt    _GL_EXTERN_C int _gl_cxxalias_dummy
243152909Sanholt#else
244152909Sanholt# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
245152909Sanholt    _GL_EXTERN_C int _gl_cxxalias_dummy
246152909Sanholt#endif
247152909Sanholt
248152909Sanholt/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
249145132Sanholt   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
250182080Srnoland   except that the C function func may have a slightly different declaration.
251182080Srnoland   A cast is used to silence the "invalid conversion" error that would
252145132Sanholt   otherwise occur.  */
253152909Sanholt#if defined __cplusplus && defined GNULIB_NAMESPACE
254152909Sanholt# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
255145132Sanholt    namespace GNULIB_NAMESPACE                          \
256145132Sanholt    {                                                   \
257152909Sanholt      static const struct _gl_ ## func ## _wrapper      \
258145132Sanholt      {                                                 \
259182080Srnoland        typedef rettype (*type) parameters;             \
260182080Srnoland                                                        \
261145132Sanholt        inline operator type () const                   \
262145132Sanholt        {                                               \
263145132Sanholt          return reinterpret_cast<type>(::func);        \
264145132Sanholt        }                                               \
265145132Sanholt      } func = {};                                      \
266145132Sanholt    }                                                   \
267145132Sanholt    _GL_EXTERN_C int _gl_cxxalias_dummy
268152909Sanholt#else
269152909Sanholt# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
270152909Sanholt    _GL_EXTERN_C int _gl_cxxalias_dummy
271152909Sanholt#endif
272152909Sanholt
273152909Sanholt/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
274152909Sanholt   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
275152909Sanholt   except that the C function is picked among a set of overloaded functions,
276152909Sanholt   namely the one with rettype2 and parameters2.  Two consecutive casts
277182080Srnoland   are used to silence the "cannot find a match" and "invalid conversion"
278182080Srnoland   errors that would otherwise occur.  */
279152909Sanholt#if defined __cplusplus && defined GNULIB_NAMESPACE
280182080Srnoland  /* The outer cast must be a reinterpret_cast.
281152909Sanholt     The inner cast: When the function is defined as a set of overloaded
282152909Sanholt     functions, it works as a static_cast<>, choosing the designated variant.
283152909Sanholt     When the function is defined as a single variant, it works as a
284152909Sanholt     reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
285182080Srnoland# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
286152909Sanholt    namespace GNULIB_NAMESPACE                                                \
287182080Srnoland    {                                                                         \
288182080Srnoland      static const struct _gl_ ## func ## _wrapper                            \
289152909Sanholt      {                                                                       \
290152909Sanholt        typedef rettype (*type) parameters;                                   \
291182080Srnoland                                                                              \
292182080Srnoland        inline operator type () const                                         \
293152909Sanholt        {                                                                     \
294152909Sanholt          return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
295152909Sanholt        }                                                                     \
296152909Sanholt      } func = {};                                                            \
297182080Srnoland    }                                                                         \
298182080Srnoland    _GL_EXTERN_C int _gl_cxxalias_dummy
299182080Srnoland#else
300182080Srnoland# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
301182080Srnoland    _GL_EXTERN_C int _gl_cxxalias_dummy
302182080Srnoland#endif
303145132Sanholt
304182080Srnoland/* _GL_CXXALIASWARN (func);
305182080Srnoland   causes a warning to be emitted when ::func is used but not when
306145132Sanholt   GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
307145132Sanholt   variants.  */
308145132Sanholt#if defined __cplusplus && defined GNULIB_NAMESPACE
309145132Sanholt# define _GL_CXXALIASWARN(func) \
310145132Sanholt   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
311182080Srnoland# define _GL_CXXALIASWARN_1(func,namespace) \
312145132Sanholt   _GL_CXXALIASWARN_2 (func, namespace)
313145132Sanholt/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
314145132Sanholt   we enable the warning only when not optimizing.  */
315145132Sanholt# if !__OPTIMIZE__
316145132Sanholt#  define _GL_CXXALIASWARN_2(func,namespace) \
317145132Sanholt    _GL_WARN_ON_USE (func, \
318145132Sanholt                     "The symbol ::" #func " refers to the system function. " \
319145132Sanholt                     "Use " #namespace "::" #func " instead.")
320145132Sanholt# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
321145132Sanholt#  define _GL_CXXALIASWARN_2(func,namespace) \
322145132Sanholt     extern __typeof__ (func) func
323145132Sanholt# else
324145132Sanholt#  define _GL_CXXALIASWARN_2(func,namespace) \
325145132Sanholt     _GL_EXTERN_C int _gl_cxxalias_dummy
326152909Sanholt# endif
327145132Sanholt#else
328145132Sanholt# define _GL_CXXALIASWARN(func) \
329145132Sanholt    _GL_EXTERN_C int _gl_cxxalias_dummy
330145132Sanholt#endif
331145132Sanholt
332145132Sanholt/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
333145132Sanholt   causes a warning to be emitted when the given overloaded variant of ::func
334145132Sanholt   is used but not when GNULIB_NAMESPACE::func is used.  */
335145132Sanholt#if defined __cplusplus && defined GNULIB_NAMESPACE
336145132Sanholt# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
337145132Sanholt   _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
338152909Sanholt                        GNULIB_NAMESPACE)
339145132Sanholt# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
340182080Srnoland   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
341182080Srnoland/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
342182080Srnoland   we enable the warning only when not optimizing.  */
343145132Sanholt# if !__OPTIMIZE__
344145132Sanholt#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
345145132Sanholt    _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
346145132Sanholt                         "The symbol ::" #func " refers to the system function. " \
347145132Sanholt                         "Use " #namespace "::" #func " instead.")
348145132Sanholt# else
349145132Sanholt#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
350145132Sanholt     _GL_EXTERN_C int _gl_cxxalias_dummy
351145132Sanholt# endif
352145132Sanholt#else
353145132Sanholt# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
354145132Sanholt    _GL_EXTERN_C int _gl_cxxalias_dummy
355145132Sanholt#endif
356145132Sanholt
357182080Srnoland#endif /* _GL_CXXDEFS_H */
358182080Srnoland
359145132Sanholt/* The definition of _GL_WARN_ON_USE is copied here.  */
360145132Sanholt/* A C macro for emitting warnings if a function is used.
361182080Srnoland   Copyright (C) 2010-2020 Free Software Foundation, Inc.
362145132Sanholt
363145132Sanholt   This program is free software: you can redistribute it and/or modify it
364145132Sanholt   under the terms of the GNU General Public License as published
365182080Srnoland   by the Free Software Foundation; either version 3 of the License, or
366145132Sanholt   (at your option) any later version.
367145132Sanholt
368145132Sanholt   This program is distributed in the hope that it will be useful,
369145132Sanholt   but WITHOUT ANY WARRANTY; without even the implied warranty of
370145132Sanholt   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
371145132Sanholt   General Public License for more details.
372145132Sanholt
373182080Srnoland   You should have received a copy of the GNU General Public License
374145132Sanholt   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
375145132Sanholt
376152909Sanholt/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
377145132Sanholt   for FUNCTION which will then trigger a compiler warning containing
378145132Sanholt   the text of "literal string" anywhere that function is called, if
379145132Sanholt   supported by the compiler.  If the compiler does not support this
380145132Sanholt   feature, the macro expands to an unused extern declaration.
381145132Sanholt
382145132Sanholt   _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
383145132Sanholt   attribute used in _GL_WARN_ON_USE.  If the compiler does not support
384182080Srnoland   this feature, it expands to empty.
385182080Srnoland
386145132Sanholt   These macros are useful for marking a function as a potential
387145132Sanholt   portability trap, with the intent that "literal string" include
388145132Sanholt   instructions on the replacement function that should be used
389145132Sanholt   instead.
390145132Sanholt   _GL_WARN_ON_USE is for functions with 'extern' linkage.
391152909Sanholt   _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
392145132Sanholt   linkage.
393145132Sanholt
394145132Sanholt   However, one of the reasons that a function is a portability trap is
395145132Sanholt   if it has the wrong signature.  Declaring FUNCTION with a different
396145132Sanholt   signature in C is a compilation error, so this macro must use the
397145132Sanholt   same type as any existing declaration so that programs that avoid
398145132Sanholt   the problematic FUNCTION do not fail to compile merely because they
399145132Sanholt   included a header that poisoned the function.  But this implies that
400145132Sanholt   _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
401145132Sanholt   have a declaration.  Use of this macro implies that there must not
402145132Sanholt   be any other macro hiding the declaration of FUNCTION; but
403145132Sanholt   undefining FUNCTION first is part of the poisoning process anyway
404145132Sanholt   (although for symbols that are provided only via a macro, the result
405145132Sanholt   is a compilation error rather than a warning containing
406145132Sanholt   "literal string").  Also note that in C++, it is only safe to use if
407145132Sanholt   FUNCTION has no overloads.
408182080Srnoland
409145132Sanholt   For an example, it is possible to poison 'getline' by:
410145132Sanholt   - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
411145132Sanholt     [getline]) in configure.ac, which potentially defines
412152909Sanholt     HAVE_RAW_DECL_GETLINE
413152909Sanholt   - adding this code to a header that wraps the system <stdio.h>:
414145132Sanholt     #undef getline
415145132Sanholt     #if HAVE_RAW_DECL_GETLINE
416145132Sanholt     _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
417145132Sanholt       "not universally present; use the gnulib module getline");
418145132Sanholt     #endif
419145132Sanholt
420145132Sanholt   It is not possible to directly poison global variables.  But it is
421145132Sanholt   possible to write a wrapper accessor function, and poison that
422145132Sanholt   (less common usage, like &environ, will cause a compilation error
423145132Sanholt   rather than issue the nice warning, but the end result of informing
424145132Sanholt   the developer about their portability problem is still achieved):
425145132Sanholt     #if HAVE_RAW_DECL_ENVIRON
426145132Sanholt     static char ***
427145132Sanholt     rpl_environ (void) { return &environ; }
428145132Sanholt     _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
429145132Sanholt     # undef environ
430145132Sanholt     # define environ (*rpl_environ ())
431145132Sanholt     #endif
432145132Sanholt   or better (avoiding contradictory use of 'static' and 'extern'):
433145132Sanholt     #if HAVE_RAW_DECL_ENVIRON
434145132Sanholt     static char ***
435145132Sanholt     _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
436145132Sanholt     rpl_environ (void) { return &environ; }
437145132Sanholt     # undef environ
438145132Sanholt     # define environ (*rpl_environ ())
439145132Sanholt     #endif
440145132Sanholt   */
441145132Sanholt#ifndef _GL_WARN_ON_USE
442145132Sanholt
443145132Sanholt# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
444145132Sanholt/* A compiler attribute is available in gcc versions 4.3.0 and later.  */
445145132Sanholt#  define _GL_WARN_ON_USE(function, message) \
446145132Sanholtextern __typeof__ (function) function __attribute__ ((__warning__ (message)))
447152909Sanholt#  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
448152909Sanholt  __attribute__ ((__warning__ (message)))
449152909Sanholt# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
450152909Sanholt/* Verify the existence of the function.  */
451152909Sanholt#  define _GL_WARN_ON_USE(function, message) \
452152909Sanholtextern __typeof__ (function) function
453152909Sanholt#  define _GL_WARN_ON_USE_ATTRIBUTE(message)
454152909Sanholt# else /* Unsupported.  */
455152909Sanholt#  define _GL_WARN_ON_USE(function, message) \
456152909Sanholt_GL_WARN_EXTERN_C int _gl_warn_on_use
457152909Sanholt#  define _GL_WARN_ON_USE_ATTRIBUTE(message)
458152909Sanholt# endif
459152909Sanholt#endif
460152909Sanholt
461152909Sanholt/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
462152909Sanholt   is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the
463152909Sanholt   function is declared with the given prototype, consisting of return type,
464182080Srnoland   parameters, and attributes.
465152909Sanholt   This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
466152909Sanholt   not work in this case.  */
467145132Sanholt#ifndef _GL_WARN_ON_USE_CXX
468145132Sanholt# if !defined __cplusplus
469145132Sanholt#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
470145132Sanholt     _GL_WARN_ON_USE (function, msg)
471145132Sanholt# else
472182080Srnoland#  if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
473145132Sanholt#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
474145132Sanholtextern rettype function parameters_and_attributes \
475145132Sanholt     __attribute__ ((__warning__ (msg)))
476145132Sanholt#  elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
477145132Sanholt/* Verify the existence of the function.  */
478145132Sanholt#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
479145132Sanholtextern rettype function parameters_and_attributes
480145132Sanholt#  else /* Unsupported.  */
481145132Sanholt#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
482145132Sanholt_GL_WARN_EXTERN_C int _gl_warn_on_use
483145132Sanholt#  endif
484145132Sanholt# endif
485145132Sanholt#endif
486145132Sanholt
487145132Sanholt/* _GL_WARN_EXTERN_C declaration;
488145132Sanholt   performs the declaration with C linkage.  */
489145132Sanholt#ifndef _GL_WARN_EXTERN_C
490145132Sanholt# if defined __cplusplus
491145132Sanholt#  define _GL_WARN_EXTERN_C extern "C"
492182080Srnoland# else
493145132Sanholt#  define _GL_WARN_EXTERN_C extern
494152909Sanholt# endif
495145132Sanholt#endif
496145132Sanholt
497145132Sanholt/* Return non-zero if c is a blank, i.e. a space or tab character.  */
498145132Sanholt#if 1
499145132Sanholt# if !1
500145132Sanholt_GL_EXTERN_C int isblank (int c);
501182080Srnoland# endif
502145132Sanholt#elif defined GNULIB_POSIXCHECK
503145132Sanholt# undef isblank
504145132Sanholt# if HAVE_RAW_DECL_ISBLANK
505145132Sanholt_GL_WARN_ON_USE (isblank, "isblank is unportable - "
506145132Sanholt                 "use gnulib module isblank for portability");
507145132Sanholt# endif
508145132Sanholt#endif
509145132Sanholt
510145132Sanholt#endif /* _GL_CTYPE_H */
511145132Sanholt#endif /* _GL_CTYPE_H */
512145132Sanholt