1139825Simp/* This file is automatically generated. DO NOT EDIT! */ 299654Sbenno/* Generated from: NetBSD: mknative-gdb,v 1.12 2020/09/17 16:54:31 christos Exp */ 399654Sbenno/* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp */ 499654Sbenno 599654Sbenno/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 699654Sbenno/* Like <fcntl.h>, but with non-working flags defined to 0. 799654Sbenno 899654Sbenno Copyright (C) 2006-2020 Free Software Foundation, Inc. 999654Sbenno 1099654Sbenno This program is free software: you can redistribute it and/or modify 1199654Sbenno it under the terms of the GNU General Public License as published by 1299654Sbenno the Free Software Foundation; either version 3 of the License, or 1399654Sbenno (at your option) any later version. 1499654Sbenno 1599654Sbenno This program is distributed in the hope that it will be useful, 1699654Sbenno but WITHOUT ANY WARRANTY; without even the implied warranty of 1799654Sbenno MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1899654Sbenno GNU General Public License for more details. 1999654Sbenno 2099654Sbenno You should have received a copy of the GNU General Public License 2199654Sbenno along with this program. If not, see <https://www.gnu.org/licenses/>. */ 2299654Sbenno 2399654Sbenno/* written by Paul Eggert */ 2499654Sbenno 2599654Sbenno#if __GNUC__ >= 3 2699654Sbenno#pragma GCC system_header 2799654Sbenno#endif 2899654Sbenno 2999654Sbenno 3099654Sbenno#if defined __need_system_fcntl_h 3199654Sbenno/* Special invocation convention. */ 3299654Sbenno 33209486Snwhitehorn/* Needed before <sys/stat.h>. 34171805Smarcel May also define off_t to a 64-bit type on native Windows. */ 35209486Snwhitehorn#include <sys/types.h> 3699654Sbenno/* On some systems other than glibc, <sys/stat.h> is a prerequisite of 3799654Sbenno <fcntl.h>. On glibc systems, we would like to avoid namespace pollution. 3899654Sbenno But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an 3999654Sbenno extern "C" { ... } block, which leads to errors in C++ mode with the 4099654Sbenno overridden <sys/stat.h> from gnulib. These errors are known to be gone 4199654Sbenno with g++ version >= 4.3. */ 4299654Sbenno#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))) 4399654Sbenno# include <sys/stat.h> 4499654Sbenno#endif 4599654Sbenno#include_next <fcntl.h> 4699654Sbenno 4799654Sbenno/* Native Windows platforms declare open(), creat() in <io.h>. */ 4899654Sbenno#if (0 || 1 || defined GNULIB_POSIXCHECK) \ 4999654Sbenno && (defined _WIN32 && ! defined __CYGWIN__) 5099654Sbenno# include <io.h> 51171805Smarcel#endif 52171805Smarcel 5399654Sbenno#else 5499654Sbenno/* Normal invocation convention. */ 5599654Sbenno 56209298Snwhitehorn#ifndef _GL_FCNTL_H 5799654Sbenno 58171805Smarcel/* Needed before <sys/stat.h>. 59171805Smarcel May also define off_t to a 64-bit type on native Windows. */ 60171805Smarcel#include <sys/types.h> 61171805Smarcel/* On some systems other than glibc, <sys/stat.h> is a prerequisite of 62171805Smarcel <fcntl.h>. On glibc systems, we would like to avoid namespace pollution. 6399654Sbenno But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an 64171805Smarcel extern "C" { ... } block, which leads to errors in C++ mode with the 65171805Smarcel overridden <sys/stat.h> from gnulib. These errors are known to be gone 6699654Sbenno with g++ version >= 4.3. */ 67171805Smarcel#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))) 68171805Smarcel# include <sys/stat.h> 69124469Sgrehan#endif 70171805Smarcel/* The include_next requires a split double-inclusion guard. */ 71176208Smarcel#include_next <fcntl.h> 72171805Smarcel 73176208Smarcel/* Native Windows platforms declare open(), creat() in <io.h>. */ 74171805Smarcel#if (0 || 1 || defined GNULIB_POSIXCHECK) \ 7599654Sbenno && (defined _WIN32 && ! defined __CYGWIN__) 76209486Snwhitehorn# include <io.h> 77209725Snwhitehorn#endif 78176208Smarcel 79176208Smarcel#ifndef _GL_FCNTL_H 80171805Smarcel#define _GL_FCNTL_H 81176208Smarcel 82209486Snwhitehorn#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ 83124469Sgrehan# include <unistd.h> 8499654Sbenno#endif 85124469Sgrehan 86218075Smarcel 87124469Sgrehan/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 88124469Sgrehan/* C++ compatible function declaration macros. 89178628Smarcel Copyright (C) 2010-2020 Free Software Foundation, Inc. 90124469Sgrehan 91103603Sgrehan This program is free software: you can redistribute it and/or modify it 92124469Sgrehan under the terms of the GNU General Public License as published 93171805Smarcel by the Free Software Foundation; either version 3 of the License, or 94103603Sgrehan (at your option) any later version. 95171805Smarcel 96171805Smarcel This program is distributed in the hope that it will be useful, 97171805Smarcel but WITHOUT ANY WARRANTY; without even the implied warranty of 98124469Sgrehan MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 99171805Smarcel General Public License for more details. 100171805Smarcel 101171805Smarcel You should have received a copy of the GNU General Public License 102171805Smarcel along with this program. If not, see <https://www.gnu.org/licenses/>. */ 103171805Smarcel 104171805Smarcel#ifndef _GL_CXXDEFS_H 105171805Smarcel#define _GL_CXXDEFS_H 106171805Smarcel 107208149Snwhitehorn/* Begin/end the GNULIB_NAMESPACE namespace. */ 108208149Snwhitehorn#if defined __cplusplus && defined GNULIB_NAMESPACE 109208149Snwhitehorn# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { 110208149Snwhitehorn# define _GL_END_NAMESPACE } 111208149Snwhitehorn#else 112208149Snwhitehorn# define _GL_BEGIN_NAMESPACE 113208149Snwhitehorn# define _GL_END_NAMESPACE 114208149Snwhitehorn#endif 115208149Snwhitehorn 116208149Snwhitehorn/* The three most frequent use cases of these macros are: 117209298Snwhitehorn 118209298Snwhitehorn * For providing a substitute for a function that is missing on some 119209298Snwhitehorn platforms, but is declared and works fine on the platforms on which 120209485Smarcel it exists: 121209485Smarcel 122209485Smarcel #if @GNULIB_FOO@ 123209485Smarcel # if !@HAVE_FOO@ 124209485Smarcel _GL_FUNCDECL_SYS (foo, ...); 125209485Smarcel # endif 126209485Smarcel _GL_CXXALIAS_SYS (foo, ...); 127209485Smarcel _GL_CXXALIASWARN (foo); 128209485Smarcel #elif defined GNULIB_POSIXCHECK 129209298Snwhitehorn ... 130209298Snwhitehorn #endif 131209298Snwhitehorn 132209298Snwhitehorn * For providing a replacement for a function that exists on all platforms, 133209298Snwhitehorn but is broken/insufficient and needs to be replaced on some platforms: 134209298Snwhitehorn 135209485Smarcel #if @GNULIB_FOO@ 136209298Snwhitehorn # if @REPLACE_FOO@ 137209298Snwhitehorn # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 138209298Snwhitehorn # undef foo 139209298Snwhitehorn # define foo rpl_foo 140209298Snwhitehorn # endif 141209298Snwhitehorn _GL_FUNCDECL_RPL (foo, ...); 142209298Snwhitehorn _GL_CXXALIAS_RPL (foo, ...); 143209298Snwhitehorn # else 144209298Snwhitehorn _GL_CXXALIAS_SYS (foo, ...); 145209298Snwhitehorn # endif 146209298Snwhitehorn _GL_CXXALIASWARN (foo); 147124469Sgrehan #elif defined GNULIB_POSIXCHECK 148124469Sgrehan ... 14999654Sbenno #endif 15099654Sbenno 15199654Sbenno * For providing a replacement for a function that exists on some platforms 15299654Sbenno but is broken/insufficient and needs to be replaced on some of them and 15399654Sbenno is additionally either missing or undeclared on some other platforms: 15499654Sbenno 15599654Sbenno #if @GNULIB_FOO@ 15699654Sbenno # if @REPLACE_FOO@ 15799654Sbenno # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 15899654Sbenno # undef foo 15999654Sbenno # define foo rpl_foo 16099654Sbenno # endif 16199654Sbenno _GL_FUNCDECL_RPL (foo, ...); 16299654Sbenno _GL_CXXALIAS_RPL (foo, ...); 163124469Sgrehan # else 164110167Sbenno # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 165124469Sgrehan _GL_FUNCDECL_SYS (foo, ...); 166110167Sbenno # endif 16799654Sbenno _GL_CXXALIAS_SYS (foo, ...); 168111156Sgrehan # endif 169193909Sgrehan _GL_CXXALIASWARN (foo); 170111156Sgrehan #elif defined GNULIB_POSIXCHECK 171193909Sgrehan ... 172111156Sgrehan #endif 173193909Sgrehan*/ 174193909Sgrehan 175111156Sgrehan/* _GL_EXTERN_C declaration; 176124469Sgrehan performs the declaration with C linkage. */ 177124469Sgrehan#if defined __cplusplus 178124469Sgrehan# define _GL_EXTERN_C extern "C" 179124469Sgrehan#else 18099654Sbenno# define _GL_EXTERN_C extern 181178628Smarcel#endif 182178628Smarcel 183178628Smarcel/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 184176208Smarcel declares a replacement function, named rpl_func, with the given prototype, 185176208Smarcel consisting of return type, parameters, and attributes. 186176208Smarcel Example: 187176208Smarcel _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 188209299Snwhitehorn _GL_ARG_NONNULL ((1))); 189176208Smarcel */ 190176208Smarcel#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 191176208Smarcel _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 192176208Smarcel#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 19399654Sbenno _GL_EXTERN_C rettype rpl_func parameters_and_attributes 194176208Smarcel 195176208Smarcel/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 196176208Smarcel declares the system function, named func, with the given prototype, 197176208Smarcel consisting of return type, parameters, and attributes. 198176208Smarcel Example: 199176208Smarcel _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 200176208Smarcel _GL_ARG_NONNULL ((1))); 20199654Sbenno */ 20299654Sbenno#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 20399654Sbenno _GL_EXTERN_C rettype func parameters_and_attributes 20499654Sbenno 20599654Sbenno/* _GL_CXXALIAS_RPL (func, rettype, parameters); 20699654Sbenno declares a C++ alias called GNULIB_NAMESPACE::func 20799654Sbenno that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 20899654Sbenno Example: 20999654Sbenno _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 21099654Sbenno 211209725Snwhitehorn Wrapping rpl_func in an object with an inline conversion operator 212103603Sgrehan avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is 213209725Snwhitehorn actually used in the program. */ 214209725Snwhitehorn#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 21599654Sbenno _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 21699654Sbenno#if defined __cplusplus && defined GNULIB_NAMESPACE 217183028Smarcel# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 218183028Smarcel namespace GNULIB_NAMESPACE \ 219183028Smarcel { \ 220218075Smarcel static const struct _gl_ ## func ## _wrapper \ 22199654Sbenno { \ 222209298Snwhitehorn typedef rettype (*type) parameters; \ 223209298Snwhitehorn \ 224209298Snwhitehorn inline operator type () const \ 225209298Snwhitehorn { \ 22699654Sbenno return ::rpl_func; \ 22799654Sbenno } \ 22899654Sbenno } func = {}; \ 22999654Sbenno } \ 230171805Smarcel _GL_EXTERN_C int _gl_cxxalias_dummy 23199654Sbenno#else 23299654Sbenno# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 233171805Smarcel _GL_EXTERN_C int _gl_cxxalias_dummy 234222813Sattilio#endif 235209486Snwhitehorn 236209486Snwhitehorn/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 237209486Snwhitehorn is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 238209486Snwhitehorn except that the C function rpl_func may have a slightly different 239209486Snwhitehorn declaration. A cast is used to silence the "invalid conversion" error 240209486Snwhitehorn that would otherwise occur. */ 241209486Snwhitehorn#if defined __cplusplus && defined GNULIB_NAMESPACE 242209486Snwhitehorn# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 243222813Sattilio namespace GNULIB_NAMESPACE \ 244222813Sattilio { \ 245222813Sattilio static const struct _gl_ ## func ## _wrapper \ 246222813Sattilio { \ 247222813Sattilio typedef rettype (*type) parameters; \ 248222813Sattilio \ 249209486Snwhitehorn inline operator type () const \ 250209486Snwhitehorn { \ 251209486Snwhitehorn return reinterpret_cast<type>(::rpl_func); \ 252176918Smarcel } \ 253176918Smarcel } func = {}; \ 254176918Smarcel } \ 255176918Smarcel _GL_EXTERN_C int _gl_cxxalias_dummy 256176918Smarcel#else 257176918Smarcel# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 258176918Smarcel _GL_EXTERN_C int _gl_cxxalias_dummy 259176918Smarcel#endif 260176918Smarcel 261176918Smarcel/* _GL_CXXALIAS_SYS (func, rettype, parameters); 262176918Smarcel declares a C++ alias called GNULIB_NAMESPACE::func 263176918Smarcel that redirects to the system provided function func, if GNULIB_NAMESPACE 264176918Smarcel is defined. 265176918Smarcel Example: 266176918Smarcel _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 267176918Smarcel 268176918Smarcel Wrapping func in an object with an inline conversion operator 269176918Smarcel avoids a reference to func unless GNULIB_NAMESPACE::func is 270176918Smarcel actually used in the program. */ 271209298Snwhitehorn#if defined __cplusplus && defined GNULIB_NAMESPACE 272209298Snwhitehorn# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 273209298Snwhitehorn namespace GNULIB_NAMESPACE \ 274209298Snwhitehorn { \ 275209298Snwhitehorn static const struct _gl_ ## func ## _wrapper \ 276209298Snwhitehorn { \ 277209298Snwhitehorn typedef rettype (*type) parameters; \ 278209298Snwhitehorn \ 279209298Snwhitehorn inline operator type () const \ 280209298Snwhitehorn { \ 281209298Snwhitehorn return ::func; \ 282176918Smarcel } \ 283171805Smarcel } func = {}; \ 28499654Sbenno } \ 285171805Smarcel _GL_EXTERN_C int _gl_cxxalias_dummy 286183028Smarcel#else 28799654Sbenno# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 288192532Sraj _GL_EXTERN_C int _gl_cxxalias_dummy 289192532Sraj#endif 290209725Snwhitehorn 291209725Snwhitehorn/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 292183028Smarcel is like _GL_CXXALIAS_SYS (func, rettype, parameters); 293171805Smarcel except that the C function func may have a slightly different declaration. 294183028Smarcel A cast is used to silence the "invalid conversion" error that would 295171805Smarcel otherwise occur. */ 296171805Smarcel#if defined __cplusplus && defined GNULIB_NAMESPACE 297171805Smarcel# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 298171805Smarcel namespace GNULIB_NAMESPACE \ 299124469Sgrehan { \ 30099654Sbenno static const struct _gl_ ## func ## _wrapper \ 30199654Sbenno { \ 302171805Smarcel typedef rettype (*type) parameters; \ 303171805Smarcel \ 30499654Sbenno inline operator type () const \ 305171805Smarcel { \ 306171805Smarcel return reinterpret_cast<type>(::func); \ 30799654Sbenno } \ 30899654Sbenno } func = {}; \ 309176208Smarcel } \ 310176208Smarcel _GL_EXTERN_C int _gl_cxxalias_dummy 311176208Smarcel#else 312176208Smarcel# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 313176208Smarcel _GL_EXTERN_C int _gl_cxxalias_dummy 314176208Smarcel#endif 315176208Smarcel 316176208Smarcel/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 317176208Smarcel is like _GL_CXXALIAS_SYS (func, rettype, parameters); 318176208Smarcel except that the C function is picked among a set of overloaded functions, 319176208Smarcel namely the one with rettype2 and parameters2. Two consecutive casts 32099654Sbenno are used to silence the "cannot find a match" and "invalid conversion" 32199654Sbenno errors that would otherwise occur. */ 322171805Smarcel#if defined __cplusplus && defined GNULIB_NAMESPACE 323171805Smarcel /* The outer cast must be a reinterpret_cast. 32499654Sbenno The inner cast: When the function is defined as a set of overloaded 325171805Smarcel functions, it works as a static_cast<>, choosing the designated variant. 326209725Snwhitehorn When the function is defined as a single variant, it works as a 32799654Sbenno reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 328209725Snwhitehorn# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 329209725Snwhitehorn namespace GNULIB_NAMESPACE \ 330171805Smarcel { \ 331209725Snwhitehorn static const struct _gl_ ## func ## _wrapper \ 33299654Sbenno { \ 33399654Sbenno typedef rettype (*type) parameters; \ 334171805Smarcel \ 335176208Smarcel inline operator type () const \ 336176208Smarcel { \ 337176208Smarcel return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ 338176208Smarcel } \ 339209726Snwhitehorn } func = {}; \ 340209726Snwhitehorn } \ 341176208Smarcel _GL_EXTERN_C int _gl_cxxalias_dummy 342209486Snwhitehorn#else 343209726Snwhitehorn# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 344176208Smarcel _GL_EXTERN_C int _gl_cxxalias_dummy 345209486Snwhitehorn#endif 346176208Smarcel 347176208Smarcel/* _GL_CXXALIASWARN (func); 348176208Smarcel causes a warning to be emitted when ::func is used but not when 349171805Smarcel GNULIB_NAMESPACE::func is used. func must be defined without overloaded 35099654Sbenno variants. */ 351171805Smarcel#if defined __cplusplus && defined GNULIB_NAMESPACE 352171805Smarcel# define _GL_CXXALIASWARN(func) \ 35399654Sbenno _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 354171805Smarcel# define _GL_CXXALIASWARN_1(func,namespace) \ 355176208Smarcel _GL_CXXALIASWARN_2 (func, namespace) 356176208Smarcel/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 357176208Smarcel we enable the warning only when not optimizing. */ 358176208Smarcel# if !__OPTIMIZE__ 359176208Smarcel# define _GL_CXXALIASWARN_2(func,namespace) \ 360176208Smarcel _GL_WARN_ON_USE (func, \ 361176208Smarcel "The symbol ::" #func " refers to the system function. " \ 362176208Smarcel "Use " #namespace "::" #func " instead.") 363176208Smarcel# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 36499654Sbenno# define _GL_CXXALIASWARN_2(func,namespace) \ 36599654Sbenno extern __typeof__ (func) func 366171805Smarcel# else 367171805Smarcel# define _GL_CXXALIASWARN_2(func,namespace) \ 36899654Sbenno _GL_EXTERN_C int _gl_cxxalias_dummy 369171805Smarcel# endif 370171805Smarcel#else 37199654Sbenno# define _GL_CXXALIASWARN(func) \ 372171805Smarcel _GL_EXTERN_C int _gl_cxxalias_dummy 373176208Smarcel#endif 374176208Smarcel 375176208Smarcel/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 376176208Smarcel causes a warning to be emitted when the given overloaded variant of ::func 377176208Smarcel is used but not when GNULIB_NAMESPACE::func is used. */ 378176208Smarcel#if defined __cplusplus && defined GNULIB_NAMESPACE 379176208Smarcel# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 380176208Smarcel _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 381176208Smarcel GNULIB_NAMESPACE) 38299654Sbenno# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 383 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 384/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 385 we enable the warning only when not optimizing. */ 386# if !__OPTIMIZE__ 387# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 388 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 389 "The symbol ::" #func " refers to the system function. " \ 390 "Use " #namespace "::" #func " instead.") 391# else 392# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 393 _GL_EXTERN_C int _gl_cxxalias_dummy 394# endif 395#else 396# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 397 _GL_EXTERN_C int _gl_cxxalias_dummy 398#endif 399 400#endif /* _GL_CXXDEFS_H */ 401 402/* The definition of _GL_ARG_NONNULL is copied here. */ 403/* A C macro for declaring that specific arguments must not be NULL. 404 Copyright (C) 2009-2020 Free Software Foundation, Inc. 405 406 This program is free software: you can redistribute it and/or modify it 407 under the terms of the GNU General Public License as published 408 by the Free Software Foundation; either version 3 of the License, or 409 (at your option) any later version. 410 411 This program is distributed in the hope that it will be useful, 412 but WITHOUT ANY WARRANTY; without even the implied warranty of 413 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 414 General Public License for more details. 415 416 You should have received a copy of the GNU General Public License 417 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 418 419/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 420 that the values passed as arguments n, ..., m must be non-NULL pointers. 421 n = 1 stands for the first argument, n = 2 for the second argument etc. */ 422#ifndef _GL_ARG_NONNULL 423# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 424# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 425# else 426# define _GL_ARG_NONNULL(params) 427# endif 428#endif 429 430/* The definition of _GL_WARN_ON_USE is copied here. */ 431/* A C macro for emitting warnings if a function is used. 432 Copyright (C) 2010-2020 Free Software Foundation, Inc. 433 434 This program is free software: you can redistribute it and/or modify it 435 under the terms of the GNU General Public License as published 436 by the Free Software Foundation; either version 3 of the License, or 437 (at your option) any later version. 438 439 This program is distributed in the hope that it will be useful, 440 but WITHOUT ANY WARRANTY; without even the implied warranty of 441 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 442 General Public License for more details. 443 444 You should have received a copy of the GNU General Public License 445 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 446 447/* _GL_WARN_ON_USE (function, "literal string") issues a declaration 448 for FUNCTION which will then trigger a compiler warning containing 449 the text of "literal string" anywhere that function is called, if 450 supported by the compiler. If the compiler does not support this 451 feature, the macro expands to an unused extern declaration. 452 453 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the 454 attribute used in _GL_WARN_ON_USE. If the compiler does not support 455 this feature, it expands to empty. 456 457 These macros are useful for marking a function as a potential 458 portability trap, with the intent that "literal string" include 459 instructions on the replacement function that should be used 460 instead. 461 _GL_WARN_ON_USE is for functions with 'extern' linkage. 462 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' 463 linkage. 464 465 However, one of the reasons that a function is a portability trap is 466 if it has the wrong signature. Declaring FUNCTION with a different 467 signature in C is a compilation error, so this macro must use the 468 same type as any existing declaration so that programs that avoid 469 the problematic FUNCTION do not fail to compile merely because they 470 included a header that poisoned the function. But this implies that 471 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already 472 have a declaration. Use of this macro implies that there must not 473 be any other macro hiding the declaration of FUNCTION; but 474 undefining FUNCTION first is part of the poisoning process anyway 475 (although for symbols that are provided only via a macro, the result 476 is a compilation error rather than a warning containing 477 "literal string"). Also note that in C++, it is only safe to use if 478 FUNCTION has no overloads. 479 480 For an example, it is possible to poison 'getline' by: 481 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], 482 [getline]) in configure.ac, which potentially defines 483 HAVE_RAW_DECL_GETLINE 484 - adding this code to a header that wraps the system <stdio.h>: 485 #undef getline 486 #if HAVE_RAW_DECL_GETLINE 487 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" 488 "not universally present; use the gnulib module getline"); 489 #endif 490 491 It is not possible to directly poison global variables. But it is 492 possible to write a wrapper accessor function, and poison that 493 (less common usage, like &environ, will cause a compilation error 494 rather than issue the nice warning, but the end result of informing 495 the developer about their portability problem is still achieved): 496 #if HAVE_RAW_DECL_ENVIRON 497 static char *** 498 rpl_environ (void) { return &environ; } 499 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); 500 # undef environ 501 # define environ (*rpl_environ ()) 502 #endif 503 or better (avoiding contradictory use of 'static' and 'extern'): 504 #if HAVE_RAW_DECL_ENVIRON 505 static char *** 506 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") 507 rpl_environ (void) { return &environ; } 508 # undef environ 509 # define environ (*rpl_environ ()) 510 #endif 511 */ 512#ifndef _GL_WARN_ON_USE 513 514# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 515/* A compiler attribute is available in gcc versions 4.3.0 and later. */ 516# define _GL_WARN_ON_USE(function, message) \ 517extern __typeof__ (function) function __attribute__ ((__warning__ (message))) 518# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 519 __attribute__ ((__warning__ (message))) 520# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 521/* Verify the existence of the function. */ 522# define _GL_WARN_ON_USE(function, message) \ 523extern __typeof__ (function) function 524# define _GL_WARN_ON_USE_ATTRIBUTE(message) 525# else /* Unsupported. */ 526# define _GL_WARN_ON_USE(function, message) \ 527_GL_WARN_EXTERN_C int _gl_warn_on_use 528# define _GL_WARN_ON_USE_ATTRIBUTE(message) 529# endif 530#endif 531 532/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") 533 is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the 534 function is declared with the given prototype, consisting of return type, 535 parameters, and attributes. 536 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 537 not work in this case. */ 538#ifndef _GL_WARN_ON_USE_CXX 539# if !defined __cplusplus 540# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 541 _GL_WARN_ON_USE (function, msg) 542# else 543# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 544# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 545extern rettype function parameters_and_attributes \ 546 __attribute__ ((__warning__ (msg))) 547# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 548/* Verify the existence of the function. */ 549# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 550extern rettype function parameters_and_attributes 551# else /* Unsupported. */ 552# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 553_GL_WARN_EXTERN_C int _gl_warn_on_use 554# endif 555# endif 556#endif 557 558/* _GL_WARN_EXTERN_C declaration; 559 performs the declaration with C linkage. */ 560#ifndef _GL_WARN_EXTERN_C 561# if defined __cplusplus 562# define _GL_WARN_EXTERN_C extern "C" 563# else 564# define _GL_WARN_EXTERN_C extern 565# endif 566#endif 567 568 569/* Declare overridden functions. */ 570 571#if 0 572# if 0 573# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 574# undef creat 575# define creat rpl_creat 576# endif 577_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode) 578 _GL_ARG_NONNULL ((1))); 579_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode)); 580# else 581_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode)); 582# endif 583_GL_CXXALIASWARN (creat); 584#elif defined GNULIB_POSIXCHECK 585# undef creat 586/* Assume creat is always declared. */ 587_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - " 588 "use gnulib module creat for portability"); 589#endif 590 591#if 1 592# if 0 593# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 594# undef fcntl 595# define fcntl rpl_fcntl 596# endif 597_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...)); 598_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...)); 599# if !GNULIB_defined_rpl_fcntl 600# define GNULIB_defined_rpl_fcntl 1 601# endif 602# else 603# if !1 604_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...)); 605# if !GNULIB_defined_fcntl 606# define GNULIB_defined_fcntl 1 607# endif 608# endif 609_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...)); 610# endif 611_GL_CXXALIASWARN (fcntl); 612#elif defined GNULIB_POSIXCHECK 613# undef fcntl 614# if HAVE_RAW_DECL_FCNTL 615_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " 616 "use gnulib module fcntl for portability"); 617# endif 618#endif 619 620#if 1 621# if 0 622# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 623# undef open 624# define open rpl_open 625# endif 626_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 627 _GL_ARG_NONNULL ((1))); 628_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 629# else 630_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 631# endif 632/* On HP-UX 11, in C++ mode, open() is defined as an inline function with a 633 default argument. _GL_CXXALIASWARN does not work in this case. */ 634# if !defined __hpux 635_GL_CXXALIASWARN (open); 636# endif 637#elif defined GNULIB_POSIXCHECK 638# undef open 639/* Assume open is always declared. */ 640_GL_WARN_ON_USE (open, "open is not always POSIX compliant - " 641 "use gnulib module open for portability"); 642#endif 643 644#if 1 645# if 0 646# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 647# undef openat 648# define openat rpl_openat 649# endif 650_GL_FUNCDECL_RPL (openat, int, 651 (int fd, char const *file, int flags, /* mode_t mode */ ...) 652 _GL_ARG_NONNULL ((2))); 653_GL_CXXALIAS_RPL (openat, int, 654 (int fd, char const *file, int flags, /* mode_t mode */ ...)); 655# else 656# if !1 657_GL_FUNCDECL_SYS (openat, int, 658 (int fd, char const *file, int flags, /* mode_t mode */ ...) 659 _GL_ARG_NONNULL ((2))); 660# endif 661_GL_CXXALIAS_SYS (openat, int, 662 (int fd, char const *file, int flags, /* mode_t mode */ ...)); 663# endif 664_GL_CXXALIASWARN (openat); 665#elif defined GNULIB_POSIXCHECK 666# undef openat 667# if HAVE_RAW_DECL_OPENAT 668_GL_WARN_ON_USE (openat, "openat is not portable - " 669 "use gnulib module openat for portability"); 670# endif 671#endif 672 673 674/* Fix up the FD_* macros, only known to be missing on mingw. */ 675 676#ifndef FD_CLOEXEC 677# define FD_CLOEXEC 1 678#endif 679 680/* Fix up the supported F_* macros. Intentionally leave other F_* 681 macros undefined. Only known to be missing on mingw. */ 682 683#ifndef F_DUPFD_CLOEXEC 684# define F_DUPFD_CLOEXEC 0x40000000 685/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */ 686# define GNULIB_defined_F_DUPFD_CLOEXEC 1 687#else 688# define GNULIB_defined_F_DUPFD_CLOEXEC 0 689#endif 690 691#ifndef F_DUPFD 692# define F_DUPFD 1 693#endif 694 695#ifndef F_GETFD 696# define F_GETFD 2 697#endif 698 699/* Fix up the O_* macros. */ 700 701/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT 702 to values outside 'int' range, so omit these misdefinitions. 703 But avoid namespace pollution on non-AIX systems. */ 704#ifdef _AIX 705# include <limits.h> 706# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX) 707# undef O_CLOEXEC 708# endif 709# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX) 710# undef O_NOFOLLOW 711# endif 712# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX) 713# undef O_TTY_INIT 714# endif 715#endif 716 717#if !defined O_DIRECT && defined O_DIRECTIO 718/* Tru64 spells it 'O_DIRECTIO'. */ 719# define O_DIRECT O_DIRECTIO 720#endif 721 722#if !defined O_CLOEXEC && defined O_NOINHERIT 723/* Mingw spells it 'O_NOINHERIT'. */ 724# define O_CLOEXEC O_NOINHERIT 725#endif 726 727#ifndef O_CLOEXEC 728# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */ 729# define GNULIB_defined_O_CLOEXEC 1 730#else 731# define GNULIB_defined_O_CLOEXEC 0 732#endif 733 734#ifndef O_DIRECT 735# define O_DIRECT 0 736#endif 737 738#ifndef O_DIRECTORY 739# define O_DIRECTORY 0 740#endif 741 742#ifndef O_DSYNC 743# define O_DSYNC 0 744#endif 745 746#ifndef O_EXEC 747# define O_EXEC O_RDONLY /* This is often close enough in older systems. */ 748#endif 749 750#ifndef O_IGNORE_CTTY 751# define O_IGNORE_CTTY 0 752#endif 753 754#ifndef O_NDELAY 755# define O_NDELAY 0 756#endif 757 758#ifndef O_NOATIME 759# define O_NOATIME 0 760#endif 761 762#ifndef O_NONBLOCK 763# define O_NONBLOCK O_NDELAY 764#endif 765 766/* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero 767 value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY 768 or to 0 as fallback. */ 769#if 0 770# if O_NONBLOCK 771# 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