1*56bb7041Schristos /* This file is automatically generated.  DO NOT EDIT! */
2*56bb7041Schristos /* Generated from: NetBSD: mknative-gdb,v 1.15 2020/12/05 21:27:31 christos Exp  */
3*56bb7041Schristos /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
4*56bb7041Schristos 
5*56bb7041Schristos /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
6*56bb7041Schristos /* A more-standard <time.h>.
7*56bb7041Schristos 
8*56bb7041Schristos    Copyright (C) 2007-2020 Free Software Foundation, Inc.
9*56bb7041Schristos 
10*56bb7041Schristos    This program is free software; you can redistribute it and/or modify
11*56bb7041Schristos    it under the terms of the GNU General Public License as published by
12*56bb7041Schristos    the Free Software Foundation; either version 3, or (at your option)
13*56bb7041Schristos    any later version.
14*56bb7041Schristos 
15*56bb7041Schristos    This program is distributed in the hope that it will be useful,
16*56bb7041Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
17*56bb7041Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*56bb7041Schristos    GNU General Public License for more details.
19*56bb7041Schristos 
20*56bb7041Schristos    You should have received a copy of the GNU General Public License
21*56bb7041Schristos    along with this program; if not, see <https://www.gnu.org/licenses/>.  */
22*56bb7041Schristos 
23*56bb7041Schristos #if __GNUC__ >= 3
24*56bb7041Schristos #pragma GCC system_header
25*56bb7041Schristos #endif
26*56bb7041Schristos 
27*56bb7041Schristos 
28*56bb7041Schristos /* Don't get in the way of glibc when it includes time.h merely to
29*56bb7041Schristos    declare a few standard symbols, rather than to declare all the
30*56bb7041Schristos    symbols.  (However, skip this for MinGW as it treats __need_time_t
31*56bb7041Schristos    incompatibly.)  Also, Solaris 8 <time.h> eventually includes itself
32*56bb7041Schristos    recursively; if that is happening, just include the system <time.h>
33*56bb7041Schristos    without adding our own declarations.  */
34*56bb7041Schristos #if (((defined __need_time_t || defined __need_clock_t \
35*56bb7041Schristos        || defined __need_timespec)                     \
36*56bb7041Schristos       && !defined __MINGW32__)                         \
37*56bb7041Schristos      || defined _GL_TIME_H)
38*56bb7041Schristos 
39*56bb7041Schristos # include_next <time.h>
40*56bb7041Schristos 
41*56bb7041Schristos #else
42*56bb7041Schristos 
43*56bb7041Schristos # define _GL_TIME_H
44*56bb7041Schristos 
45*56bb7041Schristos /* mingw's <time.h> provides the functions asctime_r, ctime_r, gmtime_r,
46*56bb7041Schristos    localtime_r only if <unistd.h> or <pthread.h> has been included before.  */
47*56bb7041Schristos # if defined __MINGW32__
48*56bb7041Schristos #  include <unistd.h>
49*56bb7041Schristos # endif
50*56bb7041Schristos 
51*56bb7041Schristos # include_next <time.h>
52*56bb7041Schristos 
53*56bb7041Schristos /* NetBSD 5.0 mis-defines NULL.  */
54*56bb7041Schristos # include <stddef.h>
55*56bb7041Schristos 
56*56bb7041Schristos /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
57*56bb7041Schristos /* C++ compatible function declaration macros.
58*56bb7041Schristos    Copyright (C) 2010-2020 Free Software Foundation, Inc.
59*56bb7041Schristos 
60*56bb7041Schristos    This program is free software: you can redistribute it and/or modify it
61*56bb7041Schristos    under the terms of the GNU General Public License as published
62*56bb7041Schristos    by the Free Software Foundation; either version 3 of the License, or
63*56bb7041Schristos    (at your option) any later version.
64*56bb7041Schristos 
65*56bb7041Schristos    This program is distributed in the hope that it will be useful,
66*56bb7041Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
67*56bb7041Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
68*56bb7041Schristos    General Public License for more details.
69*56bb7041Schristos 
70*56bb7041Schristos    You should have received a copy of the GNU General Public License
71*56bb7041Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
72*56bb7041Schristos 
73*56bb7041Schristos #ifndef _GL_CXXDEFS_H
74*56bb7041Schristos #define _GL_CXXDEFS_H
75*56bb7041Schristos 
76*56bb7041Schristos /* Begin/end the GNULIB_NAMESPACE namespace.  */
77*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
78*56bb7041Schristos # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
79*56bb7041Schristos # define _GL_END_NAMESPACE }
80*56bb7041Schristos #else
81*56bb7041Schristos # define _GL_BEGIN_NAMESPACE
82*56bb7041Schristos # define _GL_END_NAMESPACE
83*56bb7041Schristos #endif
84*56bb7041Schristos 
85*56bb7041Schristos /* The three most frequent use cases of these macros are:
86*56bb7041Schristos 
87*56bb7041Schristos    * For providing a substitute for a function that is missing on some
88*56bb7041Schristos      platforms, but is declared and works fine on the platforms on which
89*56bb7041Schristos      it exists:
90*56bb7041Schristos 
91*56bb7041Schristos        #if @GNULIB_FOO@
92*56bb7041Schristos        # if !@HAVE_FOO@
93*56bb7041Schristos        _GL_FUNCDECL_SYS (foo, ...);
94*56bb7041Schristos        # endif
95*56bb7041Schristos        _GL_CXXALIAS_SYS (foo, ...);
96*56bb7041Schristos        _GL_CXXALIASWARN (foo);
97*56bb7041Schristos        #elif defined GNULIB_POSIXCHECK
98*56bb7041Schristos        ...
99*56bb7041Schristos        #endif
100*56bb7041Schristos 
101*56bb7041Schristos    * For providing a replacement for a function that exists on all platforms,
102*56bb7041Schristos      but is broken/insufficient and needs to be replaced on some platforms:
103*56bb7041Schristos 
104*56bb7041Schristos        #if @GNULIB_FOO@
105*56bb7041Schristos        # if @REPLACE_FOO@
106*56bb7041Schristos        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
107*56bb7041Schristos        #   undef foo
108*56bb7041Schristos        #   define foo rpl_foo
109*56bb7041Schristos        #  endif
110*56bb7041Schristos        _GL_FUNCDECL_RPL (foo, ...);
111*56bb7041Schristos        _GL_CXXALIAS_RPL (foo, ...);
112*56bb7041Schristos        # else
113*56bb7041Schristos        _GL_CXXALIAS_SYS (foo, ...);
114*56bb7041Schristos        # endif
115*56bb7041Schristos        _GL_CXXALIASWARN (foo);
116*56bb7041Schristos        #elif defined GNULIB_POSIXCHECK
117*56bb7041Schristos        ...
118*56bb7041Schristos        #endif
119*56bb7041Schristos 
120*56bb7041Schristos    * For providing a replacement for a function that exists on some platforms
121*56bb7041Schristos      but is broken/insufficient and needs to be replaced on some of them and
122*56bb7041Schristos      is additionally either missing or undeclared on some other platforms:
123*56bb7041Schristos 
124*56bb7041Schristos        #if @GNULIB_FOO@
125*56bb7041Schristos        # if @REPLACE_FOO@
126*56bb7041Schristos        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
127*56bb7041Schristos        #   undef foo
128*56bb7041Schristos        #   define foo rpl_foo
129*56bb7041Schristos        #  endif
130*56bb7041Schristos        _GL_FUNCDECL_RPL (foo, ...);
131*56bb7041Schristos        _GL_CXXALIAS_RPL (foo, ...);
132*56bb7041Schristos        # else
133*56bb7041Schristos        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
134*56bb7041Schristos        _GL_FUNCDECL_SYS (foo, ...);
135*56bb7041Schristos        #  endif
136*56bb7041Schristos        _GL_CXXALIAS_SYS (foo, ...);
137*56bb7041Schristos        # endif
138*56bb7041Schristos        _GL_CXXALIASWARN (foo);
139*56bb7041Schristos        #elif defined GNULIB_POSIXCHECK
140*56bb7041Schristos        ...
141*56bb7041Schristos        #endif
142*56bb7041Schristos */
143*56bb7041Schristos 
144*56bb7041Schristos /* _GL_EXTERN_C declaration;
145*56bb7041Schristos    performs the declaration with C linkage.  */
146*56bb7041Schristos #if defined __cplusplus
147*56bb7041Schristos # define _GL_EXTERN_C extern "C"
148*56bb7041Schristos #else
149*56bb7041Schristos # define _GL_EXTERN_C extern
150*56bb7041Schristos #endif
151*56bb7041Schristos 
152*56bb7041Schristos /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
153*56bb7041Schristos    declares a replacement function, named rpl_func, with the given prototype,
154*56bb7041Schristos    consisting of return type, parameters, and attributes.
155*56bb7041Schristos    Example:
156*56bb7041Schristos      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
157*56bb7041Schristos                                   _GL_ARG_NONNULL ((1)));
158*56bb7041Schristos  */
159*56bb7041Schristos #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
160*56bb7041Schristos   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
161*56bb7041Schristos #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
162*56bb7041Schristos   _GL_EXTERN_C rettype rpl_func parameters_and_attributes
163*56bb7041Schristos 
164*56bb7041Schristos /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
165*56bb7041Schristos    declares the system function, named func, with the given prototype,
166*56bb7041Schristos    consisting of return type, parameters, and attributes.
167*56bb7041Schristos    Example:
168*56bb7041Schristos      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
169*56bb7041Schristos                                   _GL_ARG_NONNULL ((1)));
170*56bb7041Schristos  */
171*56bb7041Schristos #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
172*56bb7041Schristos   _GL_EXTERN_C rettype func parameters_and_attributes
173*56bb7041Schristos 
174*56bb7041Schristos /* _GL_CXXALIAS_RPL (func, rettype, parameters);
175*56bb7041Schristos    declares a C++ alias called GNULIB_NAMESPACE::func
176*56bb7041Schristos    that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
177*56bb7041Schristos    Example:
178*56bb7041Schristos      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
179*56bb7041Schristos 
180*56bb7041Schristos    Wrapping rpl_func in an object with an inline conversion operator
181*56bb7041Schristos    avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
182*56bb7041Schristos    actually used in the program.  */
183*56bb7041Schristos #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
184*56bb7041Schristos   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
185*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
186*56bb7041Schristos # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
187*56bb7041Schristos     namespace GNULIB_NAMESPACE                                \
188*56bb7041Schristos     {                                                         \
189*56bb7041Schristos       static const struct _gl_ ## func ## _wrapper            \
190*56bb7041Schristos       {                                                       \
191*56bb7041Schristos         typedef rettype (*type) parameters;                   \
192*56bb7041Schristos                                                               \
193*56bb7041Schristos         inline operator type () const                         \
194*56bb7041Schristos         {                                                     \
195*56bb7041Schristos           return ::rpl_func;                                  \
196*56bb7041Schristos         }                                                     \
197*56bb7041Schristos       } func = {};                                            \
198*56bb7041Schristos     }                                                         \
199*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
200*56bb7041Schristos #else
201*56bb7041Schristos # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
202*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
203*56bb7041Schristos #endif
204*56bb7041Schristos 
205*56bb7041Schristos /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
206*56bb7041Schristos    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
207*56bb7041Schristos    except that the C function rpl_func may have a slightly different
208*56bb7041Schristos    declaration.  A cast is used to silence the "invalid conversion" error
209*56bb7041Schristos    that would otherwise occur.  */
210*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
211*56bb7041Schristos # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
212*56bb7041Schristos     namespace GNULIB_NAMESPACE                                     \
213*56bb7041Schristos     {                                                              \
214*56bb7041Schristos       static const struct _gl_ ## func ## _wrapper                 \
215*56bb7041Schristos       {                                                            \
216*56bb7041Schristos         typedef rettype (*type) parameters;                        \
217*56bb7041Schristos                                                                    \
218*56bb7041Schristos         inline operator type () const                              \
219*56bb7041Schristos         {                                                          \
220*56bb7041Schristos           return reinterpret_cast<type>(::rpl_func);               \
221*56bb7041Schristos         }                                                          \
222*56bb7041Schristos       } func = {};                                                 \
223*56bb7041Schristos     }                                                              \
224*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
225*56bb7041Schristos #else
226*56bb7041Schristos # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
227*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
228*56bb7041Schristos #endif
229*56bb7041Schristos 
230*56bb7041Schristos /* _GL_CXXALIAS_SYS (func, rettype, parameters);
231*56bb7041Schristos    declares a C++ alias called GNULIB_NAMESPACE::func
232*56bb7041Schristos    that redirects to the system provided function func, if GNULIB_NAMESPACE
233*56bb7041Schristos    is defined.
234*56bb7041Schristos    Example:
235*56bb7041Schristos      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
236*56bb7041Schristos 
237*56bb7041Schristos    Wrapping func in an object with an inline conversion operator
238*56bb7041Schristos    avoids a reference to func unless GNULIB_NAMESPACE::func is
239*56bb7041Schristos    actually used in the program.  */
240*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
241*56bb7041Schristos # define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
242*56bb7041Schristos     namespace GNULIB_NAMESPACE                                \
243*56bb7041Schristos     {                                                         \
244*56bb7041Schristos       static const struct _gl_ ## func ## _wrapper            \
245*56bb7041Schristos       {                                                       \
246*56bb7041Schristos         typedef rettype (*type) parameters;                   \
247*56bb7041Schristos                                                               \
248*56bb7041Schristos         inline operator type () const                         \
249*56bb7041Schristos         {                                                     \
250*56bb7041Schristos           return ::func;                                      \
251*56bb7041Schristos         }                                                     \
252*56bb7041Schristos       } func = {};                                            \
253*56bb7041Schristos     }                                                         \
254*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
255*56bb7041Schristos #else
256*56bb7041Schristos # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
257*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
258*56bb7041Schristos #endif
259*56bb7041Schristos 
260*56bb7041Schristos /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
261*56bb7041Schristos    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
262*56bb7041Schristos    except that the C function func may have a slightly different declaration.
263*56bb7041Schristos    A cast is used to silence the "invalid conversion" error that would
264*56bb7041Schristos    otherwise occur.  */
265*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
266*56bb7041Schristos # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
267*56bb7041Schristos     namespace GNULIB_NAMESPACE                          \
268*56bb7041Schristos     {                                                   \
269*56bb7041Schristos       static const struct _gl_ ## func ## _wrapper      \
270*56bb7041Schristos       {                                                 \
271*56bb7041Schristos         typedef rettype (*type) parameters;             \
272*56bb7041Schristos                                                         \
273*56bb7041Schristos         inline operator type () const                   \
274*56bb7041Schristos         {                                               \
275*56bb7041Schristos           return reinterpret_cast<type>(::func);        \
276*56bb7041Schristos         }                                               \
277*56bb7041Schristos       } func = {};                                      \
278*56bb7041Schristos     }                                                   \
279*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
280*56bb7041Schristos #else
281*56bb7041Schristos # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
282*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
283*56bb7041Schristos #endif
284*56bb7041Schristos 
285*56bb7041Schristos /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
286*56bb7041Schristos    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
287*56bb7041Schristos    except that the C function is picked among a set of overloaded functions,
288*56bb7041Schristos    namely the one with rettype2 and parameters2.  Two consecutive casts
289*56bb7041Schristos    are used to silence the "cannot find a match" and "invalid conversion"
290*56bb7041Schristos    errors that would otherwise occur.  */
291*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
292*56bb7041Schristos   /* The outer cast must be a reinterpret_cast.
293*56bb7041Schristos      The inner cast: When the function is defined as a set of overloaded
294*56bb7041Schristos      functions, it works as a static_cast<>, choosing the designated variant.
295*56bb7041Schristos      When the function is defined as a single variant, it works as a
296*56bb7041Schristos      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
297*56bb7041Schristos # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
298*56bb7041Schristos     namespace GNULIB_NAMESPACE                                                \
299*56bb7041Schristos     {                                                                         \
300*56bb7041Schristos       static const struct _gl_ ## func ## _wrapper                            \
301*56bb7041Schristos       {                                                                       \
302*56bb7041Schristos         typedef rettype (*type) parameters;                                   \
303*56bb7041Schristos                                                                               \
304*56bb7041Schristos         inline operator type () const                                         \
305*56bb7041Schristos         {                                                                     \
306*56bb7041Schristos           return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
307*56bb7041Schristos         }                                                                     \
308*56bb7041Schristos       } func = {};                                                            \
309*56bb7041Schristos     }                                                                         \
310*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
311*56bb7041Schristos #else
312*56bb7041Schristos # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
313*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
314*56bb7041Schristos #endif
315*56bb7041Schristos 
316*56bb7041Schristos /* _GL_CXXALIASWARN (func);
317*56bb7041Schristos    causes a warning to be emitted when ::func is used but not when
318*56bb7041Schristos    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
319*56bb7041Schristos    variants.  */
320*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
321*56bb7041Schristos # define _GL_CXXALIASWARN(func) \
322*56bb7041Schristos    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
323*56bb7041Schristos # define _GL_CXXALIASWARN_1(func,namespace) \
324*56bb7041Schristos    _GL_CXXALIASWARN_2 (func, namespace)
325*56bb7041Schristos /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
326*56bb7041Schristos    we enable the warning only when not optimizing.  */
327*56bb7041Schristos # if !__OPTIMIZE__
328*56bb7041Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
329*56bb7041Schristos     _GL_WARN_ON_USE (func, \
330*56bb7041Schristos                      "The symbol ::" #func " refers to the system function. " \
331*56bb7041Schristos                      "Use " #namespace "::" #func " instead.")
332*56bb7041Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
333*56bb7041Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
334*56bb7041Schristos      extern __typeof__ (func) func
335*56bb7041Schristos # else
336*56bb7041Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
337*56bb7041Schristos      _GL_EXTERN_C int _gl_cxxalias_dummy
338*56bb7041Schristos # endif
339*56bb7041Schristos #else
340*56bb7041Schristos # define _GL_CXXALIASWARN(func) \
341*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
342*56bb7041Schristos #endif
343*56bb7041Schristos 
344*56bb7041Schristos /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
345*56bb7041Schristos    causes a warning to be emitted when the given overloaded variant of ::func
346*56bb7041Schristos    is used but not when GNULIB_NAMESPACE::func is used.  */
347*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
348*56bb7041Schristos # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
349*56bb7041Schristos    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
350*56bb7041Schristos                         GNULIB_NAMESPACE)
351*56bb7041Schristos # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
352*56bb7041Schristos    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
353*56bb7041Schristos /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
354*56bb7041Schristos    we enable the warning only when not optimizing.  */
355*56bb7041Schristos # if !__OPTIMIZE__
356*56bb7041Schristos #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
357*56bb7041Schristos     _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
358*56bb7041Schristos                          "The symbol ::" #func " refers to the system function. " \
359*56bb7041Schristos                          "Use " #namespace "::" #func " instead.")
360*56bb7041Schristos # else
361*56bb7041Schristos #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
362*56bb7041Schristos      _GL_EXTERN_C int _gl_cxxalias_dummy
363*56bb7041Schristos # endif
364*56bb7041Schristos #else
365*56bb7041Schristos # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
366*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
367*56bb7041Schristos #endif
368*56bb7041Schristos 
369*56bb7041Schristos #endif /* _GL_CXXDEFS_H */
370*56bb7041Schristos 
371*56bb7041Schristos /* The definition of _GL_ARG_NONNULL is copied here.  */
372*56bb7041Schristos /* A C macro for declaring that specific arguments must not be NULL.
373*56bb7041Schristos    Copyright (C) 2009-2020 Free Software Foundation, Inc.
374*56bb7041Schristos 
375*56bb7041Schristos    This program is free software: you can redistribute it and/or modify it
376*56bb7041Schristos    under the terms of the GNU General Public License as published
377*56bb7041Schristos    by the Free Software Foundation; either version 3 of the License, or
378*56bb7041Schristos    (at your option) any later version.
379*56bb7041Schristos 
380*56bb7041Schristos    This program is distributed in the hope that it will be useful,
381*56bb7041Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
382*56bb7041Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
383*56bb7041Schristos    General Public License for more details.
384*56bb7041Schristos 
385*56bb7041Schristos    You should have received a copy of the GNU General Public License
386*56bb7041Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
387*56bb7041Schristos 
388*56bb7041Schristos /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
389*56bb7041Schristos    that the values passed as arguments n, ..., m must be non-NULL pointers.
390*56bb7041Schristos    n = 1 stands for the first argument, n = 2 for the second argument etc.  */
391*56bb7041Schristos #ifndef _GL_ARG_NONNULL
392*56bb7041Schristos # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
393*56bb7041Schristos #  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
394*56bb7041Schristos # else
395*56bb7041Schristos #  define _GL_ARG_NONNULL(params)
396*56bb7041Schristos # endif
397*56bb7041Schristos #endif
398*56bb7041Schristos 
399*56bb7041Schristos /* The definition of _GL_WARN_ON_USE is copied here.  */
400*56bb7041Schristos /* A C macro for emitting warnings if a function is used.
401*56bb7041Schristos    Copyright (C) 2010-2020 Free Software Foundation, Inc.
402*56bb7041Schristos 
403*56bb7041Schristos    This program is free software: you can redistribute it and/or modify it
404*56bb7041Schristos    under the terms of the GNU General Public License as published
405*56bb7041Schristos    by the Free Software Foundation; either version 3 of the License, or
406*56bb7041Schristos    (at your option) any later version.
407*56bb7041Schristos 
408*56bb7041Schristos    This program is distributed in the hope that it will be useful,
409*56bb7041Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
410*56bb7041Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
411*56bb7041Schristos    General Public License for more details.
412*56bb7041Schristos 
413*56bb7041Schristos    You should have received a copy of the GNU General Public License
414*56bb7041Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
415*56bb7041Schristos 
416*56bb7041Schristos /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
417*56bb7041Schristos    for FUNCTION which will then trigger a compiler warning containing
418*56bb7041Schristos    the text of "literal string" anywhere that function is called, if
419*56bb7041Schristos    supported by the compiler.  If the compiler does not support this
420*56bb7041Schristos    feature, the macro expands to an unused extern declaration.
421*56bb7041Schristos 
422*56bb7041Schristos    _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
423*56bb7041Schristos    attribute used in _GL_WARN_ON_USE.  If the compiler does not support
424*56bb7041Schristos    this feature, it expands to empty.
425*56bb7041Schristos 
426*56bb7041Schristos    These macros are useful for marking a function as a potential
427*56bb7041Schristos    portability trap, with the intent that "literal string" include
428*56bb7041Schristos    instructions on the replacement function that should be used
429*56bb7041Schristos    instead.
430*56bb7041Schristos    _GL_WARN_ON_USE is for functions with 'extern' linkage.
431*56bb7041Schristos    _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
432*56bb7041Schristos    linkage.
433*56bb7041Schristos 
434*56bb7041Schristos    However, one of the reasons that a function is a portability trap is
435*56bb7041Schristos    if it has the wrong signature.  Declaring FUNCTION with a different
436*56bb7041Schristos    signature in C is a compilation error, so this macro must use the
437*56bb7041Schristos    same type as any existing declaration so that programs that avoid
438*56bb7041Schristos    the problematic FUNCTION do not fail to compile merely because they
439*56bb7041Schristos    included a header that poisoned the function.  But this implies that
440*56bb7041Schristos    _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
441*56bb7041Schristos    have a declaration.  Use of this macro implies that there must not
442*56bb7041Schristos    be any other macro hiding the declaration of FUNCTION; but
443*56bb7041Schristos    undefining FUNCTION first is part of the poisoning process anyway
444*56bb7041Schristos    (although for symbols that are provided only via a macro, the result
445*56bb7041Schristos    is a compilation error rather than a warning containing
446*56bb7041Schristos    "literal string").  Also note that in C++, it is only safe to use if
447*56bb7041Schristos    FUNCTION has no overloads.
448*56bb7041Schristos 
449*56bb7041Schristos    For an example, it is possible to poison 'getline' by:
450*56bb7041Schristos    - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
451*56bb7041Schristos      [getline]) in configure.ac, which potentially defines
452*56bb7041Schristos      HAVE_RAW_DECL_GETLINE
453*56bb7041Schristos    - adding this code to a header that wraps the system <stdio.h>:
454*56bb7041Schristos      #undef getline
455*56bb7041Schristos      #if HAVE_RAW_DECL_GETLINE
456*56bb7041Schristos      _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
457*56bb7041Schristos        "not universally present; use the gnulib module getline");
458*56bb7041Schristos      #endif
459*56bb7041Schristos 
460*56bb7041Schristos    It is not possible to directly poison global variables.  But it is
461*56bb7041Schristos    possible to write a wrapper accessor function, and poison that
462*56bb7041Schristos    (less common usage, like &environ, will cause a compilation error
463*56bb7041Schristos    rather than issue the nice warning, but the end result of informing
464*56bb7041Schristos    the developer about their portability problem is still achieved):
465*56bb7041Schristos      #if HAVE_RAW_DECL_ENVIRON
466*56bb7041Schristos      static char ***
467*56bb7041Schristos      rpl_environ (void) { return &environ; }
468*56bb7041Schristos      _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
469*56bb7041Schristos      # undef environ
470*56bb7041Schristos      # define environ (*rpl_environ ())
471*56bb7041Schristos      #endif
472*56bb7041Schristos    or better (avoiding contradictory use of 'static' and 'extern'):
473*56bb7041Schristos      #if HAVE_RAW_DECL_ENVIRON
474*56bb7041Schristos      static char ***
475*56bb7041Schristos      _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
476*56bb7041Schristos      rpl_environ (void) { return &environ; }
477*56bb7041Schristos      # undef environ
478*56bb7041Schristos      # define environ (*rpl_environ ())
479*56bb7041Schristos      #endif
480*56bb7041Schristos    */
481*56bb7041Schristos #ifndef _GL_WARN_ON_USE
482*56bb7041Schristos 
483*56bb7041Schristos # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
484*56bb7041Schristos /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
485*56bb7041Schristos #  define _GL_WARN_ON_USE(function, message) \
486*56bb7041Schristos extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
487*56bb7041Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
488*56bb7041Schristos   __attribute__ ((__warning__ (message)))
489*56bb7041Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
490*56bb7041Schristos /* Verify the existence of the function.  */
491*56bb7041Schristos #  define _GL_WARN_ON_USE(function, message) \
492*56bb7041Schristos extern __typeof__ (function) function
493*56bb7041Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
494*56bb7041Schristos # else /* Unsupported.  */
495*56bb7041Schristos #  define _GL_WARN_ON_USE(function, message) \
496*56bb7041Schristos _GL_WARN_EXTERN_C int _gl_warn_on_use
497*56bb7041Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
498*56bb7041Schristos # endif
499*56bb7041Schristos #endif
500*56bb7041Schristos 
501*56bb7041Schristos /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
502*56bb7041Schristos    is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the
503*56bb7041Schristos    function is declared with the given prototype, consisting of return type,
504*56bb7041Schristos    parameters, and attributes.
505*56bb7041Schristos    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
506*56bb7041Schristos    not work in this case.  */
507*56bb7041Schristos #ifndef _GL_WARN_ON_USE_CXX
508*56bb7041Schristos # if !defined __cplusplus
509*56bb7041Schristos #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
510*56bb7041Schristos      _GL_WARN_ON_USE (function, msg)
511*56bb7041Schristos # else
512*56bb7041Schristos #  if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
513*56bb7041Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
514*56bb7041Schristos extern rettype function parameters_and_attributes \
515*56bb7041Schristos      __attribute__ ((__warning__ (msg)))
516*56bb7041Schristos #  elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
517*56bb7041Schristos /* Verify the existence of the function.  */
518*56bb7041Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
519*56bb7041Schristos extern rettype function parameters_and_attributes
520*56bb7041Schristos #  else /* Unsupported.  */
521*56bb7041Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
522*56bb7041Schristos _GL_WARN_EXTERN_C int _gl_warn_on_use
523*56bb7041Schristos #  endif
524*56bb7041Schristos # endif
525*56bb7041Schristos #endif
526*56bb7041Schristos 
527*56bb7041Schristos /* _GL_WARN_EXTERN_C declaration;
528*56bb7041Schristos    performs the declaration with C linkage.  */
529*56bb7041Schristos #ifndef _GL_WARN_EXTERN_C
530*56bb7041Schristos # if defined __cplusplus
531*56bb7041Schristos #  define _GL_WARN_EXTERN_C extern "C"
532*56bb7041Schristos # else
533*56bb7041Schristos #  define _GL_WARN_EXTERN_C extern
534*56bb7041Schristos # endif
535*56bb7041Schristos #endif
536*56bb7041Schristos 
537*56bb7041Schristos /* Some systems don't define struct timespec (e.g., AIX 4.1).
538*56bb7041Schristos    Or they define it with the wrong member names or define it in <sys/time.h>
539*56bb7041Schristos    (e.g., FreeBSD circa 1997).  Stock Mingw prior to 3.0 does not define it,
540*56bb7041Schristos    but the pthreads-win32 library defines it in <pthread.h>.  */
541*56bb7041Schristos # if ! 1
542*56bb7041Schristos #  if 0
543*56bb7041Schristos #   include <sys/time.h>
544*56bb7041Schristos #  elif 0
545*56bb7041Schristos #   include <pthread.h>
546*56bb7041Schristos #  elif 0
547*56bb7041Schristos #   include <unistd.h>
548*56bb7041Schristos #  else
549*56bb7041Schristos 
550*56bb7041Schristos #   ifdef __cplusplus
551*56bb7041Schristos extern "C" {
552*56bb7041Schristos #   endif
553*56bb7041Schristos 
554*56bb7041Schristos #   if !GNULIB_defined_struct_timespec
555*56bb7041Schristos #    undef timespec
556*56bb7041Schristos #    define timespec rpl_timespec
557*56bb7041Schristos struct timespec
558*56bb7041Schristos {
559*56bb7041Schristos   time_t tv_sec;
560*56bb7041Schristos   long int tv_nsec;
561*56bb7041Schristos };
562*56bb7041Schristos #    define GNULIB_defined_struct_timespec 1
563*56bb7041Schristos #   endif
564*56bb7041Schristos 
565*56bb7041Schristos #   ifdef __cplusplus
566*56bb7041Schristos }
567*56bb7041Schristos #   endif
568*56bb7041Schristos 
569*56bb7041Schristos #  endif
570*56bb7041Schristos # endif
571*56bb7041Schristos 
572*56bb7041Schristos # if !GNULIB_defined_struct_time_t_must_be_integral
573*56bb7041Schristos /* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
574*56bb7041Schristos    requires time_t to be an integer type, even though C99 permits floating
575*56bb7041Schristos    point.  We don't know of any implementation that uses floating
576*56bb7041Schristos    point, and it is much easier to write code that doesn't have to
577*56bb7041Schristos    worry about that corner case, so we force the issue.  */
578*56bb7041Schristos struct __time_t_must_be_integral {
579*56bb7041Schristos   unsigned int __floating_time_t_unsupported : (time_t) 1;
580*56bb7041Schristos };
581*56bb7041Schristos #  define GNULIB_defined_struct_time_t_must_be_integral 1
582*56bb7041Schristos # endif
583*56bb7041Schristos 
584*56bb7041Schristos /* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
585*56bb7041Schristos    return -1 and store the remaining time into RMTP.  See
586*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html>.  */
587*56bb7041Schristos # if 0
588*56bb7041Schristos #  if GNULIB_PORTCHECK
589*56bb7041Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
590*56bb7041Schristos #    define nanosleep rpl_nanosleep
591*56bb7041Schristos #   endif
592*56bb7041Schristos _GL_FUNCDECL_RPL (nanosleep, int,
593*56bb7041Schristos                   (struct timespec const *__rqtp, struct timespec *__rmtp)
594*56bb7041Schristos                   _GL_ARG_NONNULL ((1)));
595*56bb7041Schristos _GL_CXXALIAS_RPL (nanosleep, int,
596*56bb7041Schristos                   (struct timespec const *__rqtp, struct timespec *__rmtp));
597*56bb7041Schristos #  else
598*56bb7041Schristos #   if ! 1
599*56bb7041Schristos _GL_FUNCDECL_SYS (nanosleep, int,
600*56bb7041Schristos                   (struct timespec const *__rqtp, struct timespec *__rmtp)
601*56bb7041Schristos                   _GL_ARG_NONNULL ((1)));
602*56bb7041Schristos #   endif
603*56bb7041Schristos _GL_CXXALIAS_SYS (nanosleep, int,
604*56bb7041Schristos                   (struct timespec const *__rqtp, struct timespec *__rmtp));
605*56bb7041Schristos #  endif
606*56bb7041Schristos _GL_CXXALIASWARN (nanosleep);
607*56bb7041Schristos # endif
608*56bb7041Schristos 
609*56bb7041Schristos /* Initialize time conversion information.  */
610*56bb7041Schristos # if 0
611*56bb7041Schristos #  if GNULIB_PORTCHECK
612*56bb7041Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
613*56bb7041Schristos #    undef tzset
614*56bb7041Schristos #    define tzset rpl_tzset
615*56bb7041Schristos #   endif
616*56bb7041Schristos _GL_FUNCDECL_RPL (tzset, void, (void));
617*56bb7041Schristos _GL_CXXALIAS_RPL (tzset, void, (void));
618*56bb7041Schristos #  else
619*56bb7041Schristos #   if ! 1
620*56bb7041Schristos _GL_FUNCDECL_SYS (tzset, void, (void));
621*56bb7041Schristos #   endif
622*56bb7041Schristos _GL_CXXALIAS_SYS (tzset, void, (void));
623*56bb7041Schristos #  endif
624*56bb7041Schristos _GL_CXXALIASWARN (tzset);
625*56bb7041Schristos # endif
626*56bb7041Schristos 
627*56bb7041Schristos /* Return the 'time_t' representation of TP and normalize TP.  */
628*56bb7041Schristos # if 0
629*56bb7041Schristos #  if GNULIB_PORTCHECK
630*56bb7041Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
631*56bb7041Schristos #    define mktime rpl_mktime
632*56bb7041Schristos #   endif
633*56bb7041Schristos _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
634*56bb7041Schristos _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
635*56bb7041Schristos #  else
636*56bb7041Schristos _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
637*56bb7041Schristos #  endif
638*56bb7041Schristos #  if __GLIBC__ >= 2
639*56bb7041Schristos _GL_CXXALIASWARN (mktime);
640*56bb7041Schristos #  endif
641*56bb7041Schristos # endif
642*56bb7041Schristos 
643*56bb7041Schristos /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
644*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime_r.html> and
645*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime_r.html>.  */
646*56bb7041Schristos # if 1
647*56bb7041Schristos #  if 0
648*56bb7041Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
649*56bb7041Schristos #    undef localtime_r
650*56bb7041Schristos #    define localtime_r rpl_localtime_r
651*56bb7041Schristos #   endif
652*56bb7041Schristos _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
653*56bb7041Schristos                                              struct tm *restrict __result)
654*56bb7041Schristos                                             _GL_ARG_NONNULL ((1, 2)));
655*56bb7041Schristos _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
656*56bb7041Schristos                                              struct tm *restrict __result));
657*56bb7041Schristos #  else
658*56bb7041Schristos #   if ! 1
659*56bb7041Schristos _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
660*56bb7041Schristos                                              struct tm *restrict __result)
661*56bb7041Schristos                                             _GL_ARG_NONNULL ((1, 2)));
662*56bb7041Schristos #   endif
663*56bb7041Schristos _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
664*56bb7041Schristos                                              struct tm *restrict __result));
665*56bb7041Schristos #  endif
666*56bb7041Schristos #  if 1
667*56bb7041Schristos _GL_CXXALIASWARN (localtime_r);
668*56bb7041Schristos #  endif
669*56bb7041Schristos #  if 0
670*56bb7041Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
671*56bb7041Schristos #    undef gmtime_r
672*56bb7041Schristos #    define gmtime_r rpl_gmtime_r
673*56bb7041Schristos #   endif
674*56bb7041Schristos _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
675*56bb7041Schristos                                           struct tm *restrict __result)
676*56bb7041Schristos                                          _GL_ARG_NONNULL ((1, 2)));
677*56bb7041Schristos _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
678*56bb7041Schristos                                           struct tm *restrict __result));
679*56bb7041Schristos #  else
680*56bb7041Schristos #   if ! 1
681*56bb7041Schristos _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
682*56bb7041Schristos                                           struct tm *restrict __result)
683*56bb7041Schristos                                          _GL_ARG_NONNULL ((1, 2)));
684*56bb7041Schristos #   endif
685*56bb7041Schristos _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
686*56bb7041Schristos                                           struct tm *restrict __result));
687*56bb7041Schristos #  endif
688*56bb7041Schristos #  if 1
689*56bb7041Schristos _GL_CXXALIASWARN (gmtime_r);
690*56bb7041Schristos #  endif
691*56bb7041Schristos # endif
692*56bb7041Schristos 
693*56bb7041Schristos /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
694*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime.html> and
695*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html>.  */
696*56bb7041Schristos # if 0 || 0
697*56bb7041Schristos #  if 0
698*56bb7041Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
699*56bb7041Schristos #    undef localtime
700*56bb7041Schristos #    define localtime rpl_localtime
701*56bb7041Schristos #   endif
702*56bb7041Schristos _GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
703*56bb7041Schristos                                           _GL_ARG_NONNULL ((1)));
704*56bb7041Schristos _GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
705*56bb7041Schristos #  else
706*56bb7041Schristos _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
707*56bb7041Schristos #  endif
708*56bb7041Schristos #  if __GLIBC__ >= 2
709*56bb7041Schristos _GL_CXXALIASWARN (localtime);
710*56bb7041Schristos #  endif
711*56bb7041Schristos # endif
712*56bb7041Schristos 
713*56bb7041Schristos # if 0 || 0
714*56bb7041Schristos #  if 0
715*56bb7041Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
716*56bb7041Schristos #    undef gmtime
717*56bb7041Schristos #    define gmtime rpl_gmtime
718*56bb7041Schristos #   endif
719*56bb7041Schristos _GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
720*56bb7041Schristos                                        _GL_ARG_NONNULL ((1)));
721*56bb7041Schristos _GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
722*56bb7041Schristos #  else
723*56bb7041Schristos _GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
724*56bb7041Schristos #  endif
725*56bb7041Schristos _GL_CXXALIASWARN (gmtime);
726*56bb7041Schristos # endif
727*56bb7041Schristos 
728*56bb7041Schristos /* Parse BUF as a timestamp, assuming FORMAT specifies its layout, and store
729*56bb7041Schristos    the resulting broken-down time into TM.  See
730*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html>.  */
731*56bb7041Schristos # if 0
732*56bb7041Schristos #  if ! 1
733*56bb7041Schristos _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
734*56bb7041Schristos                                      char const *restrict __format,
735*56bb7041Schristos                                      struct tm *restrict __tm)
736*56bb7041Schristos                                     _GL_ARG_NONNULL ((1, 2, 3)));
737*56bb7041Schristos #  endif
738*56bb7041Schristos _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
739*56bb7041Schristos                                      char const *restrict __format,
740*56bb7041Schristos                                      struct tm *restrict __tm));
741*56bb7041Schristos _GL_CXXALIASWARN (strptime);
742*56bb7041Schristos # endif
743*56bb7041Schristos 
744*56bb7041Schristos /* Convert *TP to a date and time string.  See
745*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>.  */
746*56bb7041Schristos # if 0
747*56bb7041Schristos #  if GNULIB_PORTCHECK
748*56bb7041Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
749*56bb7041Schristos #    define ctime rpl_ctime
750*56bb7041Schristos #   endif
751*56bb7041Schristos _GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
752*56bb7041Schristos                                  _GL_ARG_NONNULL ((1)));
753*56bb7041Schristos _GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
754*56bb7041Schristos #  else
755*56bb7041Schristos _GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
756*56bb7041Schristos #  endif
757*56bb7041Schristos #  if __GLIBC__ >= 2
758*56bb7041Schristos _GL_CXXALIASWARN (ctime);
759*56bb7041Schristos #  endif
760*56bb7041Schristos # endif
761*56bb7041Schristos 
762*56bb7041Schristos /* Convert *TP to a date and time string.  See
763*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>.  */
764*56bb7041Schristos # if 0
765*56bb7041Schristos #  if GNULIB_PORTCHECK
766*56bb7041Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
767*56bb7041Schristos #    define strftime rpl_strftime
768*56bb7041Schristos #   endif
769*56bb7041Schristos _GL_FUNCDECL_RPL (strftime, size_t,
770*56bb7041Schristos                   (char *restrict __buf, size_t __bufsize,
771*56bb7041Schristos                    const char *restrict __fmt, const struct tm *restrict __tp)
772*56bb7041Schristos                   _GL_ARG_NONNULL ((1, 3, 4)));
773*56bb7041Schristos _GL_CXXALIAS_RPL (strftime, size_t,
774*56bb7041Schristos                   (char *restrict __buf, size_t __bufsize,
775*56bb7041Schristos                    const char *restrict __fmt, const struct tm *restrict __tp));
776*56bb7041Schristos #  else
777*56bb7041Schristos _GL_CXXALIAS_SYS (strftime, size_t,
778*56bb7041Schristos                   (char *restrict __buf, size_t __bufsize,
779*56bb7041Schristos                    const char *restrict __fmt, const struct tm *restrict __tp));
780*56bb7041Schristos #  endif
781*56bb7041Schristos #  if __GLIBC__ >= 2
782*56bb7041Schristos _GL_CXXALIASWARN (strftime);
783*56bb7041Schristos #  endif
784*56bb7041Schristos # endif
785*56bb7041Schristos 
786*56bb7041Schristos # if defined _GNU_SOURCE && 0 && ! 0
787*56bb7041Schristos typedef struct tm_zone *timezone_t;
788*56bb7041Schristos _GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
789*56bb7041Schristos _GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
790*56bb7041Schristos _GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz));
791*56bb7041Schristos _GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
792*56bb7041Schristos _GL_FUNCDECL_SYS (localtime_rz, struct tm *,
793*56bb7041Schristos                   (timezone_t __tz, time_t const *restrict __timer,
794*56bb7041Schristos                    struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3)));
795*56bb7041Schristos _GL_CXXALIAS_SYS (localtime_rz, struct tm *,
796*56bb7041Schristos                   (timezone_t __tz, time_t const *restrict __timer,
797*56bb7041Schristos                    struct tm *restrict __result));
798*56bb7041Schristos _GL_FUNCDECL_SYS (mktime_z, time_t,
799*56bb7041Schristos                   (timezone_t __tz, struct tm *restrict __result)
800*56bb7041Schristos                   _GL_ARG_NONNULL ((2)));
801*56bb7041Schristos _GL_CXXALIAS_SYS (mktime_z, time_t,
802*56bb7041Schristos                   (timezone_t __tz, struct tm *restrict __result));
803*56bb7041Schristos # endif
804*56bb7041Schristos 
805*56bb7041Schristos /* Convert TM to a time_t value, assuming UTC.  */
806*56bb7041Schristos # if 0
807*56bb7041Schristos #  if GNULIB_PORTCHECK
808*56bb7041Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
809*56bb7041Schristos #    undef timegm
810*56bb7041Schristos #    define timegm rpl_timegm
811*56bb7041Schristos #   endif
812*56bb7041Schristos _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
813*56bb7041Schristos _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
814*56bb7041Schristos #  else
815*56bb7041Schristos #   if ! 1
816*56bb7041Schristos _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
817*56bb7041Schristos #   endif
818*56bb7041Schristos _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
819*56bb7041Schristos #  endif
820*56bb7041Schristos _GL_CXXALIASWARN (timegm);
821*56bb7041Schristos # endif
822*56bb7041Schristos 
823*56bb7041Schristos /* Encourage applications to avoid unsafe functions that can overrun
824*56bb7041Schristos    buffers when given outlandish struct tm values.  Portable
825*56bb7041Schristos    applications should use strftime (or even sprintf) instead.  */
826*56bb7041Schristos # if defined GNULIB_POSIXCHECK
827*56bb7041Schristos #  undef asctime
828*56bb7041Schristos _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
829*56bb7041Schristos                  "better use strftime (or even sprintf) instead");
830*56bb7041Schristos # endif
831*56bb7041Schristos # if defined GNULIB_POSIXCHECK
832*56bb7041Schristos #  undef asctime_r
833*56bb7041Schristos _GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
834*56bb7041Schristos                  "better use strftime (or even sprintf) instead");
835*56bb7041Schristos # endif
836*56bb7041Schristos # if defined GNULIB_POSIXCHECK
837*56bb7041Schristos #  undef ctime
838*56bb7041Schristos _GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
839*56bb7041Schristos                  "better use strftime (or even sprintf) instead");
840*56bb7041Schristos # endif
841*56bb7041Schristos # if defined GNULIB_POSIXCHECK
842*56bb7041Schristos #  undef ctime_r
843*56bb7041Schristos _GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
844*56bb7041Schristos                  "better use strftime (or even sprintf) instead");
845*56bb7041Schristos # endif
846*56bb7041Schristos 
847*56bb7041Schristos #endif
848