1206917Smarius/* This file is automatically generated. DO NOT EDIT! */ 2206917Smarius/* Generated from: NetBSD: mknative-gdb,v 1.12 2020/09/17 16:54:31 christos Exp */ 3206917Smarius/* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp */ 4206917Smarius 5206917Smarius/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 6206917Smarius/* Like <fcntl.h>, but with non-working flags defined to 0. 7206917Smarius 8206917Smarius Copyright (C) 2006-2020 Free Software Foundation, Inc. 9206917Smarius 10206917Smarius This program is free software: you can redistribute it and/or modify 11206917Smarius it under the terms of the GNU General Public License as published by 12206917Smarius the Free Software Foundation; either version 3 of the License, or 13206917Smarius (at your option) any later version. 14206917Smarius 15206917Smarius This program is distributed in the hope that it will be useful, 16206917Smarius but WITHOUT ANY WARRANTY; without even the implied warranty of 17206917Smarius MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18206917Smarius GNU General Public License for more details. 19206917Smarius 20206917Smarius You should have received a copy of the GNU General Public License 21206917Smarius along with this program. If not, see <https://www.gnu.org/licenses/>. */ 22206917Smarius 23206917Smarius/* written by Paul Eggert */ 24206917Smarius 25206917Smarius#if __GNUC__ >= 3 26206917Smarius#pragma GCC system_header 27206917Smarius#endif 28206917Smarius 29206917Smarius 30206917Smarius#if defined __need_system_fcntl_h 31206917Smarius/* Special invocation convention. */ 32206917Smarius 33206917Smarius/* Needed before <sys/stat.h>. 34206917Smarius May also define off_t to a 64-bit type on native Windows. */ 35206917Smarius#include <sys/types.h> 36206917Smarius/* On some systems other than glibc, <sys/stat.h> is a prerequisite of 37206917Smarius <fcntl.h>. On glibc systems, we would like to avoid namespace pollution. 38206917Smarius But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an 39206917Smarius extern "C" { ... } block, which leads to errors in C++ mode with the 40206917Smarius overridden <sys/stat.h> from gnulib. These errors are known to be gone 41206917Smarius with g++ version >= 4.3. */ 42206917Smarius#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))) 43206917Smarius# include <sys/stat.h> 44206917Smarius#endif 45206917Smarius#include_next <fcntl.h> 46206917Smarius 47206917Smarius/* Native Windows platforms declare open(), creat() in <io.h>. */ 48206917Smarius#if (0 || 1 || defined GNULIB_POSIXCHECK) \ 49206917Smarius && (defined _WIN32 && ! defined __CYGWIN__) 50206917Smarius# include <io.h> 51206917Smarius#endif 52206917Smarius 53206917Smarius#else 54206917Smarius/* Normal invocation convention. */ 55206917Smarius 56206917Smarius#ifndef _GL_FCNTL_H 57206917Smarius 58206917Smarius/* Needed before <sys/stat.h>. 59206917Smarius May also define off_t to a 64-bit type on native Windows. */ 60206917Smarius#include <sys/types.h> 61206917Smarius/* On some systems other than glibc, <sys/stat.h> is a prerequisite of 62206917Smarius <fcntl.h>. On glibc systems, we would like to avoid namespace pollution. 63206917Smarius But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an 64206917Smarius extern "C" { ... } block, which leads to errors in C++ mode with the 65206917Smarius overridden <sys/stat.h> from gnulib. These errors are known to be gone 66206917Smarius with g++ version >= 4.3. */ 67206917Smarius#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))) 68206917Smarius# include <sys/stat.h> 69206917Smarius#endif 70206917Smarius/* The include_next requires a split double-inclusion guard. */ 71206917Smarius#include_next <fcntl.h> 72206917Smarius 73206917Smarius/* Native Windows platforms declare open(), creat() in <io.h>. */ 74206917Smarius#if (0 || 1 || defined GNULIB_POSIXCHECK) \ 75206917Smarius && (defined _WIN32 && ! defined __CYGWIN__) 76206917Smarius# include <io.h> 77206917Smarius#endif 78206917Smarius 79206917Smarius#ifndef _GL_FCNTL_H 80206917Smarius#define _GL_FCNTL_H 81206917Smarius 82206917Smarius#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ 83206917Smarius# include <unistd.h> 84206917Smarius#endif 85206917Smarius 86206917Smarius 87206917Smarius/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 88206917Smarius/* C++ compatible function declaration macros. 89206917Smarius Copyright (C) 2010-2020 Free Software Foundation, Inc. 90206917Smarius 91206917Smarius This program is free software: you can redistribute it and/or modify it 92206917Smarius under the terms of the GNU General Public License as published 93206917Smarius by the Free Software Foundation; either version 3 of the License, or 94206917Smarius (at your option) any later version. 95206917Smarius 96206917Smarius This program is distributed in the hope that it will be useful, 97206917Smarius but WITHOUT ANY WARRANTY; without even the implied warranty of 98206917Smarius MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 99206917Smarius General Public License for more details. 100206917Smarius 101206917Smarius You should have received a copy of the GNU General Public License 102206917Smarius along with this program. If not, see <https://www.gnu.org/licenses/>. */ 103206917Smarius 104206917Smarius#ifndef _GL_CXXDEFS_H 105206917Smarius#define _GL_CXXDEFS_H 106206917Smarius 107206917Smarius/* Begin/end the GNULIB_NAMESPACE namespace. */ 108206917Smarius#if defined __cplusplus && defined GNULIB_NAMESPACE 109206917Smarius# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { 110206917Smarius# define _GL_END_NAMESPACE } 111206917Smarius#else 112206917Smarius# define _GL_BEGIN_NAMESPACE 113206917Smarius# define _GL_END_NAMESPACE 114206917Smarius#endif 115206917Smarius 116206917Smarius/* The three most frequent use cases of these macros are: 117206917Smarius 118206917Smarius * For providing a substitute for a function that is missing on some 119206917Smarius platforms, but is declared and works fine on the platforms on which 120206917Smarius it exists: 121206917Smarius 122206917Smarius #if @GNULIB_FOO@ 123206917Smarius # if !@HAVE_FOO@ 124206917Smarius _GL_FUNCDECL_SYS (foo, ...); 125206917Smarius # endif 126206917Smarius _GL_CXXALIAS_SYS (foo, ...); 127206917Smarius _GL_CXXALIASWARN (foo); 128206917Smarius #elif defined GNULIB_POSIXCHECK 129206917Smarius ... 130206917Smarius #endif 131206917Smarius 132206917Smarius * For providing a replacement for a function that exists on all platforms, 133206917Smarius but is broken/insufficient and needs to be replaced on some platforms: 134206917Smarius 135206917Smarius #if @GNULIB_FOO@ 136206917Smarius # if @REPLACE_FOO@ 137206917Smarius # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 138206917Smarius # undef foo 139206917Smarius # define foo rpl_foo 140206917Smarius # endif 141206917Smarius _GL_FUNCDECL_RPL (foo, ...); 142206917Smarius _GL_CXXALIAS_RPL (foo, ...); 143206917Smarius # else 144206917Smarius _GL_CXXALIAS_SYS (foo, ...); 145206917Smarius # endif 146206917Smarius _GL_CXXALIASWARN (foo); 147206917Smarius #elif defined GNULIB_POSIXCHECK 148206917Smarius ... 149206917Smarius #endif 150206917Smarius 151206917Smarius * For providing a replacement for a function that exists on some platforms 152206917Smarius but is broken/insufficient and needs to be replaced on some of them and 153206917Smarius is additionally either missing or undeclared on some other platforms: 154206917Smarius 155206917Smarius #if @GNULIB_FOO@ 156206917Smarius # if @REPLACE_FOO@ 157206917Smarius # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 158206917Smarius # undef foo 159206917Smarius # define foo rpl_foo 160206917Smarius # endif 161206917Smarius _GL_FUNCDECL_RPL (foo, ...); 162206917Smarius _GL_CXXALIAS_RPL (foo, ...); 163206917Smarius # else 164206917Smarius # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 165206917Smarius _GL_FUNCDECL_SYS (foo, ...); 166206917Smarius # endif 167206917Smarius _GL_CXXALIAS_SYS (foo, ...); 168206917Smarius # endif 169206917Smarius _GL_CXXALIASWARN (foo); 170206917Smarius #elif defined GNULIB_POSIXCHECK 171206917Smarius ... 172206917Smarius #endif 173206917Smarius*/ 174206917Smarius 175206917Smarius/* _GL_EXTERN_C declaration; 176206917Smarius performs the declaration with C linkage. */ 177206917Smarius#if defined __cplusplus 178206917Smarius# define _GL_EXTERN_C extern "C" 179206917Smarius#else 180206917Smarius# define _GL_EXTERN_C extern 181206917Smarius#endif 182206917Smarius 183206917Smarius/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 184206917Smarius declares a replacement function, named rpl_func, with the given prototype, 185206917Smarius consisting of return type, parameters, and attributes. 186206917Smarius Example: 187206917Smarius _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 188206917Smarius _GL_ARG_NONNULL ((1))); 189206917Smarius */ 190206917Smarius#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 191206917Smarius _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 192206917Smarius#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 193206917Smarius _GL_EXTERN_C rettype rpl_func parameters_and_attributes 194206917Smarius 195206917Smarius/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 196206917Smarius declares the system function, named func, with the given prototype, 197206917Smarius consisting of return type, parameters, and attributes. 198206917Smarius Example: 199206917Smarius _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 200206917Smarius _GL_ARG_NONNULL ((1))); 201206917Smarius */ 202206917Smarius#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 203206917Smarius _GL_EXTERN_C rettype func parameters_and_attributes 204206917Smarius 205206917Smarius/* _GL_CXXALIAS_RPL (func, rettype, parameters); 206206917Smarius declares a C++ alias called GNULIB_NAMESPACE::func 207206917Smarius that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 208206917Smarius Example: 209206917Smarius _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 210206917Smarius 211206917Smarius Wrapping rpl_func in an object with an inline conversion operator 212206917Smarius avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is 213206917Smarius actually used in the program. */ 214206917Smarius#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 215206917Smarius _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 216206917Smarius#if defined __cplusplus && defined GNULIB_NAMESPACE 217206917Smarius# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 218206917Smarius namespace GNULIB_NAMESPACE \ 219206917Smarius { \ 220206917Smarius static const struct _gl_ ## func ## _wrapper \ 221206917Smarius { \ 222206917Smarius typedef rettype (*type) parameters; \ 223206917Smarius \ 224206917Smarius inline operator type () const \ 225206917Smarius { \ 226206917Smarius return ::rpl_func; \ 227206917Smarius } \ 228206917Smarius } func = {}; \ 229206917Smarius } \ 230206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 231206917Smarius#else 232206917Smarius# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 233206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 234206917Smarius#endif 235206917Smarius 236206917Smarius/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 237206917Smarius is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 238206917Smarius except that the C function rpl_func may have a slightly different 239206917Smarius declaration. A cast is used to silence the "invalid conversion" error 240206917Smarius that would otherwise occur. */ 241206917Smarius#if defined __cplusplus && defined GNULIB_NAMESPACE 242206917Smarius# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 243206917Smarius namespace GNULIB_NAMESPACE \ 244206917Smarius { \ 245206917Smarius static const struct _gl_ ## func ## _wrapper \ 246206917Smarius { \ 247206917Smarius typedef rettype (*type) parameters; \ 248206917Smarius \ 249206917Smarius inline operator type () const \ 250206917Smarius { \ 251206917Smarius return reinterpret_cast<type>(::rpl_func); \ 252206917Smarius } \ 253206917Smarius } func = {}; \ 254206917Smarius } \ 255206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 256206917Smarius#else 257206917Smarius# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 258206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 259206917Smarius#endif 260206917Smarius 261206917Smarius/* _GL_CXXALIAS_SYS (func, rettype, parameters); 262206917Smarius declares a C++ alias called GNULIB_NAMESPACE::func 263206917Smarius that redirects to the system provided function func, if GNULIB_NAMESPACE 264206917Smarius is defined. 265206917Smarius Example: 266206917Smarius _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 267206917Smarius 268206917Smarius Wrapping func in an object with an inline conversion operator 269206917Smarius avoids a reference to func unless GNULIB_NAMESPACE::func is 270206917Smarius actually used in the program. */ 271206917Smarius#if defined __cplusplus && defined GNULIB_NAMESPACE 272206917Smarius# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 273206917Smarius namespace GNULIB_NAMESPACE \ 274206917Smarius { \ 275206917Smarius static const struct _gl_ ## func ## _wrapper \ 276206917Smarius { \ 277206917Smarius typedef rettype (*type) parameters; \ 278206917Smarius \ 279206917Smarius inline operator type () const \ 280206917Smarius { \ 281206917Smarius return ::func; \ 282206917Smarius } \ 283206917Smarius } func = {}; \ 284206917Smarius } \ 285206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 286206917Smarius#else 287206917Smarius# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 288206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 289206917Smarius#endif 290206917Smarius 291206917Smarius/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 292228975Suqs is like _GL_CXXALIAS_SYS (func, rettype, parameters); 293206917Smarius except that the C function func may have a slightly different declaration. 294206917Smarius A cast is used to silence the "invalid conversion" error that would 295206917Smarius otherwise occur. */ 296206917Smarius#if defined __cplusplus && defined GNULIB_NAMESPACE 297206917Smarius# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 298206917Smarius namespace GNULIB_NAMESPACE \ 299206917Smarius { \ 300206917Smarius static const struct _gl_ ## func ## _wrapper \ 301206917Smarius { \ 302206917Smarius typedef rettype (*type) parameters; \ 303206917Smarius \ 304206917Smarius inline operator type () const \ 305206917Smarius { \ 306206917Smarius return reinterpret_cast<type>(::func); \ 307206917Smarius } \ 308206917Smarius } func = {}; \ 309206917Smarius } \ 310206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 311206917Smarius#else 312206917Smarius# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 313206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 314206917Smarius#endif 315206917Smarius 316206917Smarius/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 317206917Smarius is like _GL_CXXALIAS_SYS (func, rettype, parameters); 318206917Smarius except that the C function is picked among a set of overloaded functions, 319206917Smarius namely the one with rettype2 and parameters2. Two consecutive casts 320206917Smarius are used to silence the "cannot find a match" and "invalid conversion" 321206917Smarius errors that would otherwise occur. */ 322206917Smarius#if defined __cplusplus && defined GNULIB_NAMESPACE 323206917Smarius /* The outer cast must be a reinterpret_cast. 324206917Smarius The inner cast: When the function is defined as a set of overloaded 325206917Smarius functions, it works as a static_cast<>, choosing the designated variant. 326206917Smarius When the function is defined as a single variant, it works as a 327206917Smarius reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 328206917Smarius# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 329206917Smarius namespace GNULIB_NAMESPACE \ 330206917Smarius { \ 331206917Smarius static const struct _gl_ ## func ## _wrapper \ 332206917Smarius { \ 333206917Smarius typedef rettype (*type) parameters; \ 334206917Smarius \ 335206917Smarius inline operator type () const \ 336206917Smarius { \ 337206917Smarius return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ 338206917Smarius } \ 339206917Smarius } func = {}; \ 340206917Smarius } \ 341206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 342206917Smarius#else 343206917Smarius# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 344206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 345206917Smarius#endif 346206917Smarius 347206917Smarius/* _GL_CXXALIASWARN (func); 348206917Smarius causes a warning to be emitted when ::func is used but not when 349206917Smarius GNULIB_NAMESPACE::func is used. func must be defined without overloaded 350206917Smarius variants. */ 351206917Smarius#if defined __cplusplus && defined GNULIB_NAMESPACE 352206917Smarius# define _GL_CXXALIASWARN(func) \ 353206917Smarius _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 354206917Smarius# define _GL_CXXALIASWARN_1(func,namespace) \ 355206917Smarius _GL_CXXALIASWARN_2 (func, namespace) 356206917Smarius/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 357206917Smarius we enable the warning only when not optimizing. */ 358206917Smarius# if !__OPTIMIZE__ 359206917Smarius# define _GL_CXXALIASWARN_2(func,namespace) \ 360206917Smarius _GL_WARN_ON_USE (func, \ 361206917Smarius "The symbol ::" #func " refers to the system function. " \ 362206917Smarius "Use " #namespace "::" #func " instead.") 363206917Smarius# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 364206917Smarius# define _GL_CXXALIASWARN_2(func,namespace) \ 365206917Smarius extern __typeof__ (func) func 366206917Smarius# else 367206917Smarius# define _GL_CXXALIASWARN_2(func,namespace) \ 368206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 369206917Smarius# endif 370206917Smarius#else 371206917Smarius# define _GL_CXXALIASWARN(func) \ 372206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 373206917Smarius#endif 374206917Smarius 375206917Smarius/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 376206917Smarius causes a warning to be emitted when the given overloaded variant of ::func 377206917Smarius is used but not when GNULIB_NAMESPACE::func is used. */ 378206917Smarius#if defined __cplusplus && defined GNULIB_NAMESPACE 379206917Smarius# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 380206917Smarius _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 381206917Smarius GNULIB_NAMESPACE) 382206917Smarius# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 383206917Smarius _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 384206917Smarius/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 385206917Smarius we enable the warning only when not optimizing. */ 386206917Smarius# if !__OPTIMIZE__ 387206917Smarius# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 388206917Smarius _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 389206917Smarius "The symbol ::" #func " refers to the system function. " \ 390206917Smarius "Use " #namespace "::" #func " instead.") 391206917Smarius# else 392206917Smarius# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 393206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 394206917Smarius# endif 395206917Smarius#else 396206917Smarius# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 397206917Smarius _GL_EXTERN_C int _gl_cxxalias_dummy 398206917Smarius#endif 399206917Smarius 400206917Smarius#endif /* _GL_CXXDEFS_H */ 401206917Smarius 402206917Smarius/* The definition of _GL_ARG_NONNULL is copied here. */ 403206917Smarius/* A C macro for declaring that specific arguments must not be NULL. 404206917Smarius Copyright (C) 2009-2020 Free Software Foundation, Inc. 405206917Smarius 406206917Smarius This program is free software: you can redistribute it and/or modify it 407206917Smarius under the terms of the GNU General Public License as published 408206917Smarius by the Free Software Foundation; either version 3 of the License, or 409206917Smarius (at your option) any later version. 410206917Smarius 411206917Smarius This program is distributed in the hope that it will be useful, 412206917Smarius but WITHOUT ANY WARRANTY; without even the implied warranty of 413206917Smarius MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 414206917Smarius General Public License for more details. 415206917Smarius 416206917Smarius You should have received a copy of the GNU General Public License 417206917Smarius along with this program. If not, see <https://www.gnu.org/licenses/>. */ 418206917Smarius 419206917Smarius/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 420206917Smarius that the values passed as arguments n, ..., m must be non-NULL pointers. 421206917Smarius n = 1 stands for the first argument, n = 2 for the second argument etc. */ 422206917Smarius#ifndef _GL_ARG_NONNULL 423206917Smarius# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 424206917Smarius# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 425206917Smarius# else 426206917Smarius# define _GL_ARG_NONNULL(params) 427206917Smarius# endif 428206917Smarius#endif 429206917Smarius 430206917Smarius/* The definition of _GL_WARN_ON_USE is copied here. */ 431206917Smarius/* A C macro for emitting warnings if a function is used. 432206917Smarius Copyright (C) 2010-2020 Free Software Foundation, Inc. 433206917Smarius 434206917Smarius This program is free software: you can redistribute it and/or modify it 435206917Smarius under the terms of the GNU General Public License as published 436206917Smarius by the Free Software Foundation; either version 3 of the License, or 437206917Smarius (at your option) any later version. 438206917Smarius 439206917Smarius This program is distributed in the hope that it will be useful, 440206917Smarius but WITHOUT ANY WARRANTY; without even the implied warranty of 441206917Smarius MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 442206917Smarius General Public License for more details. 443206917Smarius 444206917Smarius You should have received a copy of the GNU General Public License 445206917Smarius along with this program. If not, see <https://www.gnu.org/licenses/>. */ 446206917Smarius 447206917Smarius/* _GL_WARN_ON_USE (function, "literal string") issues a declaration 448206917Smarius for FUNCTION which will then trigger a compiler warning containing 449206917Smarius the text of "literal string" anywhere that function is called, if 450206917Smarius supported by the compiler. If the compiler does not support this 451206917Smarius feature, the macro expands to an unused extern declaration. 452206917Smarius 453206917Smarius _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the 454206917Smarius attribute used in _GL_WARN_ON_USE. If the compiler does not support 455206917Smarius this feature, it expands to empty. 456206917Smarius 457206917Smarius These macros are useful for marking a function as a potential 458206917Smarius portability trap, with the intent that "literal string" include 459206917Smarius instructions on the replacement function that should be used 460206917Smarius instead. 461206917Smarius _GL_WARN_ON_USE is for functions with 'extern' linkage. 462206917Smarius _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' 463206917Smarius linkage. 464206917Smarius 465206917Smarius However, one of the reasons that a function is a portability trap is 466206917Smarius if it has the wrong signature. Declaring FUNCTION with a different 467206917Smarius signature in C is a compilation error, so this macro must use the 468206917Smarius same type as any existing declaration so that programs that avoid 469206917Smarius the problematic FUNCTION do not fail to compile merely because they 470206917Smarius included a header that poisoned the function. But this implies that 471206917Smarius _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already 472206917Smarius have a declaration. Use of this macro implies that there must not 473206917Smarius be any other macro hiding the declaration of FUNCTION; but 474206917Smarius undefining FUNCTION first is part of the poisoning process anyway 475206917Smarius (although for symbols that are provided only via a macro, the result 476206917Smarius is a compilation error rather than a warning containing 477206917Smarius "literal string"). Also note that in C++, it is only safe to use if 478206917Smarius FUNCTION has no overloads. 479206917Smarius 480206917Smarius For an example, it is possible to poison 'getline' by: 481206917Smarius - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], 482206917Smarius [getline]) in configure.ac, which potentially defines 483206917Smarius HAVE_RAW_DECL_GETLINE 484206917Smarius - adding this code to a header that wraps the system <stdio.h>: 485206917Smarius #undef getline 486206917Smarius #if HAVE_RAW_DECL_GETLINE 487206917Smarius _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" 488206917Smarius "not universally present; use the gnulib module getline"); 489206917Smarius #endif 490206917Smarius 491206917Smarius It is not possible to directly poison global variables. But it is 492206917Smarius possible to write a wrapper accessor function, and poison that 493206917Smarius (less common usage, like &environ, will cause a compilation error 494206917Smarius rather than issue the nice warning, but the end result of informing 495206917Smarius the developer about their portability problem is still achieved): 496206917Smarius #if HAVE_RAW_DECL_ENVIRON 497206917Smarius static char *** 498206917Smarius rpl_environ (void) { return &environ; } 499206917Smarius _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); 500206917Smarius # undef environ 501206917Smarius # define environ (*rpl_environ ()) 502206917Smarius #endif 503206917Smarius or better (avoiding contradictory use of 'static' and 'extern'): 504206917Smarius #if HAVE_RAW_DECL_ENVIRON 505206917Smarius static char *** 506206917Smarius _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") 507206917Smarius rpl_environ (void) { return &environ; } 508206917Smarius # undef environ 509206917Smarius # define environ (*rpl_environ ()) 510206917Smarius #endif 511206917Smarius */ 512206917Smarius#ifndef _GL_WARN_ON_USE 513206917Smarius 514206917Smarius# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 515206917Smarius/* A compiler attribute is available in gcc versions 4.3.0 and later. */ 516206917Smarius# define _GL_WARN_ON_USE(function, message) \ 517206917Smariusextern __typeof__ (function) function __attribute__ ((__warning__ (message))) 518206917Smarius# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 519206917Smarius __attribute__ ((__warning__ (message))) 520206917Smarius# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 521206917Smarius/* Verify the existence of the function. */ 522206917Smarius# define _GL_WARN_ON_USE(function, message) \ 523206917Smariusextern __typeof__ (function) function 524206917Smarius# define _GL_WARN_ON_USE_ATTRIBUTE(message) 525206917Smarius# else /* Unsupported. */ 526206917Smarius# define _GL_WARN_ON_USE(function, message) \ 527206917Smarius_GL_WARN_EXTERN_C int _gl_warn_on_use 528206917Smarius# define _GL_WARN_ON_USE_ATTRIBUTE(message) 529206917Smarius# endif 530206917Smarius#endif 531206917Smarius 532206917Smarius/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") 533206917Smarius is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the 534206917Smarius function is declared with the given prototype, consisting of return type, 535206917Smarius parameters, and attributes. 536206917Smarius This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 537206917Smarius not work in this case. */ 538206917Smarius#ifndef _GL_WARN_ON_USE_CXX 539206917Smarius# if !defined __cplusplus 540206917Smarius# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 541206917Smarius _GL_WARN_ON_USE (function, msg) 542206917Smarius# else 543206917Smarius# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 544206917Smarius# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 545206917Smariusextern rettype function parameters_and_attributes \ 546206917Smarius __attribute__ ((__warning__ (msg))) 547206917Smarius# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 548206917Smarius/* Verify the existence of the function. */ 549206917Smarius# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 550206917Smariusextern rettype function parameters_and_attributes 551206917Smarius# else /* Unsupported. */ 552206917Smarius# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 553206917Smarius_GL_WARN_EXTERN_C int _gl_warn_on_use 554206917Smarius# endif 555206917Smarius# endif 556206917Smarius#endif 557206917Smarius 558206917Smarius/* _GL_WARN_EXTERN_C declaration; 559206917Smarius performs the declaration with C linkage. */ 560206917Smarius#ifndef _GL_WARN_EXTERN_C 561206917Smarius# if defined __cplusplus 562206917Smarius# define _GL_WARN_EXTERN_C extern "C" 563206917Smarius# else 564206917Smarius# define _GL_WARN_EXTERN_C extern 565206917Smarius# endif 566206917Smarius#endif 567206917Smarius 568206917Smarius 569206917Smarius/* Declare overridden functions. */ 570206917Smarius 571206917Smarius#if 0 572206917Smarius# if 0 573206917Smarius# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 574206917Smarius# undef creat 575206917Smarius# define creat rpl_creat 576206917Smarius# endif 577206917Smarius_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode) 578206917Smarius _GL_ARG_NONNULL ((1))); 579206917Smarius_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode)); 580206917Smarius# else 581206917Smarius_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode)); 582206917Smarius# endif 583206917Smarius_GL_CXXALIASWARN (creat); 584206917Smarius#elif defined GNULIB_POSIXCHECK 585206917Smarius# undef creat 586206917Smarius/* Assume creat is always declared. */ 587206917Smarius_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - " 588206917Smarius "use gnulib module creat for portability"); 589206917Smarius#endif 590206917Smarius 591206917Smarius#if 1 592206917Smarius# if 0 593206917Smarius# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 594206917Smarius# undef fcntl 595206917Smarius# define fcntl rpl_fcntl 596206917Smarius# endif 597206917Smarius_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...)); 598206917Smarius_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...)); 599206917Smarius# if !GNULIB_defined_rpl_fcntl 600206917Smarius# define GNULIB_defined_rpl_fcntl 1 601206917Smarius# endif 602206917Smarius# else 603206917Smarius# if !1 604206917Smarius_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...)); 605206917Smarius# if !GNULIB_defined_fcntl 606206917Smarius# define GNULIB_defined_fcntl 1 607206917Smarius# endif 608206917Smarius# endif 609206917Smarius_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...)); 610206917Smarius# endif 611206917Smarius_GL_CXXALIASWARN (fcntl); 612206917Smarius#elif defined GNULIB_POSIXCHECK 613206917Smarius# undef fcntl 614206917Smarius# if HAVE_RAW_DECL_FCNTL 615206917Smarius_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " 616206917Smarius "use gnulib module fcntl for portability"); 617206917Smarius# endif 618206917Smarius#endif 619206917Smarius 620206917Smarius#if 1 621206917Smarius# if 0 622206917Smarius# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 623206917Smarius# undef open 624206917Smarius# define open rpl_open 625206917Smarius# endif 626206917Smarius_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 627206917Smarius _GL_ARG_NONNULL ((1))); 628206917Smarius_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 629206917Smarius# else 630206917Smarius_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 631206917Smarius# endif 632228975Suqs/* On HP-UX 11, in C++ mode, open() is defined as an inline function with a 633206917Smarius default argument. _GL_CXXALIASWARN does not work in this case. */ 634206917Smarius# if !defined __hpux 635206917Smarius_GL_CXXALIASWARN (open); 636206917Smarius# endif 637206917Smarius#elif defined GNULIB_POSIXCHECK 638206917Smarius# undef open 639206917Smarius/* Assume open is always declared. */ 640206917Smarius_GL_WARN_ON_USE (open, "open is not always POSIX compliant - " 641206917Smarius "use gnulib module open for portability"); 642206917Smarius#endif 643206917Smarius 644206917Smarius#if 1 645206917Smarius# if 0 646206917Smarius# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 647206917Smarius# undef openat 648206917Smarius# define openat rpl_openat 649206917Smarius# endif 650206917Smarius_GL_FUNCDECL_RPL (openat, int, 651206917Smarius (int fd, char const *file, int flags, /* mode_t mode */ ...) 652206917Smarius _GL_ARG_NONNULL ((2))); 653206917Smarius_GL_CXXALIAS_RPL (openat, int, 654206917Smarius (int fd, char const *file, int flags, /* mode_t mode */ ...)); 655206917Smarius# else 656206917Smarius# if !1 657206917Smarius_GL_FUNCDECL_SYS (openat, int, 658206917Smarius (int fd, char const *file, int flags, /* mode_t mode */ ...) 659206917Smarius _GL_ARG_NONNULL ((2))); 660206917Smarius# endif 661206917Smarius_GL_CXXALIAS_SYS (openat, int, 662206917Smarius (int fd, char const *file, int flags, /* mode_t mode */ ...)); 663206917Smarius# endif 664206917Smarius_GL_CXXALIASWARN (openat); 665206917Smarius#elif defined GNULIB_POSIXCHECK 666206917Smarius# undef openat 667206917Smarius# if HAVE_RAW_DECL_OPENAT 668206917Smarius_GL_WARN_ON_USE (openat, "openat is not portable - " 669206917Smarius "use gnulib module openat for portability"); 670206917Smarius# endif 671206917Smarius#endif 672206917Smarius 673206917Smarius 674206917Smarius/* Fix up the FD_* macros, only known to be missing on mingw. */ 675206917Smarius 676206917Smarius#ifndef FD_CLOEXEC 677206917Smarius# define FD_CLOEXEC 1 678206917Smarius#endif 679206917Smarius 680206917Smarius/* Fix up the supported F_* macros. Intentionally leave other F_* 681206917Smarius macros undefined. Only known to be missing on mingw. */ 682206917Smarius 683206917Smarius#ifndef F_DUPFD_CLOEXEC 684206917Smarius# define F_DUPFD_CLOEXEC 0x40000000 685206917Smarius/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */ 686206917Smarius# define GNULIB_defined_F_DUPFD_CLOEXEC 1 687206917Smarius#else 688206917Smarius# define GNULIB_defined_F_DUPFD_CLOEXEC 0 689206917Smarius#endif 690206917Smarius 691206917Smarius#ifndef F_DUPFD 692206917Smarius# define F_DUPFD 1 693206917Smarius#endif 694206917Smarius 695206917Smarius#ifndef F_GETFD 696206917Smarius# define F_GETFD 2 697206917Smarius#endif 698206917Smarius 699206917Smarius/* Fix up the O_* macros. */ 700206917Smarius 701206917Smarius/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT 702206917Smarius to values outside 'int' range, so omit these misdefinitions. 703206917Smarius But avoid namespace pollution on non-AIX systems. */ 704206917Smarius#ifdef _AIX 705206917Smarius# include <limits.h> 706206917Smarius# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX) 707206917Smarius# undef O_CLOEXEC 708206917Smarius# endif 709206917Smarius# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX) 710206917Smarius# undef O_NOFOLLOW 711206917Smarius# endif 712206917Smarius# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX) 713206917Smarius# undef O_TTY_INIT 714206917Smarius# endif 715206917Smarius#endif 716206917Smarius 717206917Smarius#if !defined O_DIRECT && defined O_DIRECTIO 718206917Smarius/* Tru64 spells it 'O_DIRECTIO'. */ 719206917Smarius# define O_DIRECT O_DIRECTIO 720206917Smarius#endif 721206917Smarius 722206917Smarius#if !defined O_CLOEXEC && defined O_NOINHERIT 723206917Smarius/* Mingw spells it 'O_NOINHERIT'. */ 724206917Smarius# define O_CLOEXEC O_NOINHERIT 725206917Smarius#endif 726206917Smarius 727206917Smarius#ifndef O_CLOEXEC 728206917Smarius# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */ 729206917Smarius# define GNULIB_defined_O_CLOEXEC 1 730206917Smarius#else 731206917Smarius# define GNULIB_defined_O_CLOEXEC 0 732206917Smarius#endif 733206917Smarius 734206917Smarius#ifndef O_DIRECT 735206917Smarius# define O_DIRECT 0 736206917Smarius#endif 737206917Smarius 738206917Smarius#ifndef O_DIRECTORY 739206917Smarius# define O_DIRECTORY 0 740206917Smarius#endif 741206917Smarius 742206917Smarius#ifndef O_DSYNC 743206917Smarius# define O_DSYNC 0 744206917Smarius#endif 745206917Smarius 746206917Smarius#ifndef O_EXEC 747206917Smarius# define O_EXEC O_RDONLY /* This is often close enough in older systems. */ 748206917Smarius#endif 749206917Smarius 750206917Smarius#ifndef O_IGNORE_CTTY 751206917Smarius# define O_IGNORE_CTTY 0 752206917Smarius#endif 753206917Smarius 754206917Smarius#ifndef O_NDELAY 755206917Smarius# define O_NDELAY 0 756206917Smarius#endif 757206917Smarius 758206917Smarius#ifndef O_NOATIME 759206917Smarius# define O_NOATIME 0 760206917Smarius#endif 761206917Smarius 762206917Smarius#ifndef O_NONBLOCK 763206917Smarius# define O_NONBLOCK O_NDELAY 764206917Smarius#endif 765206917Smarius 766206917Smarius/* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero 767206917Smarius value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY 768206917Smarius or to 0 as fallback. */ 769206917Smarius#if 0 770206917Smarius# if O_NONBLOCK 771206917Smarius# define GNULIB_defined_O_NONBLOCK 0 772# else 773# define GNULIB_defined_O_NONBLOCK 1 774# undef O_NONBLOCK 775# define O_NONBLOCK 0x40000000 776# endif 777#endif 778 779#ifndef O_NOCTTY 780# define O_NOCTTY 0 781#endif 782 783#ifndef O_NOFOLLOW 784# define O_NOFOLLOW 0 785#endif 786 787#ifndef O_NOLINK 788# define O_NOLINK 0 789#endif 790 791#ifndef O_NOLINKS 792# define O_NOLINKS 0 793#endif 794 795#ifndef O_NOTRANS 796# define O_NOTRANS 0 797#endif 798 799#ifndef O_RSYNC 800# define O_RSYNC 0 801#endif 802 803#ifndef O_SEARCH 804# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */ 805#endif 806 807#ifndef O_SYNC 808# define O_SYNC 0 809#endif 810 811#ifndef O_TTY_INIT 812# define O_TTY_INIT 0 813#endif 814 815#if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH) 816# undef O_ACCMODE 817# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH) 818#endif 819 820/* For systems that distinguish between text and binary I/O. 821 O_BINARY is usually declared in fcntl.h */ 822#if !defined O_BINARY && defined _O_BINARY 823 /* For MSC-compatible compilers. */ 824# define O_BINARY _O_BINARY 825# define O_TEXT _O_TEXT 826#endif 827 828#if defined __BEOS__ || defined __HAIKU__ 829 /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */ 830# undef O_BINARY 831# undef O_TEXT 832#endif 833 834#ifndef O_BINARY 835# define O_BINARY 0 836# define O_TEXT 0 837#endif 838 839/* Fix up the AT_* macros. */ 840 841/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its 842 value exceeds INT_MAX, so its use as an int doesn't conform to the 843 C standard, and GCC and Sun C complain in some cases. If the bug 844 is present, undef AT_FDCWD here, so it can be redefined below. */ 845#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 846# undef AT_FDCWD 847#endif 848 849/* Use the same bit pattern as Solaris 9, but with the proper 850 signedness. The bit pattern is important, in case this actually is 851 Solaris with the above workaround. */ 852#ifndef AT_FDCWD 853# define AT_FDCWD (-3041965) 854#endif 855 856/* Use the same values as Solaris 9. This shouldn't matter, but 857 there's no real reason to differ. */ 858#ifndef AT_SYMLINK_NOFOLLOW 859# define AT_SYMLINK_NOFOLLOW 4096 860#endif 861 862#ifndef AT_REMOVEDIR 863# define AT_REMOVEDIR 1 864#endif 865 866/* Solaris 9 lacks these two, so just pick unique values. */ 867#ifndef AT_SYMLINK_FOLLOW 868# define AT_SYMLINK_FOLLOW 2 869#endif 870 871#ifndef AT_EACCESS 872# define AT_EACCESS 4 873#endif 874 875 876#endif /* _GL_FCNTL_H */ 877#endif /* _GL_FCNTL_H */ 878#endif 879