192108Sphk/* This file is automatically generated.  DO NOT EDIT! */
292108Sphk/* Generated from: NetBSD: mknative-gdb,v 1.12 2020/09/17 16:54:31 christos Exp  */
392108Sphk/* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
492108Sphk
592108Sphk/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
692108Sphk/* Like <fcntl.h>, but with non-working flags defined to 0.
792108Sphk
892108Sphk   Copyright (C) 2006-2020 Free Software Foundation, Inc.
992108Sphk
1092108Sphk   This program is free software: you can redistribute it and/or modify
1192108Sphk   it under the terms of the GNU General Public License as published by
1292108Sphk   the Free Software Foundation; either version 3 of the License, or
1392108Sphk   (at your option) any later version.
1492108Sphk
1592108Sphk   This program is distributed in the hope that it will be useful,
1692108Sphk   but WITHOUT ANY WARRANTY; without even the implied warranty of
1792108Sphk   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1892108Sphk   GNU General Public License for more details.
1992108Sphk
2092108Sphk   You should have received a copy of the GNU General Public License
2192108Sphk   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
2292108Sphk
2392108Sphk/* written by Paul Eggert */
2492108Sphk
2592108Sphk#if __GNUC__ >= 3
2692108Sphk#pragma GCC system_header
2792108Sphk#endif
2892108Sphk
2992108Sphk
3092108Sphk#if defined __need_system_fcntl_h
3192108Sphk/* Special invocation convention.  */
3292108Sphk
3392108Sphk/* Needed before <sys/stat.h>.
3492108Sphk   May also define off_t to a 64-bit type on native Windows.  */
3592108Sphk#include <sys/types.h>
3692108Sphk/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
3792108Sphk   <fcntl.h>.  On glibc systems, we would like to avoid namespace pollution.
3892108Sphk   But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
3992108Sphk   extern "C" { ... } block, which leads to errors in C++ mode with the
4092108Sphk   overridden <sys/stat.h> from gnulib.  These errors are known to be gone
41116196Sobrien   with g++ version >= 4.3.  */
42116196Sobrien#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
43116196Sobrien# include <sys/stat.h>
4492108Sphk#endif
4592108Sphk#include_next <fcntl.h>
4692108Sphk
4792108Sphk/* Native Windows platforms declare open(), creat() in <io.h>.  */
4892108Sphk#if (0 || 1 || defined GNULIB_POSIXCHECK) \
4992108Sphk    && (defined _WIN32 && ! defined __CYGWIN__)
50136837Sphk# include <io.h>
5192108Sphk#endif
5292108Sphk
5392108Sphk#else
5493250Sphk/* Normal invocation convention.  */
5592108Sphk
56136837Sphk#ifndef _GL_FCNTL_H
57136837Sphk
58113938Sphk/* Needed before <sys/stat.h>.
59113938Sphk   May also define off_t to a 64-bit type on native Windows.  */
6092108Sphk#include <sys/types.h>
61109170Sphk/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
6292108Sphk   <fcntl.h>.  On glibc systems, we would like to avoid namespace pollution.
63104053Sphk   But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
64131820Sphk   extern "C" { ... } block, which leads to errors in C++ mode with the
6592108Sphk   overridden <sys/stat.h> from gnulib.  These errors are known to be gone
66113938Sphk   with g++ version >= 4.3.  */
67113938Sphk#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
68113938Sphk# include <sys/stat.h>
69113938Sphk#endif
70113940Sphk/* The include_next requires a split double-inclusion guard.  */
71113938Sphk#include_next <fcntl.h>
72113940Sphk
73113938Sphk/* Native Windows platforms declare open(), creat() in <io.h>.  */
74113938Sphk#if (0 || 1 || defined GNULIB_POSIXCHECK) \
75113938Sphk    && (defined _WIN32 && ! defined __CYGWIN__)
76113940Sphk# include <io.h>
77113940Sphk#endif
78114450Sphk
79113940Sphk#ifndef _GL_FCNTL_H
8092108Sphk#define _GL_FCNTL_H
8198066Sphk
8292108Sphk#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems.  */
8392108Sphk# include <unistd.h>
84136837Sphk#endif
85136837Sphk
86136837Sphk
8792108Sphk/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
8898066Sphk/* C++ compatible function declaration macros.
89136837Sphk   Copyright (C) 2010-2020 Free Software Foundation, Inc.
9092108Sphk
9192108Sphk   This program is free software: you can redistribute it and/or modify it
9292108Sphk   under the terms of the GNU General Public License as published
93137489Spjd   by the Free Software Foundation; either version 3 of the License, or
94137489Spjd   (at your option) any later version.
95137489Spjd
96137489Spjd   This program is distributed in the hope that it will be useful,
97137489Spjd   but WITHOUT ANY WARRANTY; without even the implied warranty of
98137489Spjd   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
99137489Spjd   General Public License for more details.
100137489Spjd
101137489Spjd   You should have received a copy of the GNU General Public License
102137489Spjd   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
103137489Spjd
104137489Spjd#ifndef _GL_CXXDEFS_H
10592108Sphk#define _GL_CXXDEFS_H
10692108Sphk
10792108Sphk/* Begin/end the GNULIB_NAMESPACE namespace.  */
108126798Sphk#if defined __cplusplus && defined GNULIB_NAMESPACE
10992108Sphk# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
11092108Sphk# define _GL_END_NAMESPACE }
11192108Sphk#else
11292108Sphk# define _GL_BEGIN_NAMESPACE
11392108Sphk# define _GL_END_NAMESPACE
114123233Sphk#endif
11592108Sphk
116104053Sphk/* The three most frequent use cases of these macros are:
117123233Sphk
118123233Sphk   * For providing a substitute for a function that is missing on some
119123233Sphk     platforms, but is declared and works fine on the platforms on which
12092108Sphk     it exists:
121104053Sphk
12292108Sphk       #if @GNULIB_FOO@
12392108Sphk       # if !@HAVE_FOO@
12492108Sphk       _GL_FUNCDECL_SYS (foo, ...);
12592108Sphk       # endif
12692108Sphk       _GL_CXXALIAS_SYS (foo, ...);
12792108Sphk       _GL_CXXALIASWARN (foo);
12892108Sphk       #elif defined GNULIB_POSIXCHECK
12992108Sphk       ...
13092108Sphk       #endif
13193250Sphk
13292108Sphk   * For providing a replacement for a function that exists on all platforms,
13392108Sphk     but is broken/insufficient and needs to be replaced on some platforms:
134123761Sphk
13592108Sphk       #if @GNULIB_FOO@
136126798Sphk       # if @REPLACE_FOO@
137126798Sphk       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
13892108Sphk       #   undef foo
13992108Sphk       #   define foo rpl_foo
140123761Sphk       #  endif
141123761Sphk       _GL_FUNCDECL_RPL (foo, ...);
142123761Sphk       _GL_CXXALIAS_RPL (foo, ...);
14392108Sphk       # else
14492108Sphk       _GL_CXXALIAS_SYS (foo, ...);
145112029Sphk       # endif
14692108Sphk       _GL_CXXALIASWARN (foo);
14792108Sphk       #elif defined GNULIB_POSIXCHECK
14892108Sphk       ...
14992108Sphk       #endif
15093776Sphk
15193776Sphk   * For providing a replacement for a function that exists on some platforms
15293776Sphk     but is broken/insufficient and needs to be replaced on some of them and
15393776Sphk     is additionally either missing or undeclared on some other platforms:
15492108Sphk
15592108Sphk       #if @GNULIB_FOO@
156123761Sphk       # if @REPLACE_FOO@
157121029Sphk       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
158123761Sphk       #   undef foo
159123761Sphk       #   define foo rpl_foo
160112322Sphk       #  endif
161112070Sphk       _GL_FUNCDECL_RPL (foo, ...);
162112070Sphk       _GL_CXXALIAS_RPL (foo, ...);
163112070Sphk       # else
164112070Sphk       #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
165112070Sphk       _GL_FUNCDECL_SYS (foo, ...);
166112322Sphk       #  endif
16792108Sphk       _GL_CXXALIAS_SYS (foo, ...);
16892108Sphk       # endif
16992108Sphk       _GL_CXXALIASWARN (foo);
17093250Sphk       #elif defined GNULIB_POSIXCHECK
17192108Sphk       ...
17292108Sphk       #endif
17392108Sphk*/
17492108Sphk
17592108Sphk/* _GL_EXTERN_C declaration;
17692108Sphk   performs the declaration with C linkage.  */
177104053Sphk#if defined __cplusplus
17892108Sphk# define _GL_EXTERN_C extern "C"
179126798Sphk#else
180126798Sphk# define _GL_EXTERN_C extern
18192108Sphk#endif
182126798Sphk
183104053Sphk/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
18492108Sphk   declares a replacement function, named rpl_func, with the given prototype,
18592108Sphk   consisting of return type, parameters, and attributes.
18693250Sphk   Example:
18792108Sphk     _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
188104056Sphk                                  _GL_ARG_NONNULL ((1)));
18992108Sphk */
19092108Sphk#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
191104056Sphk  _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
19292108Sphk#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
19392108Sphk  _GL_EXTERN_C rettype rpl_func parameters_and_attributes
19492108Sphk
19592108Sphk/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
196104056Sphk   declares the system function, named func, with the given prototype,
197113934Sphk   consisting of return type, parameters, and attributes.
198113934Sphk   Example:
199113934Sphk     _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
200113940Sphk                                  _GL_ARG_NONNULL ((1)));
201113940Sphk */
202113940Sphk#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
203113940Sphk  _GL_EXTERN_C rettype func parameters_and_attributes
204114490Sphk
205113940Sphk/* _GL_CXXALIAS_RPL (func, rettype, parameters);
20692108Sphk   declares a C++ alias called GNULIB_NAMESPACE::func
207106408Sphk   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
20892108Sphk   Example:
20992108Sphk     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
21092108Sphk
21192108Sphk   Wrapping rpl_func in an object with an inline conversion operator
21292108Sphk   avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
21392108Sphk   actually used in the program.  */
21493250Sphk#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
21592108Sphk  _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
216131820Sphk#if defined __cplusplus && defined GNULIB_NAMESPACE
21792108Sphk# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
21893250Sphk    namespace GNULIB_NAMESPACE                                \
21992108Sphk    {                                                         \
220131820Sphk      static const struct _gl_ ## func ## _wrapper            \
221131820Sphk      {                                                       \
222131820Sphk        typedef rettype (*type) parameters;                   \
223131820Sphk                                                              \
224131820Sphk        inline operator type () const                         \
225131820Sphk        {                                                     \
226131820Sphk          return ::rpl_func;                                  \
227131820Sphk        }                                                     \
22892108Sphk      } func = {};                                            \
22992108Sphk    }                                                         \
23092108Sphk    _GL_EXTERN_C int _gl_cxxalias_dummy
231112988Sphk#else
232112518Sphk# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
233112518Sphk    _GL_EXTERN_C int _gl_cxxalias_dummy
234114447Sphk#endif
235112988Sphk
236112518Sphk/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
237112518Sphk   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
238114447Sphk   except that the C function rpl_func may have a slightly different
239114447Sphk   declaration.  A cast is used to silence the "invalid conversion" error
240114447Sphk   that would otherwise occur.  */
241114447Sphk#if defined __cplusplus && defined GNULIB_NAMESPACE
242114447Sphk# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
243114447Sphk    namespace GNULIB_NAMESPACE                                     \
244112988Sphk    {                                                              \
245112518Sphk      static const struct _gl_ ## func ## _wrapper                 \
246112988Sphk      {                                                            \
247112988Sphk        typedef rettype (*type) parameters;                        \
248112988Sphk                                                                   \
249112988Sphk        inline operator type () const                              \
250112988Sphk        {                                                          \
251113934Sphk          return reinterpret_cast<type>(::rpl_func);               \
252113940Sphk        }                                                          \
253113940Sphk      } func = {};                                                 \
254114450Sphk    }                                                              \
255113940Sphk    _GL_EXTERN_C int _gl_cxxalias_dummy
256113940Sphk#else
257114490Sphk# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
258113940Sphk    _GL_EXTERN_C int _gl_cxxalias_dummy
259124885Sphk#endif
260124885Sphk
261112988Sphk/* _GL_CXXALIAS_SYS (func, rettype, parameters);
262112988Sphk   declares a C++ alias called GNULIB_NAMESPACE::func
263112518Sphk   that redirects to the system provided function func, if GNULIB_NAMESPACE
264112518Sphk   is defined.
265112518Sphk   Example:
266112518Sphk     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
267112518Sphk
268113940Sphk   Wrapping func in an object with an inline conversion operator
269125318Sphk   avoids a reference to func unless GNULIB_NAMESPACE::func is
270104056Sphk   actually used in the program.  */
271104056Sphk#if defined __cplusplus && defined GNULIB_NAMESPACE
272112988Sphk# define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
273112988Sphk    namespace GNULIB_NAMESPACE                                \
274104056Sphk    {                                                         \
275125318Sphk      static const struct _gl_ ## func ## _wrapper            \
276146353Spjd      {                                                       \
277125318Sphk        typedef rettype (*type) parameters;                   \
278125318Sphk                                                              \
279113937Sphk        inline operator type () const                         \
280104056Sphk        {                                                     \
281104056Sphk          return ::func;                                      \
282125318Sphk        }                                                     \
283112988Sphk      } func = {};                                            \
284112988Sphk    }                                                         \
285112988Sphk    _GL_EXTERN_C int _gl_cxxalias_dummy
286112988Sphk#else
287112988Sphk# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
288122880Sphk    _GL_EXTERN_C int _gl_cxxalias_dummy
289112988Sphk#endif
290112988Sphk
291104056Sphk/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
292104056Sphk   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
293104056Sphk   except that the C function func may have a slightly different declaration.
294104056Sphk   A cast is used to silence the "invalid conversion" error that would
295104056Sphk   otherwise occur.  */
296104056Sphk#if defined __cplusplus && defined GNULIB_NAMESPACE
297104056Sphk# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
298113940Sphk    namespace GNULIB_NAMESPACE                          \
299113940Sphk    {                                                   \
300136837Sphk      static const struct _gl_ ## func ## _wrapper      \
301104056Sphk      {                                                 \
302104056Sphk        typedef rettype (*type) parameters;             \
303104056Sphk                                                        \
304113940Sphk        inline operator type () const                   \
305113940Sphk        {                                               \
306113940Sphk          return reinterpret_cast<type>(::func);        \
307113940Sphk        }                                               \
308115949Sphk      } func = {};                                      \
309113940Sphk    }                                                   \
310113940Sphk    _GL_EXTERN_C int _gl_cxxalias_dummy
311113940Sphk#else
312115949Sphk# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
313125318Sphk    _GL_EXTERN_C int _gl_cxxalias_dummy
314115949Sphk#endif
315115949Sphk
316113940Sphk/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
317113940Sphk   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
318131820Sphk   except that the C function is picked among a set of overloaded functions,
319131820Sphk   namely the one with rettype2 and parameters2.  Two consecutive casts
320113940Sphk   are used to silence the "cannot find a match" and "invalid conversion"
321131820Sphk   errors that would otherwise occur.  */
322131820Sphk#if defined __cplusplus && defined GNULIB_NAMESPACE
323131820Sphk  /* The outer cast must be a reinterpret_cast.
324131820Sphk     The inner cast: When the function is defined as a set of overloaded
325113940Sphk     functions, it works as a static_cast<>, choosing the designated variant.
326113940Sphk     When the function is defined as a single variant, it works as a
327113940Sphk     reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
328113940Sphk# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
329113940Sphk    namespace GNULIB_NAMESPACE                                                \
330113940Sphk    {                                                                         \
331113940Sphk      static const struct _gl_ ## func ## _wrapper                            \
332113940Sphk      {                                                                       \
333113940Sphk        typedef rettype (*type) parameters;                                   \
334113940Sphk                                                                              \
335113940Sphk        inline operator type () const                                         \
336113940Sphk        {                                                                     \
337113940Sphk          return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
338113940Sphk        }                                                                     \
339125657Spjd      } func = {};                                                            \
340113940Sphk    }                                                                         \
341113940Sphk    _GL_EXTERN_C int _gl_cxxalias_dummy
342115949Sphk#else
343125318Sphk# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
344115949Sphk    _GL_EXTERN_C int _gl_cxxalias_dummy
345113940Sphk#endif
346113940Sphk
347113940Sphk/* _GL_CXXALIASWARN (func);
348113940Sphk   causes a warning to be emitted when ::func is used but not when
349113940Sphk   GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
350114450Sphk   variants.  */
351114450Sphk#if defined __cplusplus && defined GNULIB_NAMESPACE
352114490Sphk# define _GL_CXXALIASWARN(func) \
353114450Sphk   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
354113940Sphk# define _GL_CXXALIASWARN_1(func,namespace) \
355113940Sphk   _GL_CXXALIASWARN_2 (func, namespace)
35692108Sphk/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
35792108Sphk   we enable the warning only when not optimizing.  */
35892108Sphk# if !__OPTIMIZE__
35992108Sphk#  define _GL_CXXALIASWARN_2(func,namespace) \
360104053Sphk    _GL_WARN_ON_USE (func, \
36192108Sphk                     "The symbol ::" #func " refers to the system function. " \
362                     "Use " #namespace "::" #func " instead.")
363# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
364#  define _GL_CXXALIASWARN_2(func,namespace) \
365     extern __typeof__ (func) func
366# else
367#  define _GL_CXXALIASWARN_2(func,namespace) \
368     _GL_EXTERN_C int _gl_cxxalias_dummy
369# endif
370#else
371# define _GL_CXXALIASWARN(func) \
372    _GL_EXTERN_C int _gl_cxxalias_dummy
373#endif
374
375/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
376   causes a warning to be emitted when the given overloaded variant of ::func
377   is used but not when GNULIB_NAMESPACE::func is used.  */
378#if defined __cplusplus && defined GNULIB_NAMESPACE
379# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
380   _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
381                        GNULIB_NAMESPACE)
382# 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