1219820Sjeff/* This file is automatically generated.  DO NOT EDIT! */
2219820Sjeff/* Generated from: NetBSD: mknative-gdb,v 1.12 2020/09/17 16:54:31 christos Exp  */
3219820Sjeff/* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
4219820Sjeff
5219820Sjeff/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
6219820Sjeff/* A more-standard <time.h>.
7219820Sjeff
8219820Sjeff   Copyright (C) 2007-2020 Free Software Foundation, Inc.
9219820Sjeff
10219820Sjeff   This program is free software; you can redistribute it and/or modify
11219820Sjeff   it under the terms of the GNU General Public License as published by
12219820Sjeff   the Free Software Foundation; either version 3, or (at your option)
13219820Sjeff   any later version.
14219820Sjeff
15219820Sjeff   This program is distributed in the hope that it will be useful,
16219820Sjeff   but WITHOUT ANY WARRANTY; without even the implied warranty of
17219820Sjeff   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18219820Sjeff   GNU General Public License for more details.
19219820Sjeff
20219820Sjeff   You should have received a copy of the GNU General Public License
21219820Sjeff   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
22219820Sjeff
23219820Sjeff#if __GNUC__ >= 3
24219820Sjeff#pragma GCC system_header
25219820Sjeff#endif
26219820Sjeff
27219820Sjeff
28219820Sjeff/* Don't get in the way of glibc when it includes time.h merely to
29219820Sjeff   declare a few standard symbols, rather than to declare all the
30219820Sjeff   symbols.  (However, skip this for MinGW as it treats __need_time_t
31219820Sjeff   incompatibly.)  Also, Solaris 8 <time.h> eventually includes itself
32219820Sjeff   recursively; if that is happening, just include the system <time.h>
33219820Sjeff   without adding our own declarations.  */
34219820Sjeff#if (((defined __need_time_t || defined __need_clock_t \
35219820Sjeff       || defined __need_timespec)                     \
36219820Sjeff      && !defined __MINGW32__)                         \
37219820Sjeff     || defined _GL_TIME_H)
38219820Sjeff
39219820Sjeff# include_next <time.h>
40219820Sjeff
41219820Sjeff#else
42219820Sjeff
43219820Sjeff# define _GL_TIME_H
44219820Sjeff
45219820Sjeff/* mingw's <time.h> provides the functions asctime_r, ctime_r, gmtime_r,
46219820Sjeff   localtime_r only if <unistd.h> or <pthread.h> has been included before.  */
47219820Sjeff# if defined __MINGW32__
48219820Sjeff#  include <unistd.h>
49219820Sjeff# endif
50219820Sjeff
51219820Sjeff# include_next <time.h>
52219820Sjeff
53219820Sjeff/* NetBSD 5.0 mis-defines NULL.  */
54219820Sjeff# include <stddef.h>
55219820Sjeff
56219820Sjeff/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
57219820Sjeff/* C++ compatible function declaration macros.
58219820Sjeff   Copyright (C) 2010-2020 Free Software Foundation, Inc.
59219820Sjeff
60219820Sjeff   This program is free software: you can redistribute it and/or modify it
61219820Sjeff   under the terms of the GNU General Public License as published
62219820Sjeff   by the Free Software Foundation; either version 3 of the License, or
63219820Sjeff   (at your option) any later version.
64219820Sjeff
65219820Sjeff   This program is distributed in the hope that it will be useful,
66219820Sjeff   but WITHOUT ANY WARRANTY; without even the implied warranty of
67219820Sjeff   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
68219820Sjeff   General Public License for more details.
69219820Sjeff
70219820Sjeff   You should have received a copy of the GNU General Public License
71219820Sjeff   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
72219820Sjeff
73219820Sjeff#ifndef _GL_CXXDEFS_H
74219820Sjeff#define _GL_CXXDEFS_H
75219820Sjeff
76219820Sjeff/* Begin/end the GNULIB_NAMESPACE namespace.  */
77219820Sjeff#if defined __cplusplus && defined GNULIB_NAMESPACE
78219820Sjeff# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
79219820Sjeff# define _GL_END_NAMESPACE }
80219820Sjeff#else
81219820Sjeff# define _GL_BEGIN_NAMESPACE
82219820Sjeff# define _GL_END_NAMESPACE
83219820Sjeff#endif
84219820Sjeff
85219820Sjeff/* The three most frequent use cases of these macros are:
86219820Sjeff
87219820Sjeff   * For providing a substitute for a function that is missing on some
88219820Sjeff     platforms, but is declared and works fine on the platforms on which
89219820Sjeff     it exists:
90219820Sjeff
91219820Sjeff       #if @GNULIB_FOO@
92219820Sjeff       # if !@HAVE_FOO@
93219820Sjeff       _GL_FUNCDECL_SYS (foo, ...);
94219820Sjeff       # endif
95219820Sjeff       _GL_CXXALIAS_SYS (foo, ...);
96219820Sjeff       _GL_CXXALIASWARN (foo);
97219820Sjeff       #elif defined GNULIB_POSIXCHECK
98219820Sjeff       ...
99219820Sjeff       #endif
100219820Sjeff
101219820Sjeff   * For providing a replacement for a function that exists on all platforms,
102219820Sjeff     but is broken/insufficient and needs to be replaced on some platforms:
103219820Sjeff
104219820Sjeff       #if @GNULIB_FOO@
105219820Sjeff       # if @REPLACE_FOO@
106219820Sjeff       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
107219820Sjeff       #   undef foo
108219820Sjeff       #   define foo rpl_foo
109219820Sjeff       #  endif
110219820Sjeff       _GL_FUNCDECL_RPL (foo, ...);
111219820Sjeff       _GL_CXXALIAS_RPL (foo, ...);
112219820Sjeff       # else
113219820Sjeff       _GL_CXXALIAS_SYS (foo, ...);
114219820Sjeff       # endif
115219820Sjeff       _GL_CXXALIASWARN (foo);
116219820Sjeff       #elif defined GNULIB_POSIXCHECK
117219820Sjeff       ...
118219820Sjeff       #endif
119219820Sjeff
120219820Sjeff   * For providing a replacement for a function that exists on some platforms
121219820Sjeff     but is broken/insufficient and needs to be replaced on some of them and
122219820Sjeff     is additionally either missing or undeclared on some other platforms:
123219820Sjeff
124219820Sjeff       #if @GNULIB_FOO@
125219820Sjeff       # if @REPLACE_FOO@
126219820Sjeff       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
127219820Sjeff       #   undef foo
128219820Sjeff       #   define foo rpl_foo
129219820Sjeff       #  endif
130219820Sjeff       _GL_FUNCDECL_RPL (foo, ...);
131219820Sjeff       _GL_CXXALIAS_RPL (foo, ...);
132219820Sjeff       # else
133219820Sjeff       #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
134219820Sjeff       _GL_FUNCDECL_SYS (foo, ...);
135219820Sjeff       #  endif
136219820Sjeff       _GL_CXXALIAS_SYS (foo, ...);
137219820Sjeff       # endif
138219820Sjeff       _GL_CXXALIASWARN (foo);
139219820Sjeff       #elif defined GNULIB_POSIXCHECK
140219820Sjeff       ...
141219820Sjeff       #endif
142219820Sjeff*/
143219820Sjeff
144219820Sjeff/* _GL_EXTERN_C declaration;
145219820Sjeff   performs the declaration with C linkage.  */
146219820Sjeff#if defined __cplusplus
147219820Sjeff# define _GL_EXTERN_C extern "C"
148219820Sjeff#else
149219820Sjeff# define _GL_EXTERN_C extern
150219820Sjeff#endif
151219820Sjeff
152219820Sjeff/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
153219820Sjeff   declares a replacement function, named rpl_func, with the given prototype,
154219820Sjeff   consisting of return type, parameters, and attributes.
155219820Sjeff   Example:
156219820Sjeff     _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
157219820Sjeff                                  _GL_ARG_NONNULL ((1)));
158219820Sjeff */
159219820Sjeff#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
160219820Sjeff  _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
161219820Sjeff#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
162219820Sjeff  _GL_EXTERN_C rettype rpl_func parameters_and_attributes
163219820Sjeff
164219820Sjeff/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
165219820Sjeff   declares the system function, named func, with the given prototype,
166219820Sjeff   consisting of return type, parameters, and attributes.
167219820Sjeff   Example:
168219820Sjeff     _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
169219820Sjeff                                  _GL_ARG_NONNULL ((1)));
170219820Sjeff */
171219820Sjeff#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
172219820Sjeff  _GL_EXTERN_C rettype func parameters_and_attributes
173219820Sjeff
174219820Sjeff/* _GL_CXXALIAS_RPL (func, rettype, parameters);
175219820Sjeff   declares a C++ alias called GNULIB_NAMESPACE::func
176219820Sjeff   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
177219820Sjeff   Example:
178219820Sjeff     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
179219820Sjeff
180219820Sjeff   Wrapping rpl_func in an object with an inline conversion operator
181219820Sjeff   avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
182219820Sjeff   actually used in the program.  */
183219820Sjeff#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
184219820Sjeff  _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
185219820Sjeff#if defined __cplusplus && defined GNULIB_NAMESPACE
186219820Sjeff# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
187219820Sjeff    namespace GNULIB_NAMESPACE                                \
188219820Sjeff    {                                                         \
189219820Sjeff      static const struct _gl_ ## func ## _wrapper            \
190219820Sjeff      {                                                       \
191219820Sjeff        typedef rettype (*type) parameters;                   \
192219820Sjeff                                                              \
193219820Sjeff        inline operator type () const                         \
194219820Sjeff        {                                                     \
195219820Sjeff          return ::rpl_func;                                  \
196219820Sjeff        }                                                     \
197219820Sjeff      } func = {};                                            \
198219820Sjeff    }                                                         \
199219820Sjeff    _GL_EXTERN_C int _gl_cxxalias_dummy
200219820Sjeff#else
201219820Sjeff# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
202219820Sjeff    _GL_EXTERN_C int _gl_cxxalias_dummy
203219820Sjeff#endif
204219820Sjeff
205219820Sjeff/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
206219820Sjeff   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
207219820Sjeff   except that the C function rpl_func may have a slightly different
208219820Sjeff   declaration.  A cast is used to silence the "invalid conversion" error
209219820Sjeff   that would otherwise occur.  */
210219820Sjeff#if defined __cplusplus && defined GNULIB_NAMESPACE
211219820Sjeff# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
212219820Sjeff    namespace GNULIB_NAMESPACE                                     \
213219820Sjeff    {                                                              \
214219820Sjeff      static const struct _gl_ ## func ## _wrapper                 \
215219820Sjeff      {                                                            \
216219820Sjeff        typedef rettype (*type) parameters;                        \
217219820Sjeff                                                                   \
218219820Sjeff        inline operator type () const                              \
219219820Sjeff        {                                                          \
220219820Sjeff          return reinterpret_cast<type>(::rpl_func);               \
221219820Sjeff        }                                                          \
222219820Sjeff      } func = {};                                                 \
223219820Sjeff    }                                                              \
224219820Sjeff    _GL_EXTERN_C int _gl_cxxalias_dummy
225219820Sjeff#else
226219820Sjeff# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
227219820Sjeff    _GL_EXTERN_C int _gl_cxxalias_dummy
228219820Sjeff#endif
229219820Sjeff
230219820Sjeff/* _GL_CXXALIAS_SYS (func, rettype, parameters);
231219820Sjeff   declares a C++ alias called GNULIB_NAMESPACE::func
232219820Sjeff   that redirects to the system provided function func, if GNULIB_NAMESPACE
233219820Sjeff   is defined.
234219820Sjeff   Example:
235219820Sjeff     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
236219820Sjeff
237219820Sjeff   Wrapping func in an object with an inline conversion operator
238219820Sjeff   avoids a reference to func unless GNULIB_NAMESPACE::func is
239219820Sjeff   actually used in the program.  */
240219820Sjeff#if defined __cplusplus && defined GNULIB_NAMESPACE
241219820Sjeff# define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
242219820Sjeff    namespace GNULIB_NAMESPACE                                \
243219820Sjeff    {                                                         \
244219820Sjeff      static const struct _gl_ ## func ## _wrapper            \
245219820Sjeff      {                                                       \
246        typedef rettype (*type) parameters;                   \
247                                                              \
248        inline operator type () const                         \
249        {                                                     \
250          return ::func;                                      \
251        }                                                     \
252      } func = {};                                            \
253    }                                                         \
254    _GL_EXTERN_C int _gl_cxxalias_dummy
255#else
256# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
257    _GL_EXTERN_C int _gl_cxxalias_dummy
258#endif
259
260/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
261   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
262   except that the C function func may have a slightly different declaration.
263   A cast is used to silence the "invalid conversion" error that would
264   otherwise occur.  */
265#if defined __cplusplus && defined GNULIB_NAMESPACE
266# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
267    namespace GNULIB_NAMESPACE                          \
268    {                                                   \
269      static const struct _gl_ ## func ## _wrapper      \
270      {                                                 \
271        typedef rettype (*type) parameters;             \
272                                                        \
273        inline operator type () const                   \
274        {                                               \
275          return reinterpret_cast<type>(::func);        \
276        }                                               \
277      } func = {};                                      \
278    }                                                   \
279    _GL_EXTERN_C int _gl_cxxalias_dummy
280#else
281# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
282    _GL_EXTERN_C int _gl_cxxalias_dummy
283#endif
284
285/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
286   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
287   except that the C function is picked among a set of overloaded functions,
288   namely the one with rettype2 and parameters2.  Two consecutive casts
289   are used to silence the "cannot find a match" and "invalid conversion"
290   errors that would otherwise occur.  */
291#if defined __cplusplus && defined GNULIB_NAMESPACE
292  /* The outer cast must be a reinterpret_cast.
293     The inner cast: When the function is defined as a set of overloaded
294     functions, it works as a static_cast<>, choosing the designated variant.
295     When the function is defined as a single variant, it works as a
296     reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
297# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
298    namespace GNULIB_NAMESPACE                                                \
299    {                                                                         \
300      static const struct _gl_ ## func ## _wrapper                            \
301      {                                                                       \
302        typedef rettype (*type) parameters;                                   \
303                                                                              \
304        inline operator type () const                                         \
305        {                                                                     \
306          return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
307        }                                                                     \
308      } func = {};                                                            \
309    }                                                                         \
310    _GL_EXTERN_C int _gl_cxxalias_dummy
311#else
312# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
313    _GL_EXTERN_C int _gl_cxxalias_dummy
314#endif
315
316/* _GL_CXXALIASWARN (func);
317   causes a warning to be emitted when ::func is used but not when
318   GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
319   variants.  */
320#if defined __cplusplus && defined GNULIB_NAMESPACE
321# define _GL_CXXALIASWARN(func) \
322   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
323# define _GL_CXXALIASWARN_1(func,namespace) \
324   _GL_CXXALIASWARN_2 (func, namespace)
325/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
326   we enable the warning only when not optimizing.  */
327# if !__OPTIMIZE__
328#  define _GL_CXXALIASWARN_2(func,namespace) \
329    _GL_WARN_ON_USE (func, \
330                     "The symbol ::" #func " refers to the system function. " \
331                     "Use " #namespace "::" #func " instead.")
332# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
333#  define _GL_CXXALIASWARN_2(func,namespace) \
334     extern __typeof__ (func) func
335# else
336#  define _GL_CXXALIASWARN_2(func,namespace) \
337     _GL_EXTERN_C int _gl_cxxalias_dummy
338# endif
339#else
340# define _GL_CXXALIASWARN(func) \
341    _GL_EXTERN_C int _gl_cxxalias_dummy
342#endif
343
344/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
345   causes a warning to be emitted when the given overloaded variant of ::func
346   is used but not when GNULIB_NAMESPACE::func is used.  */
347#if defined __cplusplus && defined GNULIB_NAMESPACE
348# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
349   _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
350                        GNULIB_NAMESPACE)
351# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
352   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
353/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
354   we enable the warning only when not optimizing.  */
355# if !__OPTIMIZE__
356#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
357    _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
358                         "The symbol ::" #func " refers to the system function. " \
359                         "Use " #namespace "::" #func " instead.")
360# else
361#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
362     _GL_EXTERN_C int _gl_cxxalias_dummy
363# endif
364#else
365# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
366    _GL_EXTERN_C int _gl_cxxalias_dummy
367#endif
368
369#endif /* _GL_CXXDEFS_H */
370
371/* The definition of _GL_ARG_NONNULL is copied here.  */
372/* A C macro for declaring that specific arguments must not be NULL.
373   Copyright (C) 2009-2020 Free Software Foundation, Inc.
374
375   This program is free software: you can redistribute it and/or modify it
376   under the terms of the GNU General Public License as published
377   by the Free Software Foundation; either version 3 of the License, or
378   (at your option) any later version.
379
380   This program is distributed in the hope that it will be useful,
381   but WITHOUT ANY WARRANTY; without even the implied warranty of
382   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
383   General Public License for more details.
384
385   You should have received a copy of the GNU General Public License
386   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
387
388/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
389   that the values passed as arguments n, ..., m must be non-NULL pointers.
390   n = 1 stands for the first argument, n = 2 for the second argument etc.  */
391#ifndef _GL_ARG_NONNULL
392# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
393#  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
394# else
395#  define _GL_ARG_NONNULL(params)
396# endif
397#endif
398
399/* The definition of _GL_WARN_ON_USE is copied here.  */
400/* A C macro for emitting warnings if a function is used.
401   Copyright (C) 2010-2020 Free Software Foundation, Inc.
402
403   This program is free software: you can redistribute it and/or modify it
404   under the terms of the GNU General Public License as published
405   by the Free Software Foundation; either version 3 of the License, or
406   (at your option) any later version.
407
408   This program is distributed in the hope that it will be useful,
409   but WITHOUT ANY WARRANTY; without even the implied warranty of
410   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
411   General Public License for more details.
412
413   You should have received a copy of the GNU General Public License
414   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
415
416/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
417   for FUNCTION which will then trigger a compiler warning containing
418   the text of "literal string" anywhere that function is called, if
419   supported by the compiler.  If the compiler does not support this
420   feature, the macro expands to an unused extern declaration.
421
422   _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
423   attribute used in _GL_WARN_ON_USE.  If the compiler does not support
424   this feature, it expands to empty.
425
426   These macros are useful for marking a function as a potential
427   portability trap, with the intent that "literal string" include
428   instructions on the replacement function that should be used
429   instead.
430   _GL_WARN_ON_USE is for functions with 'extern' linkage.
431   _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
432   linkage.
433
434   However, one of the reasons that a function is a portability trap is
435   if it has the wrong signature.  Declaring FUNCTION with a different
436   signature in C is a compilation error, so this macro must use the
437   same type as any existing declaration so that programs that avoid
438   the problematic FUNCTION do not fail to compile merely because they
439   included a header that poisoned the function.  But this implies that
440   _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
441   have a declaration.  Use of this macro implies that there must not
442   be any other macro hiding the declaration of FUNCTION; but
443   undefining FUNCTION first is part of the poisoning process anyway
444   (although for symbols that are provided only via a macro, the result
445   is a compilation error rather than a warning containing
446   "literal string").  Also note that in C++, it is only safe to use if
447   FUNCTION has no overloads.
448
449   For an example, it is possible to poison 'getline' by:
450   - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
451     [getline]) in configure.ac, which potentially defines
452     HAVE_RAW_DECL_GETLINE
453   - adding this code to a header that wraps the system <stdio.h>:
454     #undef getline
455     #if HAVE_RAW_DECL_GETLINE
456     _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
457       "not universally present; use the gnulib module getline");
458     #endif
459
460   It is not possible to directly poison global variables.  But it is
461   possible to write a wrapper accessor function, and poison that
462   (less common usage, like &environ, will cause a compilation error
463   rather than issue the nice warning, but the end result of informing
464   the developer about their portability problem is still achieved):
465     #if HAVE_RAW_DECL_ENVIRON
466     static char ***
467     rpl_environ (void) { return &environ; }
468     _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
469     # undef environ
470     # define environ (*rpl_environ ())
471     #endif
472   or better (avoiding contradictory use of 'static' and 'extern'):
473     #if HAVE_RAW_DECL_ENVIRON
474     static char ***
475     _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
476     rpl_environ (void) { return &environ; }
477     # undef environ
478     # define environ (*rpl_environ ())
479     #endif
480   */
481#ifndef _GL_WARN_ON_USE
482
483# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
484/* A compiler attribute is available in gcc versions 4.3.0 and later.  */
485#  define _GL_WARN_ON_USE(function, message) \
486extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
487#  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
488  __attribute__ ((__warning__ (message)))
489# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
490/* Verify the existence of the function.  */
491#  define _GL_WARN_ON_USE(function, message) \
492extern __typeof__ (function) function
493#  define _GL_WARN_ON_USE_ATTRIBUTE(message)
494# else /* Unsupported.  */
495#  define _GL_WARN_ON_USE(function, message) \
496_GL_WARN_EXTERN_C int _gl_warn_on_use
497#  define _GL_WARN_ON_USE_ATTRIBUTE(message)
498# endif
499#endif
500
501/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
502   is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the
503   function is declared with the given prototype, consisting of return type,
504   parameters, and attributes.
505   This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
506   not work in this case.  */
507#ifndef _GL_WARN_ON_USE_CXX
508# if !defined __cplusplus
509#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
510     _GL_WARN_ON_USE (function, msg)
511# else
512#  if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
513#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
514extern rettype function parameters_and_attributes \
515     __attribute__ ((__warning__ (msg)))
516#  elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
517/* Verify the existence of the function.  */
518#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
519extern rettype function parameters_and_attributes
520#  else /* Unsupported.  */
521#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
522_GL_WARN_EXTERN_C int _gl_warn_on_use
523#  endif
524# endif
525#endif
526
527/* _GL_WARN_EXTERN_C declaration;
528   performs the declaration with C linkage.  */
529#ifndef _GL_WARN_EXTERN_C
530# if defined __cplusplus
531#  define _GL_WARN_EXTERN_C extern "C"
532# else
533#  define _GL_WARN_EXTERN_C extern
534# endif
535#endif
536
537/* Some systems don't define struct timespec (e.g., AIX 4.1).
538   Or they define it with the wrong member names or define it in <sys/time.h>
539   (e.g., FreeBSD circa 1997).  Stock Mingw prior to 3.0 does not define it,
540   but the pthreads-win32 library defines it in <pthread.h>.  */
541# if ! 1
542#  if 0
543#   include <sys/time.h>
544#  elif 0
545#   include <pthread.h>
546#  elif 0
547#   include <unistd.h>
548#  else
549
550#   ifdef __cplusplus
551extern "C" {
552#   endif
553
554#   if !GNULIB_defined_struct_timespec
555#    undef timespec
556#    define timespec rpl_timespec
557struct timespec
558{
559  time_t tv_sec;
560  long int tv_nsec;
561};
562#    define GNULIB_defined_struct_timespec 1
563#   endif
564
565#   ifdef __cplusplus
566}
567#   endif
568
569#  endif
570# endif
571
572# if !GNULIB_defined_struct_time_t_must_be_integral
573/* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
574   requires time_t to be an integer type, even though C99 permits floating
575   point.  We don't know of any implementation that uses floating
576   point, and it is much easier to write code that doesn't have to
577   worry about that corner case, so we force the issue.  */
578struct __time_t_must_be_integral {
579  unsigned int __floating_time_t_unsupported : (time_t) 1;
580};
581#  define GNULIB_defined_struct_time_t_must_be_integral 1
582# endif
583
584/* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
585   return -1 and store the remaining time into RMTP.  See
586   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html>.  */
587# if 0
588#  if GNULIB_PORTCHECK
589#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
590#    define nanosleep rpl_nanosleep
591#   endif
592_GL_FUNCDECL_RPL (nanosleep, int,
593                  (struct timespec const *__rqtp, struct timespec *__rmtp)
594                  _GL_ARG_NONNULL ((1)));
595_GL_CXXALIAS_RPL (nanosleep, int,
596                  (struct timespec const *__rqtp, struct timespec *__rmtp));
597#  else
598#   if ! 1
599_GL_FUNCDECL_SYS (nanosleep, int,
600                  (struct timespec const *__rqtp, struct timespec *__rmtp)
601                  _GL_ARG_NONNULL ((1)));
602#   endif
603_GL_CXXALIAS_SYS (nanosleep, int,
604                  (struct timespec const *__rqtp, struct timespec *__rmtp));
605#  endif
606_GL_CXXALIASWARN (nanosleep);
607# endif
608
609/* Initialize time conversion information.  */
610# if 0
611#  if GNULIB_PORTCHECK
612#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
613#    undef tzset
614#    define tzset rpl_tzset
615#   endif
616_GL_FUNCDECL_RPL (tzset, void, (void));
617_GL_CXXALIAS_RPL (tzset, void, (void));
618#  else
619#   if ! 1
620_GL_FUNCDECL_SYS (tzset, void, (void));
621#   endif
622_GL_CXXALIAS_SYS (tzset, void, (void));
623#  endif
624_GL_CXXALIASWARN (tzset);
625# endif
626
627/* Return the 'time_t' representation of TP and normalize TP.  */
628# if 0
629#  if GNULIB_PORTCHECK
630#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
631#    define mktime rpl_mktime
632#   endif
633_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
634_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
635#  else
636_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
637#  endif
638#  if __GLIBC__ >= 2
639_GL_CXXALIASWARN (mktime);
640#  endif
641# endif
642
643/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
644   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime_r.html> and
645   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime_r.html>.  */
646# if 1
647#  if 0
648#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
649#    undef localtime_r
650#    define localtime_r rpl_localtime_r
651#   endif
652_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
653                                             struct tm *restrict __result)
654                                            _GL_ARG_NONNULL ((1, 2)));
655_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
656                                             struct tm *restrict __result));
657#  else
658#   if ! 1
659_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
660                                             struct tm *restrict __result)
661                                            _GL_ARG_NONNULL ((1, 2)));
662#   endif
663_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
664                                             struct tm *restrict __result));
665#  endif
666#  if 1
667_GL_CXXALIASWARN (localtime_r);
668#  endif
669#  if 0
670#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
671#    undef gmtime_r
672#    define gmtime_r rpl_gmtime_r
673#   endif
674_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
675                                          struct tm *restrict __result)
676                                         _GL_ARG_NONNULL ((1, 2)));
677_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
678                                          struct tm *restrict __result));
679#  else
680#   if ! 1
681_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
682                                          struct tm *restrict __result)
683                                         _GL_ARG_NONNULL ((1, 2)));
684#   endif
685_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
686                                          struct tm *restrict __result));
687#  endif
688#  if 1
689_GL_CXXALIASWARN (gmtime_r);
690#  endif
691# endif
692
693/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
694   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime.html> and
695   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html>.  */
696# if 0 || 0
697#  if 0
698#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
699#    undef localtime
700#    define localtime rpl_localtime
701#   endif
702_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
703                                          _GL_ARG_NONNULL ((1)));
704_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
705#  else
706_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
707#  endif
708#  if __GLIBC__ >= 2
709_GL_CXXALIASWARN (localtime);
710#  endif
711# endif
712
713# if 0 || 0
714#  if 0
715#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
716#    undef gmtime
717#    define gmtime rpl_gmtime
718#   endif
719_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
720                                       _GL_ARG_NONNULL ((1)));
721_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
722#  else
723_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
724#  endif
725_GL_CXXALIASWARN (gmtime);
726# endif
727
728/* Parse BUF as a timestamp, assuming FORMAT specifies its layout, and store
729   the resulting broken-down time into TM.  See
730   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html>.  */
731# if 0
732#  if ! 1
733_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
734                                     char const *restrict __format,
735                                     struct tm *restrict __tm)
736                                    _GL_ARG_NONNULL ((1, 2, 3)));
737#  endif
738_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
739                                     char const *restrict __format,
740                                     struct tm *restrict __tm));
741_GL_CXXALIASWARN (strptime);
742# endif
743
744/* Convert *TP to a date and time string.  See
745   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>.  */
746# if 0
747#  if GNULIB_PORTCHECK
748#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
749#    define ctime rpl_ctime
750#   endif
751_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
752                                 _GL_ARG_NONNULL ((1)));
753_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
754#  else
755_GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
756#  endif
757#  if __GLIBC__ >= 2
758_GL_CXXALIASWARN (ctime);
759#  endif
760# endif
761
762/* Convert *TP to a date and time string.  See
763   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>.  */
764# if 0
765#  if GNULIB_PORTCHECK
766#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
767#    define strftime rpl_strftime
768#   endif
769_GL_FUNCDECL_RPL (strftime, size_t,
770                  (char *restrict __buf, size_t __bufsize,
771                   const char *restrict __fmt, const struct tm *restrict __tp)
772                  _GL_ARG_NONNULL ((1, 3, 4)));
773_GL_CXXALIAS_RPL (strftime, size_t,
774                  (char *restrict __buf, size_t __bufsize,
775                   const char *restrict __fmt, const struct tm *restrict __tp));
776#  else
777_GL_CXXALIAS_SYS (strftime, size_t,
778                  (char *restrict __buf, size_t __bufsize,
779                   const char *restrict __fmt, const struct tm *restrict __tp));
780#  endif
781#  if __GLIBC__ >= 2
782_GL_CXXALIASWARN (strftime);
783#  endif
784# endif
785
786# if defined _GNU_SOURCE && 0 && ! 0
787typedef struct tm_zone *timezone_t;
788_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
789_GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
790_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz));
791_GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
792_GL_FUNCDECL_SYS (localtime_rz, struct tm *,
793                  (timezone_t __tz, time_t const *restrict __timer,
794                   struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3)));
795_GL_CXXALIAS_SYS (localtime_rz, struct tm *,
796                  (timezone_t __tz, time_t const *restrict __timer,
797                   struct tm *restrict __result));
798_GL_FUNCDECL_SYS (mktime_z, time_t,
799                  (timezone_t __tz, struct tm *restrict __result)
800                  _GL_ARG_NONNULL ((2)));
801_GL_CXXALIAS_SYS (mktime_z, time_t,
802                  (timezone_t __tz, struct tm *restrict __result));
803# endif
804
805/* Convert TM to a time_t value, assuming UTC.  */
806# if 0
807#  if GNULIB_PORTCHECK
808#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
809#    undef timegm
810#    define timegm rpl_timegm
811#   endif
812_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
813_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
814#  else
815#   if ! 1
816_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
817#   endif
818_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
819#  endif
820_GL_CXXALIASWARN (timegm);
821# endif
822
823/* Encourage applications to avoid unsafe functions that can overrun
824   buffers when given outlandish struct tm values.  Portable
825   applications should use strftime (or even sprintf) instead.  */
826# if defined GNULIB_POSIXCHECK
827#  undef asctime
828_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
829                 "better use strftime (or even sprintf) instead");
830# endif
831# if defined GNULIB_POSIXCHECK
832#  undef asctime_r
833_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
834                 "better use strftime (or even sprintf) instead");
835# endif
836# if defined GNULIB_POSIXCHECK
837#  undef ctime
838_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
839                 "better use strftime (or even sprintf) instead");
840# endif
841# if defined GNULIB_POSIXCHECK
842#  undef ctime_r
843_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
844                 "better use strftime (or even sprintf) instead");
845# endif
846
847#endif
848