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