1*fd82c4c4Schristos /* This file is automatically generated.  DO NOT EDIT! */
2*fd82c4c4Schristos /* Generated from: NetBSD: mknative-gdb,v 1.12 2020/09/17 16:54:31 christos Exp  */
3*fd82c4c4Schristos /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
4*fd82c4c4Schristos 
5*fd82c4c4Schristos /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
6*fd82c4c4Schristos /* Like <fcntl.h>, but with non-working flags defined to 0.
7*fd82c4c4Schristos 
8*fd82c4c4Schristos    Copyright (C) 2006-2020 Free Software Foundation, Inc.
9*fd82c4c4Schristos 
10*fd82c4c4Schristos    This program is free software: you can redistribute it and/or modify
11*fd82c4c4Schristos    it under the terms of the GNU General Public License as published by
12*fd82c4c4Schristos    the Free Software Foundation; either version 3 of the License, or
13*fd82c4c4Schristos    (at your option) any later version.
14*fd82c4c4Schristos 
15*fd82c4c4Schristos    This program is distributed in the hope that it will be useful,
16*fd82c4c4Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
17*fd82c4c4Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*fd82c4c4Schristos    GNU General Public License for more details.
19*fd82c4c4Schristos 
20*fd82c4c4Schristos    You should have received a copy of the GNU General Public License
21*fd82c4c4Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
22*fd82c4c4Schristos 
23*fd82c4c4Schristos /* written by Paul Eggert */
24*fd82c4c4Schristos 
25*fd82c4c4Schristos #if __GNUC__ >= 3
26*fd82c4c4Schristos #pragma GCC system_header
27*fd82c4c4Schristos #endif
28*fd82c4c4Schristos 
29*fd82c4c4Schristos 
30*fd82c4c4Schristos #if defined __need_system_fcntl_h
31*fd82c4c4Schristos /* Special invocation convention.  */
32*fd82c4c4Schristos 
33*fd82c4c4Schristos /* Needed before <sys/stat.h>.
34*fd82c4c4Schristos    May also define off_t to a 64-bit type on native Windows.  */
35*fd82c4c4Schristos #include <sys/types.h>
36*fd82c4c4Schristos /* On some systems other than glibc, <sys/stat.h> is a prerequisite of
37*fd82c4c4Schristos    <fcntl.h>.  On glibc systems, we would like to avoid namespace pollution.
38*fd82c4c4Schristos    But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
39*fd82c4c4Schristos    extern "C" { ... } block, which leads to errors in C++ mode with the
40*fd82c4c4Schristos    overridden <sys/stat.h> from gnulib.  These errors are known to be gone
41*fd82c4c4Schristos    with g++ version >= 4.3.  */
42*fd82c4c4Schristos #if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
43*fd82c4c4Schristos # include <sys/stat.h>
44*fd82c4c4Schristos #endif
45*fd82c4c4Schristos #include_next <fcntl.h>
46*fd82c4c4Schristos 
47*fd82c4c4Schristos /* Native Windows platforms declare open(), creat() in <io.h>.  */
48*fd82c4c4Schristos #if (0 || 1 || defined GNULIB_POSIXCHECK) \
49*fd82c4c4Schristos     && (defined _WIN32 && ! defined __CYGWIN__)
50*fd82c4c4Schristos # include <io.h>
51*fd82c4c4Schristos #endif
52*fd82c4c4Schristos 
53*fd82c4c4Schristos #else
54*fd82c4c4Schristos /* Normal invocation convention.  */
55*fd82c4c4Schristos 
56*fd82c4c4Schristos #ifndef _GL_FCNTL_H
57*fd82c4c4Schristos 
58*fd82c4c4Schristos /* Needed before <sys/stat.h>.
59*fd82c4c4Schristos    May also define off_t to a 64-bit type on native Windows.  */
60*fd82c4c4Schristos #include <sys/types.h>
61*fd82c4c4Schristos /* On some systems other than glibc, <sys/stat.h> is a prerequisite of
62*fd82c4c4Schristos    <fcntl.h>.  On glibc systems, we would like to avoid namespace pollution.
63*fd82c4c4Schristos    But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
64*fd82c4c4Schristos    extern "C" { ... } block, which leads to errors in C++ mode with the
65*fd82c4c4Schristos    overridden <sys/stat.h> from gnulib.  These errors are known to be gone
66*fd82c4c4Schristos    with g++ version >= 4.3.  */
67*fd82c4c4Schristos #if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
68*fd82c4c4Schristos # include <sys/stat.h>
69*fd82c4c4Schristos #endif
70*fd82c4c4Schristos /* The include_next requires a split double-inclusion guard.  */
71*fd82c4c4Schristos #include_next <fcntl.h>
72*fd82c4c4Schristos 
73*fd82c4c4Schristos /* Native Windows platforms declare open(), creat() in <io.h>.  */
74*fd82c4c4Schristos #if (0 || 1 || defined GNULIB_POSIXCHECK) \
75*fd82c4c4Schristos     && (defined _WIN32 && ! defined __CYGWIN__)
76*fd82c4c4Schristos # include <io.h>
77*fd82c4c4Schristos #endif
78*fd82c4c4Schristos 
79*fd82c4c4Schristos #ifndef _GL_FCNTL_H
80*fd82c4c4Schristos #define _GL_FCNTL_H
81*fd82c4c4Schristos 
82*fd82c4c4Schristos #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems.  */
83*fd82c4c4Schristos # include <unistd.h>
84*fd82c4c4Schristos #endif
85*fd82c4c4Schristos 
86*fd82c4c4Schristos 
87*fd82c4c4Schristos /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
88*fd82c4c4Schristos /* C++ compatible function declaration macros.
89*fd82c4c4Schristos    Copyright (C) 2010-2020 Free Software Foundation, Inc.
90*fd82c4c4Schristos 
91*fd82c4c4Schristos    This program is free software: you can redistribute it and/or modify it
92*fd82c4c4Schristos    under the terms of the GNU General Public License as published
93*fd82c4c4Schristos    by the Free Software Foundation; either version 3 of the License, or
94*fd82c4c4Schristos    (at your option) any later version.
95*fd82c4c4Schristos 
96*fd82c4c4Schristos    This program is distributed in the hope that it will be useful,
97*fd82c4c4Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
98*fd82c4c4Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
99*fd82c4c4Schristos    General Public License for more details.
100*fd82c4c4Schristos 
101*fd82c4c4Schristos    You should have received a copy of the GNU General Public License
102*fd82c4c4Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
103*fd82c4c4Schristos 
104*fd82c4c4Schristos #ifndef _GL_CXXDEFS_H
105*fd82c4c4Schristos #define _GL_CXXDEFS_H
106*fd82c4c4Schristos 
107*fd82c4c4Schristos /* Begin/end the GNULIB_NAMESPACE namespace.  */
108*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
109*fd82c4c4Schristos # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
110*fd82c4c4Schristos # define _GL_END_NAMESPACE }
111*fd82c4c4Schristos #else
112*fd82c4c4Schristos # define _GL_BEGIN_NAMESPACE
113*fd82c4c4Schristos # define _GL_END_NAMESPACE
114*fd82c4c4Schristos #endif
115*fd82c4c4Schristos 
116*fd82c4c4Schristos /* The three most frequent use cases of these macros are:
117*fd82c4c4Schristos 
118*fd82c4c4Schristos    * For providing a substitute for a function that is missing on some
119*fd82c4c4Schristos      platforms, but is declared and works fine on the platforms on which
120*fd82c4c4Schristos      it exists:
121*fd82c4c4Schristos 
122*fd82c4c4Schristos        #if @GNULIB_FOO@
123*fd82c4c4Schristos        # if !@HAVE_FOO@
124*fd82c4c4Schristos        _GL_FUNCDECL_SYS (foo, ...);
125*fd82c4c4Schristos        # endif
126*fd82c4c4Schristos        _GL_CXXALIAS_SYS (foo, ...);
127*fd82c4c4Schristos        _GL_CXXALIASWARN (foo);
128*fd82c4c4Schristos        #elif defined GNULIB_POSIXCHECK
129*fd82c4c4Schristos        ...
130*fd82c4c4Schristos        #endif
131*fd82c4c4Schristos 
132*fd82c4c4Schristos    * For providing a replacement for a function that exists on all platforms,
133*fd82c4c4Schristos      but is broken/insufficient and needs to be replaced on some platforms:
134*fd82c4c4Schristos 
135*fd82c4c4Schristos        #if @GNULIB_FOO@
136*fd82c4c4Schristos        # if @REPLACE_FOO@
137*fd82c4c4Schristos        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
138*fd82c4c4Schristos        #   undef foo
139*fd82c4c4Schristos        #   define foo rpl_foo
140*fd82c4c4Schristos        #  endif
141*fd82c4c4Schristos        _GL_FUNCDECL_RPL (foo, ...);
142*fd82c4c4Schristos        _GL_CXXALIAS_RPL (foo, ...);
143*fd82c4c4Schristos        # else
144*fd82c4c4Schristos        _GL_CXXALIAS_SYS (foo, ...);
145*fd82c4c4Schristos        # endif
146*fd82c4c4Schristos        _GL_CXXALIASWARN (foo);
147*fd82c4c4Schristos        #elif defined GNULIB_POSIXCHECK
148*fd82c4c4Schristos        ...
149*fd82c4c4Schristos        #endif
150*fd82c4c4Schristos 
151*fd82c4c4Schristos    * For providing a replacement for a function that exists on some platforms
152*fd82c4c4Schristos      but is broken/insufficient and needs to be replaced on some of them and
153*fd82c4c4Schristos      is additionally either missing or undeclared on some other platforms:
154*fd82c4c4Schristos 
155*fd82c4c4Schristos        #if @GNULIB_FOO@
156*fd82c4c4Schristos        # if @REPLACE_FOO@
157*fd82c4c4Schristos        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
158*fd82c4c4Schristos        #   undef foo
159*fd82c4c4Schristos        #   define foo rpl_foo
160*fd82c4c4Schristos        #  endif
161*fd82c4c4Schristos        _GL_FUNCDECL_RPL (foo, ...);
162*fd82c4c4Schristos        _GL_CXXALIAS_RPL (foo, ...);
163*fd82c4c4Schristos        # else
164*fd82c4c4Schristos        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
165*fd82c4c4Schristos        _GL_FUNCDECL_SYS (foo, ...);
166*fd82c4c4Schristos        #  endif
167*fd82c4c4Schristos        _GL_CXXALIAS_SYS (foo, ...);
168*fd82c4c4Schristos        # endif
169*fd82c4c4Schristos        _GL_CXXALIASWARN (foo);
170*fd82c4c4Schristos        #elif defined GNULIB_POSIXCHECK
171*fd82c4c4Schristos        ...
172*fd82c4c4Schristos        #endif
173*fd82c4c4Schristos */
174*fd82c4c4Schristos 
175*fd82c4c4Schristos /* _GL_EXTERN_C declaration;
176*fd82c4c4Schristos    performs the declaration with C linkage.  */
177*fd82c4c4Schristos #if defined __cplusplus
178*fd82c4c4Schristos # define _GL_EXTERN_C extern "C"
179*fd82c4c4Schristos #else
180*fd82c4c4Schristos # define _GL_EXTERN_C extern
181*fd82c4c4Schristos #endif
182*fd82c4c4Schristos 
183*fd82c4c4Schristos /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
184*fd82c4c4Schristos    declares a replacement function, named rpl_func, with the given prototype,
185*fd82c4c4Schristos    consisting of return type, parameters, and attributes.
186*fd82c4c4Schristos    Example:
187*fd82c4c4Schristos      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
188*fd82c4c4Schristos                                   _GL_ARG_NONNULL ((1)));
189*fd82c4c4Schristos  */
190*fd82c4c4Schristos #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
191*fd82c4c4Schristos   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
192*fd82c4c4Schristos #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
193*fd82c4c4Schristos   _GL_EXTERN_C rettype rpl_func parameters_and_attributes
194*fd82c4c4Schristos 
195*fd82c4c4Schristos /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
196*fd82c4c4Schristos    declares the system function, named func, with the given prototype,
197*fd82c4c4Schristos    consisting of return type, parameters, and attributes.
198*fd82c4c4Schristos    Example:
199*fd82c4c4Schristos      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
200*fd82c4c4Schristos                                   _GL_ARG_NONNULL ((1)));
201*fd82c4c4Schristos  */
202*fd82c4c4Schristos #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
203*fd82c4c4Schristos   _GL_EXTERN_C rettype func parameters_and_attributes
204*fd82c4c4Schristos 
205*fd82c4c4Schristos /* _GL_CXXALIAS_RPL (func, rettype, parameters);
206*fd82c4c4Schristos    declares a C++ alias called GNULIB_NAMESPACE::func
207*fd82c4c4Schristos    that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
208*fd82c4c4Schristos    Example:
209*fd82c4c4Schristos      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
210*fd82c4c4Schristos 
211*fd82c4c4Schristos    Wrapping rpl_func in an object with an inline conversion operator
212*fd82c4c4Schristos    avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
213*fd82c4c4Schristos    actually used in the program.  */
214*fd82c4c4Schristos #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
215*fd82c4c4Schristos   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
216*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
217*fd82c4c4Schristos # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
218*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                                \
219*fd82c4c4Schristos     {                                                         \
220*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper            \
221*fd82c4c4Schristos       {                                                       \
222*fd82c4c4Schristos         typedef rettype (*type) parameters;                   \
223*fd82c4c4Schristos                                                               \
224*fd82c4c4Schristos         inline operator type () const                         \
225*fd82c4c4Schristos         {                                                     \
226*fd82c4c4Schristos           return ::rpl_func;                                  \
227*fd82c4c4Schristos         }                                                     \
228*fd82c4c4Schristos       } func = {};                                            \
229*fd82c4c4Schristos     }                                                         \
230*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
231*fd82c4c4Schristos #else
232*fd82c4c4Schristos # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
233*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
234*fd82c4c4Schristos #endif
235*fd82c4c4Schristos 
236*fd82c4c4Schristos /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
237*fd82c4c4Schristos    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
238*fd82c4c4Schristos    except that the C function rpl_func may have a slightly different
239*fd82c4c4Schristos    declaration.  A cast is used to silence the "invalid conversion" error
240*fd82c4c4Schristos    that would otherwise occur.  */
241*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
242*fd82c4c4Schristos # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
243*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                                     \
244*fd82c4c4Schristos     {                                                              \
245*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper                 \
246*fd82c4c4Schristos       {                                                            \
247*fd82c4c4Schristos         typedef rettype (*type) parameters;                        \
248*fd82c4c4Schristos                                                                    \
249*fd82c4c4Schristos         inline operator type () const                              \
250*fd82c4c4Schristos         {                                                          \
251*fd82c4c4Schristos           return reinterpret_cast<type>(::rpl_func);               \
252*fd82c4c4Schristos         }                                                          \
253*fd82c4c4Schristos       } func = {};                                                 \
254*fd82c4c4Schristos     }                                                              \
255*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
256*fd82c4c4Schristos #else
257*fd82c4c4Schristos # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
258*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
259*fd82c4c4Schristos #endif
260*fd82c4c4Schristos 
261*fd82c4c4Schristos /* _GL_CXXALIAS_SYS (func, rettype, parameters);
262*fd82c4c4Schristos    declares a C++ alias called GNULIB_NAMESPACE::func
263*fd82c4c4Schristos    that redirects to the system provided function func, if GNULIB_NAMESPACE
264*fd82c4c4Schristos    is defined.
265*fd82c4c4Schristos    Example:
266*fd82c4c4Schristos      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
267*fd82c4c4Schristos 
268*fd82c4c4Schristos    Wrapping func in an object with an inline conversion operator
269*fd82c4c4Schristos    avoids a reference to func unless GNULIB_NAMESPACE::func is
270*fd82c4c4Schristos    actually used in the program.  */
271*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
272*fd82c4c4Schristos # define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
273*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                                \
274*fd82c4c4Schristos     {                                                         \
275*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper            \
276*fd82c4c4Schristos       {                                                       \
277*fd82c4c4Schristos         typedef rettype (*type) parameters;                   \
278*fd82c4c4Schristos                                                               \
279*fd82c4c4Schristos         inline operator type () const                         \
280*fd82c4c4Schristos         {                                                     \
281*fd82c4c4Schristos           return ::func;                                      \
282*fd82c4c4Schristos         }                                                     \
283*fd82c4c4Schristos       } func = {};                                            \
284*fd82c4c4Schristos     }                                                         \
285*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
286*fd82c4c4Schristos #else
287*fd82c4c4Schristos # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
288*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
289*fd82c4c4Schristos #endif
290*fd82c4c4Schristos 
291*fd82c4c4Schristos /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
292*fd82c4c4Schristos    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
293*fd82c4c4Schristos    except that the C function func may have a slightly different declaration.
294*fd82c4c4Schristos    A cast is used to silence the "invalid conversion" error that would
295*fd82c4c4Schristos    otherwise occur.  */
296*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
297*fd82c4c4Schristos # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
298*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                          \
299*fd82c4c4Schristos     {                                                   \
300*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper      \
301*fd82c4c4Schristos       {                                                 \
302*fd82c4c4Schristos         typedef rettype (*type) parameters;             \
303*fd82c4c4Schristos                                                         \
304*fd82c4c4Schristos         inline operator type () const                   \
305*fd82c4c4Schristos         {                                               \
306*fd82c4c4Schristos           return reinterpret_cast<type>(::func);        \
307*fd82c4c4Schristos         }                                               \
308*fd82c4c4Schristos       } func = {};                                      \
309*fd82c4c4Schristos     }                                                   \
310*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
311*fd82c4c4Schristos #else
312*fd82c4c4Schristos # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
313*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
314*fd82c4c4Schristos #endif
315*fd82c4c4Schristos 
316*fd82c4c4Schristos /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
317*fd82c4c4Schristos    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
318*fd82c4c4Schristos    except that the C function is picked among a set of overloaded functions,
319*fd82c4c4Schristos    namely the one with rettype2 and parameters2.  Two consecutive casts
320*fd82c4c4Schristos    are used to silence the "cannot find a match" and "invalid conversion"
321*fd82c4c4Schristos    errors that would otherwise occur.  */
322*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
323*fd82c4c4Schristos   /* The outer cast must be a reinterpret_cast.
324*fd82c4c4Schristos      The inner cast: When the function is defined as a set of overloaded
325*fd82c4c4Schristos      functions, it works as a static_cast<>, choosing the designated variant.
326*fd82c4c4Schristos      When the function is defined as a single variant, it works as a
327*fd82c4c4Schristos      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
328*fd82c4c4Schristos # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
329*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                                                \
330*fd82c4c4Schristos     {                                                                         \
331*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper                            \
332*fd82c4c4Schristos       {                                                                       \
333*fd82c4c4Schristos         typedef rettype (*type) parameters;                                   \
334*fd82c4c4Schristos                                                                               \
335*fd82c4c4Schristos         inline operator type () const                                         \
336*fd82c4c4Schristos         {                                                                     \
337*fd82c4c4Schristos           return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
338*fd82c4c4Schristos         }                                                                     \
339*fd82c4c4Schristos       } func = {};                                                            \
340*fd82c4c4Schristos     }                                                                         \
341*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
342*fd82c4c4Schristos #else
343*fd82c4c4Schristos # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
344*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
345*fd82c4c4Schristos #endif
346*fd82c4c4Schristos 
347*fd82c4c4Schristos /* _GL_CXXALIASWARN (func);
348*fd82c4c4Schristos    causes a warning to be emitted when ::func is used but not when
349*fd82c4c4Schristos    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
350*fd82c4c4Schristos    variants.  */
351*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
352*fd82c4c4Schristos # define _GL_CXXALIASWARN(func) \
353*fd82c4c4Schristos    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
354*fd82c4c4Schristos # define _GL_CXXALIASWARN_1(func,namespace) \
355*fd82c4c4Schristos    _GL_CXXALIASWARN_2 (func, namespace)
356*fd82c4c4Schristos /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
357*fd82c4c4Schristos    we enable the warning only when not optimizing.  */
358*fd82c4c4Schristos # if !__OPTIMIZE__
359*fd82c4c4Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
360*fd82c4c4Schristos     _GL_WARN_ON_USE (func, \
361*fd82c4c4Schristos                      "The symbol ::" #func " refers to the system function. " \
362*fd82c4c4Schristos                      "Use " #namespace "::" #func " instead.")
363*fd82c4c4Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
364*fd82c4c4Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
365*fd82c4c4Schristos      extern __typeof__ (func) func
366*fd82c4c4Schristos # else
367*fd82c4c4Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
368*fd82c4c4Schristos      _GL_EXTERN_C int _gl_cxxalias_dummy
369*fd82c4c4Schristos # endif
370*fd82c4c4Schristos #else
371*fd82c4c4Schristos # define _GL_CXXALIASWARN(func) \
372*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
373*fd82c4c4Schristos #endif
374*fd82c4c4Schristos 
375*fd82c4c4Schristos /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
376*fd82c4c4Schristos    causes a warning to be emitted when the given overloaded variant of ::func
377*fd82c4c4Schristos    is used but not when GNULIB_NAMESPACE::func is used.  */
378*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
379*fd82c4c4Schristos # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
380*fd82c4c4Schristos    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
381*fd82c4c4Schristos                         GNULIB_NAMESPACE)
382*fd82c4c4Schristos # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
383*fd82c4c4Schristos    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
384*fd82c4c4Schristos /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
385*fd82c4c4Schristos    we enable the warning only when not optimizing.  */
386*fd82c4c4Schristos # if !__OPTIMIZE__
387*fd82c4c4Schristos #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
388*fd82c4c4Schristos     _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
389*fd82c4c4Schristos                          "The symbol ::" #func " refers to the system function. " \
390*fd82c4c4Schristos                          "Use " #namespace "::" #func " instead.")
391*fd82c4c4Schristos # else
392*fd82c4c4Schristos #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
393*fd82c4c4Schristos      _GL_EXTERN_C int _gl_cxxalias_dummy
394*fd82c4c4Schristos # endif
395*fd82c4c4Schristos #else
396*fd82c4c4Schristos # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
397*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
398*fd82c4c4Schristos #endif
399*fd82c4c4Schristos 
400*fd82c4c4Schristos #endif /* _GL_CXXDEFS_H */
401*fd82c4c4Schristos 
402*fd82c4c4Schristos /* The definition of _GL_ARG_NONNULL is copied here.  */
403*fd82c4c4Schristos /* A C macro for declaring that specific arguments must not be NULL.
404*fd82c4c4Schristos    Copyright (C) 2009-2020 Free Software Foundation, Inc.
405*fd82c4c4Schristos 
406*fd82c4c4Schristos    This program is free software: you can redistribute it and/or modify it
407*fd82c4c4Schristos    under the terms of the GNU General Public License as published
408*fd82c4c4Schristos    by the Free Software Foundation; either version 3 of the License, or
409*fd82c4c4Schristos    (at your option) any later version.
410*fd82c4c4Schristos 
411*fd82c4c4Schristos    This program is distributed in the hope that it will be useful,
412*fd82c4c4Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
413*fd82c4c4Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
414*fd82c4c4Schristos    General Public License for more details.
415*fd82c4c4Schristos 
416*fd82c4c4Schristos    You should have received a copy of the GNU General Public License
417*fd82c4c4Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
418*fd82c4c4Schristos 
419*fd82c4c4Schristos /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
420*fd82c4c4Schristos    that the values passed as arguments n, ..., m must be non-NULL pointers.
421*fd82c4c4Schristos    n = 1 stands for the first argument, n = 2 for the second argument etc.  */
422*fd82c4c4Schristos #ifndef _GL_ARG_NONNULL
423*fd82c4c4Schristos # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
424*fd82c4c4Schristos #  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
425*fd82c4c4Schristos # else
426*fd82c4c4Schristos #  define _GL_ARG_NONNULL(params)
427*fd82c4c4Schristos # endif
428*fd82c4c4Schristos #endif
429*fd82c4c4Schristos 
430*fd82c4c4Schristos /* The definition of _GL_WARN_ON_USE is copied here.  */
431*fd82c4c4Schristos /* A C macro for emitting warnings if a function is used.
432*fd82c4c4Schristos    Copyright (C) 2010-2020 Free Software Foundation, Inc.
433*fd82c4c4Schristos 
434*fd82c4c4Schristos    This program is free software: you can redistribute it and/or modify it
435*fd82c4c4Schristos    under the terms of the GNU General Public License as published
436*fd82c4c4Schristos    by the Free Software Foundation; either version 3 of the License, or
437*fd82c4c4Schristos    (at your option) any later version.
438*fd82c4c4Schristos 
439*fd82c4c4Schristos    This program is distributed in the hope that it will be useful,
440*fd82c4c4Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
441*fd82c4c4Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
442*fd82c4c4Schristos    General Public License for more details.
443*fd82c4c4Schristos 
444*fd82c4c4Schristos    You should have received a copy of the GNU General Public License
445*fd82c4c4Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
446*fd82c4c4Schristos 
447*fd82c4c4Schristos /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
448*fd82c4c4Schristos    for FUNCTION which will then trigger a compiler warning containing
449*fd82c4c4Schristos    the text of "literal string" anywhere that function is called, if
450*fd82c4c4Schristos    supported by the compiler.  If the compiler does not support this
451*fd82c4c4Schristos    feature, the macro expands to an unused extern declaration.
452*fd82c4c4Schristos 
453*fd82c4c4Schristos    _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
454*fd82c4c4Schristos    attribute used in _GL_WARN_ON_USE.  If the compiler does not support
455*fd82c4c4Schristos    this feature, it expands to empty.
456*fd82c4c4Schristos 
457*fd82c4c4Schristos    These macros are useful for marking a function as a potential
458*fd82c4c4Schristos    portability trap, with the intent that "literal string" include
459*fd82c4c4Schristos    instructions on the replacement function that should be used
460*fd82c4c4Schristos    instead.
461*fd82c4c4Schristos    _GL_WARN_ON_USE is for functions with 'extern' linkage.
462*fd82c4c4Schristos    _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
463*fd82c4c4Schristos    linkage.
464*fd82c4c4Schristos 
465*fd82c4c4Schristos    However, one of the reasons that a function is a portability trap is
466*fd82c4c4Schristos    if it has the wrong signature.  Declaring FUNCTION with a different
467*fd82c4c4Schristos    signature in C is a compilation error, so this macro must use the
468*fd82c4c4Schristos    same type as any existing declaration so that programs that avoid
469*fd82c4c4Schristos    the problematic FUNCTION do not fail to compile merely because they
470*fd82c4c4Schristos    included a header that poisoned the function.  But this implies that
471*fd82c4c4Schristos    _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
472*fd82c4c4Schristos    have a declaration.  Use of this macro implies that there must not
473*fd82c4c4Schristos    be any other macro hiding the declaration of FUNCTION; but
474*fd82c4c4Schristos    undefining FUNCTION first is part of the poisoning process anyway
475*fd82c4c4Schristos    (although for symbols that are provided only via a macro, the result
476*fd82c4c4Schristos    is a compilation error rather than a warning containing
477*fd82c4c4Schristos    "literal string").  Also note that in C++, it is only safe to use if
478*fd82c4c4Schristos    FUNCTION has no overloads.
479*fd82c4c4Schristos 
480*fd82c4c4Schristos    For an example, it is possible to poison 'getline' by:
481*fd82c4c4Schristos    - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
482*fd82c4c4Schristos      [getline]) in configure.ac, which potentially defines
483*fd82c4c4Schristos      HAVE_RAW_DECL_GETLINE
484*fd82c4c4Schristos    - adding this code to a header that wraps the system <stdio.h>:
485*fd82c4c4Schristos      #undef getline
486*fd82c4c4Schristos      #if HAVE_RAW_DECL_GETLINE
487*fd82c4c4Schristos      _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
488*fd82c4c4Schristos        "not universally present; use the gnulib module getline");
489*fd82c4c4Schristos      #endif
490*fd82c4c4Schristos 
491*fd82c4c4Schristos    It is not possible to directly poison global variables.  But it is
492*fd82c4c4Schristos    possible to write a wrapper accessor function, and poison that
493*fd82c4c4Schristos    (less common usage, like &environ, will cause a compilation error
494*fd82c4c4Schristos    rather than issue the nice warning, but the end result of informing
495*fd82c4c4Schristos    the developer about their portability problem is still achieved):
496*fd82c4c4Schristos      #if HAVE_RAW_DECL_ENVIRON
497*fd82c4c4Schristos      static char ***
498*fd82c4c4Schristos      rpl_environ (void) { return &environ; }
499*fd82c4c4Schristos      _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
500*fd82c4c4Schristos      # undef environ
501*fd82c4c4Schristos      # define environ (*rpl_environ ())
502*fd82c4c4Schristos      #endif
503*fd82c4c4Schristos    or better (avoiding contradictory use of 'static' and 'extern'):
504*fd82c4c4Schristos      #if HAVE_RAW_DECL_ENVIRON
505*fd82c4c4Schristos      static char ***
506*fd82c4c4Schristos      _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
507*fd82c4c4Schristos      rpl_environ (void) { return &environ; }
508*fd82c4c4Schristos      # undef environ
509*fd82c4c4Schristos      # define environ (*rpl_environ ())
510*fd82c4c4Schristos      #endif
511*fd82c4c4Schristos    */
512*fd82c4c4Schristos #ifndef _GL_WARN_ON_USE
513*fd82c4c4Schristos 
514*fd82c4c4Schristos # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
515*fd82c4c4Schristos /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
516*fd82c4c4Schristos #  define _GL_WARN_ON_USE(function, message) \
517*fd82c4c4Schristos extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
518*fd82c4c4Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
519*fd82c4c4Schristos   __attribute__ ((__warning__ (message)))
520*fd82c4c4Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
521*fd82c4c4Schristos /* Verify the existence of the function.  */
522*fd82c4c4Schristos #  define _GL_WARN_ON_USE(function, message) \
523*fd82c4c4Schristos extern __typeof__ (function) function
524*fd82c4c4Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
525*fd82c4c4Schristos # else /* Unsupported.  */
526*fd82c4c4Schristos #  define _GL_WARN_ON_USE(function, message) \
527*fd82c4c4Schristos _GL_WARN_EXTERN_C int _gl_warn_on_use
528*fd82c4c4Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
529*fd82c4c4Schristos # endif
530*fd82c4c4Schristos #endif
531*fd82c4c4Schristos 
532*fd82c4c4Schristos /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
533*fd82c4c4Schristos    is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the
534*fd82c4c4Schristos    function is declared with the given prototype, consisting of return type,
535*fd82c4c4Schristos    parameters, and attributes.
536*fd82c4c4Schristos    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
537*fd82c4c4Schristos    not work in this case.  */
538*fd82c4c4Schristos #ifndef _GL_WARN_ON_USE_CXX
539*fd82c4c4Schristos # if !defined __cplusplus
540*fd82c4c4Schristos #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
541*fd82c4c4Schristos      _GL_WARN_ON_USE (function, msg)
542*fd82c4c4Schristos # else
543*fd82c4c4Schristos #  if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
544*fd82c4c4Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
545*fd82c4c4Schristos extern rettype function parameters_and_attributes \
546*fd82c4c4Schristos      __attribute__ ((__warning__ (msg)))
547*fd82c4c4Schristos #  elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
548*fd82c4c4Schristos /* Verify the existence of the function.  */
549*fd82c4c4Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
550*fd82c4c4Schristos extern rettype function parameters_and_attributes
551*fd82c4c4Schristos #  else /* Unsupported.  */
552*fd82c4c4Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
553*fd82c4c4Schristos _GL_WARN_EXTERN_C int _gl_warn_on_use
554*fd82c4c4Schristos #  endif
555*fd82c4c4Schristos # endif
556*fd82c4c4Schristos #endif
557*fd82c4c4Schristos 
558*fd82c4c4Schristos /* _GL_WARN_EXTERN_C declaration;
559*fd82c4c4Schristos    performs the declaration with C linkage.  */
560*fd82c4c4Schristos #ifndef _GL_WARN_EXTERN_C
561*fd82c4c4Schristos # if defined __cplusplus
562*fd82c4c4Schristos #  define _GL_WARN_EXTERN_C extern "C"
563*fd82c4c4Schristos # else
564*fd82c4c4Schristos #  define _GL_WARN_EXTERN_C extern
565*fd82c4c4Schristos # endif
566*fd82c4c4Schristos #endif
567*fd82c4c4Schristos 
568*fd82c4c4Schristos 
569*fd82c4c4Schristos /* Declare overridden functions.  */
570*fd82c4c4Schristos 
571*fd82c4c4Schristos #if 0
572*fd82c4c4Schristos # if 0
573*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
574*fd82c4c4Schristos #   undef creat
575*fd82c4c4Schristos #   define creat rpl_creat
576*fd82c4c4Schristos #  endif
577*fd82c4c4Schristos _GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode)
578*fd82c4c4Schristos                              _GL_ARG_NONNULL ((1)));
579*fd82c4c4Schristos _GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
580*fd82c4c4Schristos # else
581*fd82c4c4Schristos _GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
582*fd82c4c4Schristos # endif
583*fd82c4c4Schristos _GL_CXXALIASWARN (creat);
584*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
585*fd82c4c4Schristos # undef creat
586*fd82c4c4Schristos /* Assume creat is always declared.  */
587*fd82c4c4Schristos _GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - "
588*fd82c4c4Schristos                  "use gnulib module creat for portability");
589*fd82c4c4Schristos #endif
590*fd82c4c4Schristos 
591*fd82c4c4Schristos #if 1
592*fd82c4c4Schristos # if 0
593*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
594*fd82c4c4Schristos #   undef fcntl
595*fd82c4c4Schristos #   define fcntl rpl_fcntl
596*fd82c4c4Schristos #  endif
597*fd82c4c4Schristos _GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
598*fd82c4c4Schristos _GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
599*fd82c4c4Schristos #  if !GNULIB_defined_rpl_fcntl
600*fd82c4c4Schristos #   define GNULIB_defined_rpl_fcntl 1
601*fd82c4c4Schristos #  endif
602*fd82c4c4Schristos # else
603*fd82c4c4Schristos #  if !1
604*fd82c4c4Schristos _GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
605*fd82c4c4Schristos #   if !GNULIB_defined_fcntl
606*fd82c4c4Schristos #    define GNULIB_defined_fcntl 1
607*fd82c4c4Schristos #   endif
608*fd82c4c4Schristos #  endif
609*fd82c4c4Schristos _GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
610*fd82c4c4Schristos # endif
611*fd82c4c4Schristos _GL_CXXALIASWARN (fcntl);
612*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
613*fd82c4c4Schristos # undef fcntl
614*fd82c4c4Schristos # if HAVE_RAW_DECL_FCNTL
615*fd82c4c4Schristos _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
616*fd82c4c4Schristos                  "use gnulib module fcntl for portability");
617*fd82c4c4Schristos # endif
618*fd82c4c4Schristos #endif
619*fd82c4c4Schristos 
620*fd82c4c4Schristos #if 1
621*fd82c4c4Schristos # if 0
622*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
623*fd82c4c4Schristos #   undef open
624*fd82c4c4Schristos #   define open rpl_open
625*fd82c4c4Schristos #  endif
626*fd82c4c4Schristos _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
627*fd82c4c4Schristos                              _GL_ARG_NONNULL ((1)));
628*fd82c4c4Schristos _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
629*fd82c4c4Schristos # else
630*fd82c4c4Schristos _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
631*fd82c4c4Schristos # endif
632*fd82c4c4Schristos /* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
633*fd82c4c4Schristos    default argument.  _GL_CXXALIASWARN does not work in this case.  */
634*fd82c4c4Schristos # if !defined __hpux
635*fd82c4c4Schristos _GL_CXXALIASWARN (open);
636*fd82c4c4Schristos # endif
637*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
638*fd82c4c4Schristos # undef open
639*fd82c4c4Schristos /* Assume open is always declared.  */
640*fd82c4c4Schristos _GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
641*fd82c4c4Schristos                  "use gnulib module open for portability");
642*fd82c4c4Schristos #endif
643*fd82c4c4Schristos 
644*fd82c4c4Schristos #if 1
645*fd82c4c4Schristos # if 0
646*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
647*fd82c4c4Schristos #   undef openat
648*fd82c4c4Schristos #   define openat rpl_openat
649*fd82c4c4Schristos #  endif
650*fd82c4c4Schristos _GL_FUNCDECL_RPL (openat, int,
651*fd82c4c4Schristos                   (int fd, char const *file, int flags, /* mode_t mode */ ...)
652*fd82c4c4Schristos                   _GL_ARG_NONNULL ((2)));
653*fd82c4c4Schristos _GL_CXXALIAS_RPL (openat, int,
654*fd82c4c4Schristos                   (int fd, char const *file, int flags, /* mode_t mode */ ...));
655*fd82c4c4Schristos # else
656*fd82c4c4Schristos #  if !1
657*fd82c4c4Schristos _GL_FUNCDECL_SYS (openat, int,
658*fd82c4c4Schristos                   (int fd, char const *file, int flags, /* mode_t mode */ ...)
659*fd82c4c4Schristos                   _GL_ARG_NONNULL ((2)));
660*fd82c4c4Schristos #  endif
661*fd82c4c4Schristos _GL_CXXALIAS_SYS (openat, int,
662*fd82c4c4Schristos                   (int fd, char const *file, int flags, /* mode_t mode */ ...));
663*fd82c4c4Schristos # endif
664*fd82c4c4Schristos _GL_CXXALIASWARN (openat);
665*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
666*fd82c4c4Schristos # undef openat
667*fd82c4c4Schristos # if HAVE_RAW_DECL_OPENAT
668*fd82c4c4Schristos _GL_WARN_ON_USE (openat, "openat is not portable - "
669*fd82c4c4Schristos                  "use gnulib module openat for portability");
670*fd82c4c4Schristos # endif
671*fd82c4c4Schristos #endif
672*fd82c4c4Schristos 
673*fd82c4c4Schristos 
674*fd82c4c4Schristos /* Fix up the FD_* macros, only known to be missing on mingw.  */
675*fd82c4c4Schristos 
676*fd82c4c4Schristos #ifndef FD_CLOEXEC
677*fd82c4c4Schristos # define FD_CLOEXEC 1
678*fd82c4c4Schristos #endif
679*fd82c4c4Schristos 
680*fd82c4c4Schristos /* Fix up the supported F_* macros.  Intentionally leave other F_*
681*fd82c4c4Schristos    macros undefined.  Only known to be missing on mingw.  */
682*fd82c4c4Schristos 
683*fd82c4c4Schristos #ifndef F_DUPFD_CLOEXEC
684*fd82c4c4Schristos # define F_DUPFD_CLOEXEC 0x40000000
685*fd82c4c4Schristos /* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise.  */
686*fd82c4c4Schristos # define GNULIB_defined_F_DUPFD_CLOEXEC 1
687*fd82c4c4Schristos #else
688*fd82c4c4Schristos # define GNULIB_defined_F_DUPFD_CLOEXEC 0
689*fd82c4c4Schristos #endif
690*fd82c4c4Schristos 
691*fd82c4c4Schristos #ifndef F_DUPFD
692*fd82c4c4Schristos # define F_DUPFD 1
693*fd82c4c4Schristos #endif
694*fd82c4c4Schristos 
695*fd82c4c4Schristos #ifndef F_GETFD
696*fd82c4c4Schristos # define F_GETFD 2
697*fd82c4c4Schristos #endif
698*fd82c4c4Schristos 
699*fd82c4c4Schristos /* Fix up the O_* macros.  */
700*fd82c4c4Schristos 
701*fd82c4c4Schristos /* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
702*fd82c4c4Schristos    to values outside 'int' range, so omit these misdefinitions.
703*fd82c4c4Schristos    But avoid namespace pollution on non-AIX systems.  */
704*fd82c4c4Schristos #ifdef _AIX
705*fd82c4c4Schristos # include <limits.h>
706*fd82c4c4Schristos # if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
707*fd82c4c4Schristos #  undef O_CLOEXEC
708*fd82c4c4Schristos # endif
709*fd82c4c4Schristos # if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
710*fd82c4c4Schristos #  undef O_NOFOLLOW
711*fd82c4c4Schristos # endif
712*fd82c4c4Schristos # if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
713*fd82c4c4Schristos #  undef O_TTY_INIT
714*fd82c4c4Schristos # endif
715*fd82c4c4Schristos #endif
716*fd82c4c4Schristos 
717*fd82c4c4Schristos #if !defined O_DIRECT && defined O_DIRECTIO
718*fd82c4c4Schristos /* Tru64 spells it 'O_DIRECTIO'.  */
719*fd82c4c4Schristos # define O_DIRECT O_DIRECTIO
720*fd82c4c4Schristos #endif
721*fd82c4c4Schristos 
722*fd82c4c4Schristos #if !defined O_CLOEXEC && defined O_NOINHERIT
723*fd82c4c4Schristos /* Mingw spells it 'O_NOINHERIT'.  */
724*fd82c4c4Schristos # define O_CLOEXEC O_NOINHERIT
725*fd82c4c4Schristos #endif
726*fd82c4c4Schristos 
727*fd82c4c4Schristos #ifndef O_CLOEXEC
728*fd82c4c4Schristos # define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags.  */
729*fd82c4c4Schristos # define GNULIB_defined_O_CLOEXEC 1
730*fd82c4c4Schristos #else
731*fd82c4c4Schristos # define GNULIB_defined_O_CLOEXEC 0
732*fd82c4c4Schristos #endif
733*fd82c4c4Schristos 
734*fd82c4c4Schristos #ifndef O_DIRECT
735*fd82c4c4Schristos # define O_DIRECT 0
736*fd82c4c4Schristos #endif
737*fd82c4c4Schristos 
738*fd82c4c4Schristos #ifndef O_DIRECTORY
739*fd82c4c4Schristos # define O_DIRECTORY 0
740*fd82c4c4Schristos #endif
741*fd82c4c4Schristos 
742*fd82c4c4Schristos #ifndef O_DSYNC
743*fd82c4c4Schristos # define O_DSYNC 0
744*fd82c4c4Schristos #endif
745*fd82c4c4Schristos 
746*fd82c4c4Schristos #ifndef O_EXEC
747*fd82c4c4Schristos # define O_EXEC O_RDONLY /* This is often close enough in older systems.  */
748*fd82c4c4Schristos #endif
749*fd82c4c4Schristos 
750*fd82c4c4Schristos #ifndef O_IGNORE_CTTY
751*fd82c4c4Schristos # define O_IGNORE_CTTY 0
752*fd82c4c4Schristos #endif
753*fd82c4c4Schristos 
754*fd82c4c4Schristos #ifndef O_NDELAY
755*fd82c4c4Schristos # define O_NDELAY 0
756*fd82c4c4Schristos #endif
757*fd82c4c4Schristos 
758*fd82c4c4Schristos #ifndef O_NOATIME
759*fd82c4c4Schristos # define O_NOATIME 0
760*fd82c4c4Schristos #endif
761*fd82c4c4Schristos 
762*fd82c4c4Schristos #ifndef O_NONBLOCK
763*fd82c4c4Schristos # define O_NONBLOCK O_NDELAY
764*fd82c4c4Schristos #endif
765*fd82c4c4Schristos 
766*fd82c4c4Schristos /* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
767*fd82c4c4Schristos    value of O_NONBLOCK.  Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
768*fd82c4c4Schristos    or to 0 as fallback.  */
769*fd82c4c4Schristos #if 0
770*fd82c4c4Schristos # if O_NONBLOCK
771*fd82c4c4Schristos #  define GNULIB_defined_O_NONBLOCK 0
772*fd82c4c4Schristos # else
773*fd82c4c4Schristos #  define GNULIB_defined_O_NONBLOCK 1
774*fd82c4c4Schristos #  undef O_NONBLOCK
775*fd82c4c4Schristos #  define O_NONBLOCK 0x40000000
776*fd82c4c4Schristos # endif
777*fd82c4c4Schristos #endif
778*fd82c4c4Schristos 
779*fd82c4c4Schristos #ifndef O_NOCTTY
780*fd82c4c4Schristos # define O_NOCTTY 0
781*fd82c4c4Schristos #endif
782*fd82c4c4Schristos 
783*fd82c4c4Schristos #ifndef O_NOFOLLOW
784*fd82c4c4Schristos # define O_NOFOLLOW 0
785*fd82c4c4Schristos #endif
786*fd82c4c4Schristos 
787*fd82c4c4Schristos #ifndef O_NOLINK
788*fd82c4c4Schristos # define O_NOLINK 0
789*fd82c4c4Schristos #endif
790*fd82c4c4Schristos 
791*fd82c4c4Schristos #ifndef O_NOLINKS
792*fd82c4c4Schristos # define O_NOLINKS 0
793*fd82c4c4Schristos #endif
794*fd82c4c4Schristos 
795*fd82c4c4Schristos #ifndef O_NOTRANS
796*fd82c4c4Schristos # define O_NOTRANS 0
797*fd82c4c4Schristos #endif
798*fd82c4c4Schristos 
799*fd82c4c4Schristos #ifndef O_RSYNC
800*fd82c4c4Schristos # define O_RSYNC 0
801*fd82c4c4Schristos #endif
802*fd82c4c4Schristos 
803*fd82c4c4Schristos #ifndef O_SEARCH
804*fd82c4c4Schristos # define O_SEARCH O_RDONLY /* This is often close enough in older systems.  */
805*fd82c4c4Schristos #endif
806*fd82c4c4Schristos 
807*fd82c4c4Schristos #ifndef O_SYNC
808*fd82c4c4Schristos # define O_SYNC 0
809*fd82c4c4Schristos #endif
810*fd82c4c4Schristos 
811*fd82c4c4Schristos #ifndef O_TTY_INIT
812*fd82c4c4Schristos # define O_TTY_INIT 0
813*fd82c4c4Schristos #endif
814*fd82c4c4Schristos 
815*fd82c4c4Schristos #if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
816*fd82c4c4Schristos # undef O_ACCMODE
817*fd82c4c4Schristos # define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
818*fd82c4c4Schristos #endif
819*fd82c4c4Schristos 
820*fd82c4c4Schristos /* For systems that distinguish between text and binary I/O.
821*fd82c4c4Schristos    O_BINARY is usually declared in fcntl.h  */
822*fd82c4c4Schristos #if !defined O_BINARY && defined _O_BINARY
823*fd82c4c4Schristos   /* For MSC-compatible compilers.  */
824*fd82c4c4Schristos # define O_BINARY _O_BINARY
825*fd82c4c4Schristos # define O_TEXT _O_TEXT
826*fd82c4c4Schristos #endif
827*fd82c4c4Schristos 
828*fd82c4c4Schristos #if defined __BEOS__ || defined __HAIKU__
829*fd82c4c4Schristos   /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect.  */
830*fd82c4c4Schristos # undef O_BINARY
831*fd82c4c4Schristos # undef O_TEXT
832*fd82c4c4Schristos #endif
833*fd82c4c4Schristos 
834*fd82c4c4Schristos #ifndef O_BINARY
835*fd82c4c4Schristos # define O_BINARY 0
836*fd82c4c4Schristos # define O_TEXT 0
837*fd82c4c4Schristos #endif
838*fd82c4c4Schristos 
839*fd82c4c4Schristos /* Fix up the AT_* macros.  */
840*fd82c4c4Schristos 
841*fd82c4c4Schristos /* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive.  Its
842*fd82c4c4Schristos    value exceeds INT_MAX, so its use as an int doesn't conform to the
843*fd82c4c4Schristos    C standard, and GCC and Sun C complain in some cases.  If the bug
844*fd82c4c4Schristos    is present, undef AT_FDCWD here, so it can be redefined below.  */
845*fd82c4c4Schristos #if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
846*fd82c4c4Schristos # undef AT_FDCWD
847*fd82c4c4Schristos #endif
848*fd82c4c4Schristos 
849*fd82c4c4Schristos /* Use the same bit pattern as Solaris 9, but with the proper
850*fd82c4c4Schristos    signedness.  The bit pattern is important, in case this actually is
851*fd82c4c4Schristos    Solaris with the above workaround.  */
852*fd82c4c4Schristos #ifndef AT_FDCWD
853*fd82c4c4Schristos # define AT_FDCWD (-3041965)
854*fd82c4c4Schristos #endif
855*fd82c4c4Schristos 
856*fd82c4c4Schristos /* Use the same values as Solaris 9.  This shouldn't matter, but
857*fd82c4c4Schristos    there's no real reason to differ.  */
858*fd82c4c4Schristos #ifndef AT_SYMLINK_NOFOLLOW
859*fd82c4c4Schristos # define AT_SYMLINK_NOFOLLOW 4096
860*fd82c4c4Schristos #endif
861*fd82c4c4Schristos 
862*fd82c4c4Schristos #ifndef AT_REMOVEDIR
863*fd82c4c4Schristos # define AT_REMOVEDIR 1
864*fd82c4c4Schristos #endif
865*fd82c4c4Schristos 
866*fd82c4c4Schristos /* Solaris 9 lacks these two, so just pick unique values.  */
867*fd82c4c4Schristos #ifndef AT_SYMLINK_FOLLOW
868*fd82c4c4Schristos # define AT_SYMLINK_FOLLOW 2
869*fd82c4c4Schristos #endif
870*fd82c4c4Schristos 
871*fd82c4c4Schristos #ifndef AT_EACCESS
872*fd82c4c4Schristos # define AT_EACCESS 4
873*fd82c4c4Schristos #endif
874*fd82c4c4Schristos 
875*fd82c4c4Schristos 
876*fd82c4c4Schristos #endif /* _GL_FCNTL_H */
877*fd82c4c4Schristos #endif /* _GL_FCNTL_H */
878*fd82c4c4Schristos #endif
879