1139804Simp/* This file is automatically generated. DO NOT EDIT! */ 21541Srgrimes/* Generated from: NetBSD: mknative-gdb,v 1.16 2023/07/31 17:09:59 christos Exp */ 31541Srgrimes/* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp */ 41541Srgrimes 51541Srgrimes/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 61541Srgrimes/* A POSIX <locale.h>. 71541Srgrimes Copyright (C) 2007-2022 Free Software Foundation, Inc. 81541Srgrimes 91541Srgrimes This file is free software: you can redistribute it and/or modify 101541Srgrimes it under the terms of the GNU Lesser General Public License as 111541Srgrimes published by the Free Software Foundation; either version 2.1 of the 121541Srgrimes License, or (at your option) any later version. 131541Srgrimes 141541Srgrimes This file is distributed in the hope that it will be useful, 151541Srgrimes but WITHOUT ANY WARRANTY; without even the implied warranty of 161541Srgrimes MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 171541Srgrimes GNU Lesser General Public License for more details. 181541Srgrimes 191541Srgrimes You should have received a copy of the GNU Lesser General Public License 201541Srgrimes along with this program. If not, see <https://www.gnu.org/licenses/>. */ 211541Srgrimes 221541Srgrimes#if __GNUC__ >= 3 231541Srgrimes#pragma GCC system_header 241541Srgrimes#endif 251541Srgrimes 261541Srgrimes 271541Srgrimes#if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \ 281541Srgrimes || defined _GL_ALREADY_INCLUDING_LOCALE_H 291541Srgrimes 301541Srgrimes/* Special invocation convention: 311541Srgrimes - Inside mingw header files, 32116182Sobrien - To handle Solaris header files (through Solaris 10) when combined 33116182Sobrien with gettext's libintl.h. */ 34116182Sobrien 3577598Sjesper#include_next <locale.h> 36101013Srwatson 371541Srgrimes#else 3895759Stanimura/* Normal invocation convention. */ 3912041Swollman 4076166Smarkm#ifndef _GL_LOCALE_H 411541Srgrimes 4295759Stanimura#define _GL_ALREADY_INCLUDING_LOCALE_H 4376166Smarkm 441541Srgrimes/* The include_next requires a split double-inclusion guard. */ 4551381Sgreen#include_next <locale.h> 4695759Stanimura 471541Srgrimes#undef _GL_ALREADY_INCLUDING_LOCALE_H 481541Srgrimes 49169236Srwatson#ifndef _GL_LOCALE_H 5012041Swollman#define _GL_LOCALE_H 511541Srgrimes 52160621Srwatson/* NetBSD 5.0 mis-defines NULL. */ 53160621Srwatson#include <stddef.h> 54160621Srwatson 55160621Srwatson/* Mac OS X 10.5 defines the locale_t type in <xlocale.h>. */ 56160621Srwatson#if 0 5788633Salfred# include <xlocale.h> 581541Srgrimes#endif 59160621Srwatson 601541Srgrimes/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 611541Srgrimes/* C++ compatible function declaration macros. 62101996Sdg Copyright (C) 2010-2022 Free Software Foundation, Inc. 63172557Smohans 64172557Smohans This program is free software: you can redistribute it and/or modify it 651541Srgrimes under the terms of the GNU Lesser General Public License as published 6613267Swollman by the Free Software Foundation; either version 2 of the License, or 6713267Swollman (at your option) any later version. 68160915Srwatson 69160915Srwatson This program is distributed in the hope that it will be useful, 70160875Srwatson but WITHOUT ANY WARRANTY; without even the implied warranty of 711541Srgrimes MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 72160915Srwatson Lesser General Public License for more details. 73160915Srwatson 74160915Srwatson You should have received a copy of the GNU Lesser General Public License 75160915Srwatson along with this program. If not, see <https://www.gnu.org/licenses/>. */ 76160915Srwatson 77160915Srwatson#ifndef _GL_CXXDEFS_H 78160915Srwatson#define _GL_CXXDEFS_H 791541Srgrimes 80130831Srwatson/* Begin/end the GNULIB_NAMESPACE namespace. */ 81160915Srwatson#if defined __cplusplus && defined GNULIB_NAMESPACE 82130831Srwatson# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { 831541Srgrimes# define _GL_END_NAMESPACE } 84130831Srwatson#else 85130831Srwatson# define _GL_BEGIN_NAMESPACE 86130831Srwatson# define _GL_END_NAMESPACE 87130831Srwatson#endif 88130831Srwatson 89130831Srwatson/* The three most frequent use cases of these macros are: 90130831Srwatson 911549Srgrimes * For providing a substitute for a function that is missing on some 92160915Srwatson platforms, but is declared and works fine on the platforms on which 931541Srgrimes it exists: 941541Srgrimes 95130831Srwatson #if @GNULIB_FOO@ 96130831Srwatson # if !@HAVE_FOO@ 97130831Srwatson _GL_FUNCDECL_SYS (foo, ...); 981541Srgrimes # endif 991541Srgrimes _GL_CXXALIAS_SYS (foo, ...); 1001549Srgrimes _GL_CXXALIASWARN (foo); 101160915Srwatson #elif defined GNULIB_POSIXCHECK 1021541Srgrimes ... 1031541Srgrimes #endif 104130831Srwatson 105130831Srwatson * For providing a replacement for a function that exists on all platforms, 106130480Srwatson but is broken/insufficient and needs to be replaced on some platforms: 107130831Srwatson 108130831Srwatson #if @GNULIB_FOO@ 1091541Srgrimes # if @REPLACE_FOO@ 1101541Srgrimes # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 111130831Srwatson # undef foo 112160915Srwatson # define foo rpl_foo 113130831Srwatson # endif 114130831Srwatson _GL_FUNCDECL_RPL (foo, ...); 115130831Srwatson _GL_CXXALIAS_RPL (foo, ...); 116130831Srwatson # else 117130831Srwatson _GL_CXXALIAS_SYS (foo, ...); 118130831Srwatson # endif 119130831Srwatson _GL_CXXALIASWARN (foo); 1201541Srgrimes #elif defined GNULIB_POSIXCHECK 1211541Srgrimes ... 1221541Srgrimes #endif 1231549Srgrimes 124160915Srwatson * For providing a replacement for a function that exists on some platforms 1251541Srgrimes but is broken/insufficient and needs to be replaced on some of them and 1261541Srgrimes is additionally either missing or undeclared on some other platforms: 127130705Srwatson 128130705Srwatson #if @GNULIB_FOO@ 1291541Srgrimes # if @REPLACE_FOO@ 130130705Srwatson # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 13112843Sbde # undef foo 1321541Srgrimes # define foo rpl_foo 1331541Srgrimes # endif 1341541Srgrimes _GL_FUNCDECL_RPL (foo, ...); 1351549Srgrimes _GL_CXXALIAS_RPL (foo, ...); 136169236Srwatson # else 1371541Srgrimes # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 1381541Srgrimes _GL_FUNCDECL_SYS (foo, ...); 139175845Srwatson # endif 140175845Srwatson _GL_CXXALIAS_SYS (foo, ...); 141175845Srwatson # endif 142175845Srwatson _GL_CXXALIASWARN (foo); 143175845Srwatson #elif defined GNULIB_POSIXCHECK 144175845Srwatson ... 145170151Srwatson #endif 146170151Srwatson*/ 147170151Srwatson 148170151Srwatson/* _GL_EXTERN_C declaration; 149169236Srwatson performs the declaration with C linkage. */ 150169236Srwatson#if defined __cplusplus 151169236Srwatson# define _GL_EXTERN_C extern "C" 152169236Srwatson#else 1531541Srgrimes# define _GL_EXTERN_C extern 1541541Srgrimes#endif 1551541Srgrimes 156169236Srwatson/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 157169236Srwatson declares a replacement function, named rpl_func, with the given prototype, 158169236Srwatson consisting of return type, parameters, and attributes. 159169236Srwatson Example: 160169236Srwatson _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 161169236Srwatson _GL_ARG_NONNULL ((1))); 162169236Srwatson */ 1631541Srgrimes#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 164160915Srwatson _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 165160915Srwatson#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 166130831Srwatson _GL_EXTERN_C rettype rpl_func parameters_and_attributes 167130831Srwatson 168130831Srwatson/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 169130831Srwatson declares the system function, named func, with the given prototype, 170130831Srwatson consisting of return type, parameters, and attributes. 171130831Srwatson Example: 172130831Srwatson _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 173130831Srwatson _GL_ARG_NONNULL ((1))); 1741541Srgrimes */ 1751549Srgrimes#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 176160915Srwatson _GL_EXTERN_C rettype func parameters_and_attributes 1771541Srgrimes 178193272Sjhb/* _GL_CXXALIAS_RPL (func, rettype, parameters); 17995552Stanimura declares a C++ alias called GNULIB_NAMESPACE::func 180130831Srwatson that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 181130831Srwatson Example: 182122352Stanimura _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 183174647Sjeff 184174647Sjeff Wrapping rpl_func in an object with an inline conversion operator 1851541Srgrimes avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is 1861541Srgrimes actually used in the program. */ 18798998Salfred#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 1881541Srgrimes _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 189133741Sjmg#if defined __cplusplus && defined GNULIB_NAMESPACE 190193272Sjhb# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 191193272Sjhb namespace GNULIB_NAMESPACE \ 192193272Sjhb { \ 193193272Sjhb static const struct _gl_ ## func ## _wrapper \ 194193272Sjhb { \ 195193272Sjhb typedef rettype (*type) parameters; \ 196193272Sjhb \ 197193272Sjhb inline operator type () const \ 198193272Sjhb { \ 199193272Sjhb return ::rpl_func; \ 200193272Sjhb } \ 201130831Srwatson } func = {}; \ 202193272Sjhb } \ 203193272Sjhb _GL_EXTERN_C int _gl_cxxalias_dummy 20497658Stanimura#else 20595883Salfred# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 206130831Srwatson _GL_EXTERN_C int _gl_cxxalias_dummy 2071541Srgrimes#endif 2081541Srgrimes 2091541Srgrimes/* _GL_CXXALIAS_MDA (func, rettype, parameters); 2101541Srgrimes is to be used when func is a Microsoft deprecated alias, on native Windows. 2111541Srgrimes It declares a C++ alias called GNULIB_NAMESPACE::func 212160915Srwatson that redirects to _func, if GNULIB_NAMESPACE is defined. 213160915Srwatson Example: 214160915Srwatson _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); 215160915Srwatson */ 216160915Srwatson#define _GL_CXXALIAS_MDA(func,rettype,parameters) \ 2171541Srgrimes _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters) 218160915Srwatson 219160915Srwatson/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 220160915Srwatson is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 221160915Srwatson except that the C function rpl_func may have a slightly different 222160915Srwatson declaration. A cast is used to silence the "invalid conversion" error 2231541Srgrimes that would otherwise occur. */ 224160915Srwatson#if defined __cplusplus && defined GNULIB_NAMESPACE 225160915Srwatson# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 226160915Srwatson namespace GNULIB_NAMESPACE \ 227160915Srwatson { \ 228160915Srwatson static const struct _gl_ ## func ## _wrapper \ 229160915Srwatson { \ 230160915Srwatson typedef rettype (*type) parameters; \ 231160915Srwatson \ 232160915Srwatson inline operator type () const \ 2331541Srgrimes { \ 2341541Srgrimes return reinterpret_cast<type>(::rpl_func); \ 2351541Srgrimes } \ 2361541Srgrimes } func = {}; \ 237160915Srwatson } \ 238160915Srwatson _GL_EXTERN_C int _gl_cxxalias_dummy 2391541Srgrimes#else 2401549Srgrimes# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 241160915Srwatson _GL_EXTERN_C int _gl_cxxalias_dummy 2421541Srgrimes#endif 24383366Sjulian 2441541Srgrimes/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters); 245131006Srwatson is like _GL_CXXALIAS_MDA (func, rettype, parameters); 246131006Srwatson except that the C function func may have a slightly different declaration. 247131006Srwatson A cast is used to silence the "invalid conversion" error that would 2481541Srgrimes otherwise occur. */ 249131006Srwatson#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \ 2501541Srgrimes _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters) 2511541Srgrimes 2521541Srgrimes/* _GL_CXXALIAS_SYS (func, rettype, parameters); 2531541Srgrimes declares a C++ alias called GNULIB_NAMESPACE::func 2541541Srgrimes that redirects to the system provided function func, if GNULIB_NAMESPACE 2551541Srgrimes is defined. 2561541Srgrimes Example: 257131006Srwatson _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 258130653Srwatson 2591541Srgrimes Wrapping func in an object with an inline conversion operator 2601541Srgrimes avoids a reference to func unless GNULIB_NAMESPACE::func is 261131006Srwatson actually used in the program. */ 2621541Srgrimes#if defined __cplusplus && defined GNULIB_NAMESPACE 263131006Srwatson# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 264131006Srwatson namespace GNULIB_NAMESPACE \ 2651541Srgrimes { \ 2661541Srgrimes static const struct _gl_ ## func ## _wrapper \ 2671541Srgrimes { \ 268101996Sdg typedef rettype (*type) parameters; \ 269101996Sdg \ 270101996Sdg inline operator type () const \ 271101996Sdg { \ 272162086Sjhb return ::func; \ 273101996Sdg } \ 274162086Sjhb } func = {}; \ 275101996Sdg } \ 276101996Sdg _GL_EXTERN_C int _gl_cxxalias_dummy 277162086Sjhb#else 278101996Sdg# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 279162086Sjhb _GL_EXTERN_C int _gl_cxxalias_dummy 280101996Sdg#endif 281101996Sdg 282101996Sdg/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 283101996Sdg is like _GL_CXXALIAS_SYS (func, rettype, parameters); 2841541Srgrimes except that the C function func may have a slightly different declaration. 285160915Srwatson A cast is used to silence the "invalid conversion" error that would 286160915Srwatson otherwise occur. */ 2871541Srgrimes#if defined __cplusplus && defined GNULIB_NAMESPACE 2881549Srgrimes# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 289160915Srwatson namespace GNULIB_NAMESPACE \ 290160915Srwatson { \ 2911541Srgrimes static const struct _gl_ ## func ## _wrapper \ 292125454Sjhb { \ 29352070Sgreen typedef rettype (*type) parameters; \ 294131006Srwatson \ 295131006Srwatson inline operator type () const \ 29652070Sgreen { \ 297183663Srwatson return reinterpret_cast<type>(::func); \ 298183663Srwatson } \ 299183663Srwatson } func = {}; \ 300183663Srwatson } \ 301183663Srwatson _GL_EXTERN_C int _gl_cxxalias_dummy 30252070Sgreen#else 303101996Sdg# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 3041541Srgrimes _GL_EXTERN_C int _gl_cxxalias_dummy 305125454Sjhb#endif 306125454Sjhb 307125454Sjhb/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 308125454Sjhb is like _GL_CXXALIAS_SYS (func, rettype, parameters); 309125454Sjhb except that the C function is picked among a set of overloaded functions, 310125454Sjhb namely the one with rettype2 and parameters2. Two consecutive casts 31165495Struckman are used to silence the "cannot find a match" and "invalid conversion" 312125454Sjhb errors that would otherwise occur. */ 31352070Sgreen#if defined __cplusplus && defined GNULIB_NAMESPACE 31413267Swollman /* The outer cast must be a reinterpret_cast. 3151541Srgrimes The inner cast: When the function is defined as a set of overloaded 3161541Srgrimes functions, it works as a static_cast<>, choosing the designated variant. 3171541Srgrimes When the function is defined as a single variant, it works as a 3181541Srgrimes reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 3191541Srgrimes# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 320131006Srwatson namespace GNULIB_NAMESPACE \ 321160915Srwatson { \ 322160915Srwatson static const struct _gl_ ## func ## _wrapper \ 323131006Srwatson { \ 324131006Srwatson typedef rettype (*type) parameters; \ 325131006Srwatson \ 326131006Srwatson inline operator type () const \ 327131006Srwatson { \ 328131006Srwatson return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ 329131006Srwatson } \ 330131006Srwatson } func = {}; \ 331131006Srwatson } \ 3321541Srgrimes _GL_EXTERN_C int _gl_cxxalias_dummy 3331541Srgrimes#else 3341541Srgrimes# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 335175968Srwatson _GL_EXTERN_C int _gl_cxxalias_dummy 336160915Srwatson#endif 337160875Srwatson 338160875Srwatson/* _GL_CXXALIASWARN (func); 339160875Srwatson causes a warning to be emitted when ::func is used but not when 340160875Srwatson GNULIB_NAMESPACE::func is used. func must be defined without overloaded 341160875Srwatson variants. */ 342160875Srwatson#if defined __cplusplus && defined GNULIB_NAMESPACE 343160875Srwatson# define _GL_CXXALIASWARN(func) \ 344160875Srwatson _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 3451549Srgrimes# define _GL_CXXALIASWARN_1(func,namespace) \ 346160915Srwatson _GL_CXXALIASWARN_2 (func, namespace) 3471541Srgrimes/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 3481541Srgrimes we enable the warning only when not optimizing. */ 349130831Srwatson# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) 350130831Srwatson# define _GL_CXXALIASWARN_2(func,namespace) \ 351160875Srwatson _GL_WARN_ON_USE (func, \ 3521541Srgrimes "The symbol ::" #func " refers to the system function. " \ 3531541Srgrimes "Use " #namespace "::" #func " instead.") 354130831Srwatson# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 355160915Srwatson# define _GL_CXXALIASWARN_2(func,namespace) \ 356130831Srwatson extern __typeof__ (func) func 357130831Srwatson# else 358130831Srwatson# define _GL_CXXALIASWARN_2(func,namespace) \ 359130831Srwatson _GL_EXTERN_C int _gl_cxxalias_dummy 360130831Srwatson# endif 361130831Srwatson#else 362160875Srwatson# define _GL_CXXALIASWARN(func) \ 363160875Srwatson _GL_EXTERN_C int _gl_cxxalias_dummy 364160915Srwatson#endif 365160875Srwatson 366160875Srwatson/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 367160875Srwatson causes a warning to be emitted when the given overloaded variant of ::func 368160875Srwatson is used but not when GNULIB_NAMESPACE::func is used. */ 369160875Srwatson#if defined __cplusplus && defined GNULIB_NAMESPACE 3701541Srgrimes# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 371160915Srwatson _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 3721541Srgrimes GNULIB_NAMESPACE) 373160915Srwatson# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 374160915Srwatson _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 375160915Srwatson/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 376160915Srwatson we enable the warning only when not optimizing. */ 377160915Srwatson# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) 378160915Srwatson# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 379160915Srwatson _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \ 380160915Srwatson "The symbol ::" #func " refers to the system function. " \ 381160915Srwatson "Use " #namespace "::" #func " instead.") 382160915Srwatson# else 383160915Srwatson# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 384160915Srwatson _GL_EXTERN_C int _gl_cxxalias_dummy 3851541Srgrimes# endif 386160915Srwatson#else 387160915Srwatson# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 388160915Srwatson _GL_EXTERN_C int _gl_cxxalias_dummy 389160915Srwatson#endif 390160915Srwatson 3911541Srgrimes#endif /* _GL_CXXDEFS_H */ 392121628Ssam 393121628Ssam/* The definition of _GL_ARG_NONNULL is copied here. */ 394121628Ssam/* A C macro for declaring that specific arguments must not be NULL. 395121628Ssam Copyright (C) 2009-2022 Free Software Foundation, Inc. 396121628Ssam 397121628Ssam This program is free software: you can redistribute it and/or modify it 398130831Srwatson under the terms of the GNU Lesser General Public License as published 399130831Srwatson by the Free Software Foundation; either version 2 of the License, or 400121628Ssam (at your option) any later version. 401121628Ssam 402121628Ssam This program is distributed in the hope that it will be useful, 403121628Ssam but WITHOUT ANY WARRANTY; without even the implied warranty of 404121628Ssam MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 405121628Ssam Lesser General Public License for more details. 406121628Ssam 407121628Ssam You should have received a copy of the GNU Lesser General Public License 408121628Ssam along with this program. If not, see <https://www.gnu.org/licenses/>. */ 409121628Ssam 410121628Ssam/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 411121628Ssam that the values passed as arguments n, ..., m must be non-NULL pointers. 412121628Ssam n = 1 stands for the first argument, n = 2 for the second argument etc. */ 413121628Ssam#ifndef _GL_ARG_NONNULL 414121628Ssam# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__ 415121628Ssam# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 416121628Ssam# else 417121628Ssam# define _GL_ARG_NONNULL(params) 418121628Ssam# endif 419130831Srwatson#endif 420130831Srwatson 421121628Ssam/* The definition of _GL_WARN_ON_USE is copied here. */ 422121628Ssam/* A C macro for emitting warnings if a function is used. 423121628Ssam Copyright (C) 2010-2022 Free Software Foundation, Inc. 424121628Ssam 425121628Ssam This program is free software: you can redistribute it and/or modify it 426121628Ssam under the terms of the GNU Lesser General Public License as published 427121628Ssam by the Free Software Foundation; either version 2 of the License, or 428121628Ssam (at your option) any later version. 429121628Ssam 430121628Ssam This program is distributed in the hope that it will be useful, 431121628Ssam but WITHOUT ANY WARRANTY; without even the implied warranty of 432121628Ssam MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 433121628Ssam Lesser General Public License for more details. 434121628Ssam 435121628Ssam You should have received a copy of the GNU Lesser General Public License 436121628Ssam along with this program. If not, see <https://www.gnu.org/licenses/>. */ 437121628Ssam 438121628Ssam/* _GL_WARN_ON_USE (function, "literal string") issues a declaration 439121628Ssam for FUNCTION which will then trigger a compiler warning containing 440121628Ssam the text of "literal string" anywhere that function is called, if 441121628Ssam supported by the compiler. If the compiler does not support this 442121628Ssam feature, the macro expands to an unused extern declaration. 443130831Srwatson 444121628Ssam _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the 445121628Ssam attribute used in _GL_WARN_ON_USE. If the compiler does not support 446121628Ssam this feature, it expands to empty. 447121628Ssam 448121628Ssam These macros are useful for marking a function as a potential 449121628Ssam portability trap, with the intent that "literal string" include 450121628Ssam instructions on the replacement function that should be used 4511541Srgrimes instead. 452160915Srwatson _GL_WARN_ON_USE is for functions with 'extern' linkage. 453160915Srwatson _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' 454160915Srwatson linkage. 4551541Srgrimes 4561549Srgrimes However, one of the reasons that a function is a portability trap is 457160915Srwatson if it has the wrong signature. Declaring FUNCTION with a different 4581541Srgrimes signature in C is a compilation error, so this macro must use the 459160915Srwatson same type as any existing declaration so that programs that avoid 4601541Srgrimes the problematic FUNCTION do not fail to compile merely because they 461130831Srwatson included a header that poisoned the function. But this implies that 462130831Srwatson _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already 4631541Srgrimes have a declaration. Use of this macro implies that there must not 4641541Srgrimes be any other macro hiding the declaration of FUNCTION; but 465130831Srwatson undefining FUNCTION first is part of the poisoning process anyway 466121628Ssam (although for symbols that are provided only via a macro, the result 4673308Sphk is a compilation error rather than a warning containing 4683308Sphk "literal string"). Also note that in C++, it is only safe to use if 4691541Srgrimes FUNCTION has no overloads. 4701541Srgrimes 4711541Srgrimes For an example, it is possible to poison 'getline' by: 4721541Srgrimes - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], 473130831Srwatson [getline]) in configure.ac, which potentially defines 4741541Srgrimes HAVE_RAW_DECL_GETLINE 4751541Srgrimes - adding this code to a header that wraps the system <stdio.h>: 4761541Srgrimes #undef getline 477121628Ssam #if HAVE_RAW_DECL_GETLINE 478121628Ssam _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" 479121628Ssam "not universally present; use the gnulib module getline"); 480121628Ssam #endif 481121628Ssam 482121628Ssam It is not possible to directly poison global variables. But it is 483121628Ssam possible to write a wrapper accessor function, and poison that 484121628Ssam (less common usage, like &environ, will cause a compilation error 485121628Ssam rather than issue the nice warning, but the end result of informing 486130831Srwatson the developer about their portability problem is still achieved): 487121628Ssam #if HAVE_RAW_DECL_ENVIRON 488121628Ssam static char *** 489121628Ssam rpl_environ (void) { return &environ; } 490121628Ssam _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); 491121628Ssam # undef environ 492121628Ssam # define environ (*rpl_environ ()) 493121628Ssam #endif 494121628Ssam or better (avoiding contradictory use of 'static' and 'extern'): 495121628Ssam #if HAVE_RAW_DECL_ENVIRON 496121628Ssam static char *** 4971541Srgrimes _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") 4981541Srgrimes rpl_environ (void) { return &environ; } 499121628Ssam # undef environ 5001541Srgrimes # define environ (*rpl_environ ()) 5011541Srgrimes #endif 502121628Ssam */ 503160915Srwatson#ifndef _GL_WARN_ON_USE 504160915Srwatson 505160915Srwatson# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 506130831Srwatson/* A compiler attribute is available in gcc versions 4.3.0 and later. */ 507130831Srwatson# define _GL_WARN_ON_USE(function, message) \ 508160915Srwatson_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message))) 509130831Srwatson# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 510130831Srwatson __attribute__ ((__warning__ (message))) 511130831Srwatson# elif __clang_major__ >= 4 512130831Srwatson/* Another compiler attribute is available in clang. */ 513130831Srwatson# define _GL_WARN_ON_USE(function, message) \ 514130831Srwatson_GL_WARN_EXTERN_C __typeof__ (function) function \ 515130831Srwatson __attribute__ ((__diagnose_if__ (1, message, "warning"))) 516130831Srwatson# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 517160915Srwatson __attribute__ ((__diagnose_if__ (1, message, "warning"))) 518160915Srwatson# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 519160915Srwatson/* Verify the existence of the function. */ 520121628Ssam# define _GL_WARN_ON_USE(function, message) \ 521121628Ssam_GL_WARN_EXTERN_C __typeof__ (function) function 522130831Srwatson# define _GL_WARN_ON_USE_ATTRIBUTE(message) 523121628Ssam# else /* Unsupported. */ 524130831Srwatson# define _GL_WARN_ON_USE(function, message) \ 525121628Ssam_GL_WARN_EXTERN_C int _gl_warn_on_use 526121628Ssam# define _GL_WARN_ON_USE_ATTRIBUTE(message) 527121628Ssam# endif 528121628Ssam#endif 529121628Ssam 530121628Ssam/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message") 531121628Ssam is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the 532121628Ssam function is declared with the given prototype, consisting of return type, 533121628Ssam parameters, and attributes. 534121628Ssam This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 535121628Ssam not work in this case. */ 536121628Ssam#ifndef _GL_WARN_ON_USE_CXX 537130831Srwatson# if !defined __cplusplus 538160915Srwatson# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 539160915Srwatson _GL_WARN_ON_USE (function, msg) 540160915Srwatson# else 541130831Srwatson# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 542130831Srwatson/* A compiler attribute is available in gcc versions 4.3.0 and later. */ 543130831Srwatson# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 544130831Srwatsonextern rettype_gcc function parameters_and_attributes \ 545130831Srwatson __attribute__ ((__warning__ (msg))) 546130831Srwatson# elif __clang_major__ >= 4 547130831Srwatson/* Another compiler attribute is available in clang. */ 548130831Srwatson# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 549130831Srwatsonextern rettype_clang function parameters_and_attributes \ 550130831Srwatson __attribute__ ((__diagnose_if__ (1, msg, "warning"))) 5511541Srgrimes# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 5521549Srgrimes/* Verify the existence of the function. */ 553160915Srwatson# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 5541541Srgrimesextern rettype_gcc function parameters_and_attributes 555103554Sphk# else /* Unsupported. */ 556103554Sphk# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 557103554Sphk_GL_WARN_EXTERN_C int _gl_warn_on_use 5581541Srgrimes# endif 559130831Srwatson# endif 560130831Srwatson#endif 56140913Sfenner 56240913Sfenner/* _GL_WARN_EXTERN_C declaration; 56340913Sfenner performs the declaration with C linkage. */ 5641541Srgrimes#ifndef _GL_WARN_EXTERN_C 5651541Srgrimes# if defined __cplusplus 56617675Sjulian# define _GL_WARN_EXTERN_C extern "C" 5671541Srgrimes# else 56840913Sfenner# define _GL_WARN_EXTERN_C extern 5691541Srgrimes# endif 5701541Srgrimes#endif 571121628Ssam 5721541Srgrimes/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C. 5731541Srgrimes On systems that don't define it, use the same value as GNU libintl. */ 5741541Srgrimes#if !defined LC_MESSAGES 5751541Srgrimes# define LC_MESSAGES 1729 5761541Srgrimes#endif 5771541Srgrimes 5781541Srgrimes/* On native Windows with MSVC, 'struct lconv' lacks the members int_p_* and 579160915Srwatson int_n_*. Instead of overriding 'struct lconv', merely define these member 5801541Srgrimes names as macros. This avoids trouble in C++ mode. */ 5811549Srgrimes#if defined _MSC_VER 582160915Srwatson# define int_p_cs_precedes p_cs_precedes 5831541Srgrimes# define int_p_sign_posn p_sign_posn 584160915Srwatson# define int_p_sep_by_space p_sep_by_space 5851541Srgrimes# define int_n_cs_precedes n_cs_precedes 586130831Srwatson# define int_n_sign_posn n_sign_posn 587130831Srwatson# define int_n_sep_by_space n_sep_by_space 5881541Srgrimes#endif 5891541Srgrimes 5901541Srgrimes/* Bionic libc's 'struct lconv' is just a dummy. */ 591160915Srwatson#if 0 592160915Srwatson# define lconv rpl_lconv 5931541Srgrimesstruct lconv 5941541Srgrimes{ 595121628Ssam /* All 'char *' are actually 'const char *'. */ 596121628Ssam 597191366Semax /* Members that depend on the LC_NUMERIC category of the locale. See 5981541Srgrimes <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */ 5991541Srgrimes 6001541Srgrimes /* Symbol used as decimal point. */ 6011541Srgrimes char *decimal_point; 6021541Srgrimes /* Symbol used to separate groups of digits to the left of the decimal 6031541Srgrimes point. */ 604191366Semax char *thousands_sep; 6051541Srgrimes /* Definition of the size of groups of digits to the left of the decimal 6061541Srgrimes point. */ 6071541Srgrimes char *grouping; 6081541Srgrimes 609160915Srwatson /* Members that depend on the LC_MONETARY category of the locale. See 610130831Srwatson <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */ 611130831Srwatson 612160915Srwatson /* Symbol used as decimal point. */ 613130831Srwatson char *mon_decimal_point; 614130831Srwatson /* Symbol used to separate groups of digits to the left of the decimal 615130831Srwatson point. */ 616130831Srwatson char *mon_thousands_sep; 617130831Srwatson /* Definition of the size of groups of digits to the left of the decimal 618130831Srwatson point. */ 619130831Srwatson char *mon_grouping; 620130831Srwatson /* Sign used to indicate a value >= 0. */ 621160915Srwatson char *positive_sign; 622160915Srwatson /* Sign used to indicate a value < 0. */ 623160915Srwatson char *negative_sign; 624160915Srwatson 6251541Srgrimes /* For formatting local currency. */ 6261549Srgrimes /* Currency symbol (3 characters) followed by separator (1 character). */ 627160915Srwatson char *currency_symbol; 628160915Srwatson /* Number of digits after the decimal point. */ 6291541Srgrimes char frac_digits; 630121628Ssam /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it 6311541Srgrimes comes after the number. */ 6321541Srgrimes char p_cs_precedes; 633130831Srwatson /* For values >= 0: Position of the sign. */ 634130831Srwatson char p_sign_posn; 63578945Sjlemon /* For values >= 0: Placement of spaces between currency symbol, sign, and 636130831Srwatson number. */ 6371541Srgrimes char p_sep_by_space; 6381541Srgrimes /* For values < 0: 1 if the currency symbol precedes the number, 0 if it 639103554Sphk comes after the number. */ 640130831Srwatson char n_cs_precedes; 6411541Srgrimes /* For values < 0: Position of the sign. */ 6421541Srgrimes char n_sign_posn; 643118045Sscottl /* For values < 0: Placement of spaces between currency symbol, sign, and 6441541Srgrimes number. */ 6451541Srgrimes char n_sep_by_space; 646118045Sscottl 647111119Simp /* For formatting international currency. */ 6481541Srgrimes /* Currency symbol (3 characters) followed by separator (1 character). */ 6491541Srgrimes char *int_curr_symbol; 6501541Srgrimes /* Number of digits after the decimal point. */ 65198998Salfred char int_frac_digits; 6521541Srgrimes /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it 6531541Srgrimes comes after the number. */ 6541541Srgrimes char int_p_cs_precedes; 6551541Srgrimes /* For values >= 0: Position of the sign. */ 6561541Srgrimes char int_p_sign_posn; 657121628Ssam /* For values >= 0: Placement of spaces between currency symbol, sign, and 6581541Srgrimes number. */ 659121628Ssam char int_p_sep_by_space; 660121628Ssam /* For values < 0: 1 if the currency symbol precedes the number, 0 if it 661121628Ssam comes after the number. */ 662121628Ssam char int_n_cs_precedes; 663121628Ssam /* For values < 0: Position of the sign. */ 664121628Ssam char int_n_sign_posn; 665121628Ssam /* For values < 0: Placement of spaces between currency symbol, sign, and 666121628Ssam number. */ 6671541Srgrimes char int_n_sep_by_space; 6681541Srgrimes}; 6691541Srgrimes#endif 670130831Srwatson 671160915Srwatson#if 0 672160915Srwatson# if 0 673160915Srwatson# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 674160915Srwatson# undef localeconv 675130831Srwatson# define localeconv rpl_localeconv 6761549Srgrimes# endif 677160915Srwatson_GL_FUNCDECL_RPL (localeconv, struct lconv *, (void)); 678160915Srwatson_GL_CXXALIAS_RPL (localeconv, struct lconv *, (void)); 679130831Srwatson# else 680130831Srwatson_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void)); 681130831Srwatson# endif 682130831Srwatson# if __GLIBC__ >= 2 683130831Srwatson_GL_CXXALIASWARN (localeconv); 684130831Srwatson# endif 685130831Srwatson#elif 0 686130831Srwatson# undef localeconv 687130831Srwatson# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv 688130831Srwatson#elif defined GNULIB_POSIXCHECK 689160915Srwatson# undef localeconv 690160915Srwatson# if HAVE_RAW_DECL_LOCALECONV 6911541Srgrimes_GL_WARN_ON_USE (localeconv, 692121628Ssam "localeconv returns too few information on some platforms - " 693103554Sphk "use gnulib module localeconv for portability"); 6941541Srgrimes# endif 695130831Srwatson#endif 696130831Srwatson 6971541Srgrimes#if 0 698130831Srwatson# if 0 699103554Sphk# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 700130831Srwatson# undef setlocale 7011541Srgrimes# define setlocale rpl_setlocale 7021541Srgrimes# define GNULIB_defined_setlocale 1 7031541Srgrimes# endif 704121628Ssam_GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale)); 705121628Ssam_GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale)); 706121628Ssam# else 707121628Ssam_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale)); 7081541Srgrimes# endif 709121628Ssam# if __GLIBC__ >= 2 710121628Ssam_GL_CXXALIASWARN (setlocale); 711121628Ssam# endif 712121628Ssam#elif defined GNULIB_POSIXCHECK 713121628Ssam# undef setlocale 714121628Ssam# if HAVE_RAW_DECL_SETLOCALE 715121628Ssam_GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - " 716121628Ssam "use gnulib module setlocale for portability"); 7171541Srgrimes# endif 7181541Srgrimes#endif 7191541Srgrimes 720130831Srwatson#if 1 721160915Srwatson/* Included here for convenience. */ 722130831Srwatson# include "setlocale_null.h" 723130831Srwatson#endif 724130831Srwatson 725130831Srwatson#if /*@GNULIB_NEWLOCALE@ ||*/ (0 && 0 && 1) 726130831Srwatson# if 0 727130831Srwatson# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 728130831Srwatson# undef newlocale 729130831Srwatson# define newlocale rpl_newlocale 730130831Srwatson# define GNULIB_defined_newlocale 1 7311541Srgrimes# endif 732150280Srwatson_GL_FUNCDECL_RPL (newlocale, locale_t, 733150280Srwatson (int category_mask, const char *name, locale_t base) 734150280Srwatson _GL_ARG_NONNULL ((2))); 735150280Srwatson_GL_CXXALIAS_RPL (newlocale, locale_t, 736150280Srwatson (int category_mask, const char *name, locale_t base)); 737150280Srwatson# else 738150280Srwatson# if 1 739150280Srwatson_GL_CXXALIAS_SYS (newlocale, locale_t, 740150280Srwatson (int category_mask, const char *name, locale_t base)); 741150280Srwatson# endif 742150280Srwatson# endif 743150280Srwatson# if 1 744150280Srwatson_GL_CXXALIASWARN (newlocale); 745150280Srwatson# endif 746150280Srwatson# if 1 || 0 747150280Srwatson# ifndef HAVE_WORKING_NEWLOCALE 748150280Srwatson# define HAVE_WORKING_NEWLOCALE 1 749150280Srwatson# endif 7501541Srgrimes# endif 7511549Srgrimes#elif defined GNULIB_POSIXCHECK 752160915Srwatson# undef newlocale 7531541Srgrimes# if HAVE_RAW_DECL_NEWLOCALE 754160915Srwatson_GL_WARN_ON_USE (newlocale, "newlocale is not portable"); 755160915Srwatson# endif 7561541Srgrimes#endif 757130831Srwatson 758130831Srwatson#if 0 || (0 && 0 && 1) 7591541Srgrimes# if 0 7601541Srgrimes# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 7611541Srgrimes# undef duplocale 7621541Srgrimes# define duplocale rpl_duplocale 7631541Srgrimes# define GNULIB_defined_duplocale 1 7641541Srgrimes# endif 765121628Ssam_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1))); 766121628Ssam_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale)); 7671541Srgrimes# else 7681541Srgrimes# if 1 7691541Srgrimes_GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale)); 77068918Sdwmalone# endif 77168918Sdwmalone# endif 772174711Skmacy# if 1 77368918Sdwmalone_GL_CXXALIASWARN (duplocale); 77468918Sdwmalone# endif 7751541Srgrimes# if 1 || 0 7761541Srgrimes# ifndef HAVE_WORKING_DUPLOCALE 7771541Srgrimes# define HAVE_WORKING_DUPLOCALE 1 7781541Srgrimes# endif 7791541Srgrimes# endif 780151967Sandre#elif defined GNULIB_POSIXCHECK 781109098Stjr# undef duplocale 782106473Skbyanc# if HAVE_RAW_DECL_DUPLOCALE 7831541Srgrimes_GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - " 7841541Srgrimes "use gnulib module duplocale for portability"); 7851541Srgrimes# endif 7861541Srgrimes#endif 7871541Srgrimes 7881541Srgrimes#if /*@GNULIB_FREELOCALE@ ||*/ (0 && 0 && 1) 7891541Srgrimes# if 0 790121628Ssam# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 7911541Srgrimes# undef freelocale 7921541Srgrimes# define freelocale rpl_freelocale 7931541Srgrimes# define GNULIB_defined_freelocale 1 7941541Srgrimes# endif 7951541Srgrimes_GL_FUNCDECL_RPL (freelocale, void, (locale_t locale) _GL_ARG_NONNULL ((1))); 7961541Srgrimes_GL_CXXALIAS_RPL (freelocale, void, (locale_t locale)); 7971541Srgrimes# else 798150280Srwatson# if 1 799150280Srwatson/* Need to cast, because on FreeBSD and Mac OS X 10.13, the return type is 8001541Srgrimes int. */ 801121628Ssam_GL_CXXALIAS_SYS_CAST (freelocale, void, (locale_t locale)); 8021541Srgrimes# endif 8031541Srgrimes# endif 8041541Srgrimes# if 1 805160915Srwatson_GL_CXXALIASWARN (freelocale); 8061541Srgrimes# endif 807160875Srwatson#elif defined GNULIB_POSIXCHECK 808160915Srwatson# undef freelocale 8091541Srgrimes# if HAVE_RAW_DECL_FREELOCALE 8101541Srgrimes_GL_WARN_ON_USE (freelocale, "freelocale is not portable"); 81151757Spb# endif 81251757Spb#endif 81351757Spb 81451757Spb#endif /* _GL_LOCALE_H */ 81551757Spb#endif /* _GL_LOCALE_H */ 81651757Spb#endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */ 81751757Spb