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