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