1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Like <fcntl.h>, but with non-working flags defined to 0.
4 Copyright (C) 2006-2019 Free Software Foundation, Inc.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19 /* written by Paul Eggert */
22 #pragma GCC system_header
26 #if defined __need_system_fcntl_h
27 /* Special invocation convention. */
29 /* Needed before <sys/stat.h>.
30 May also define off_t to a 64-bit type on native Windows. */
31 #include <sys/types.h>
32 /* On some systems other than glibc, <sys/stat.h> is a prerequisite of
33 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
34 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
35 extern "C" { ... } block, which leads to errors in C++ mode with the
36 overridden <sys/stat.h> from gnulib. These errors are known to be gone
37 with g++ version >= 4.3. */
38 #if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
39 # include <sys/stat.h>
41 #include_next <fcntl.h>
44 /* Normal invocation convention. */
48 /* Needed before <sys/stat.h>.
49 May also define off_t to a 64-bit type on native Windows. */
50 #include <sys/types.h>
51 /* On some systems other than glibc, <sys/stat.h> is a prerequisite of
52 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
53 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
54 extern "C" { ... } block, which leads to errors in C++ mode with the
55 overridden <sys/stat.h> from gnulib. These errors are known to be gone
56 with g++ version >= 4.3. */
57 #if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
58 # include <sys/stat.h>
60 /* The include_next requires a split double-inclusion guard. */
61 #include_next <fcntl.h>
66 #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
70 /* Native Windows platforms declare open(), creat() in <io.h>. */
71 #if (1 || defined GNULIB_POSIXCHECK) \
72 && (defined _WIN32 && ! defined __CYGWIN__)
77 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
78 /* C++ compatible function declaration macros.
79 Copyright (C) 2010-2019 Free Software Foundation, Inc.
81 This program is free software: you can redistribute it and/or modify it
82 under the terms of the GNU General Public License as published
83 by the Free Software Foundation; either version 3 of the License, or
84 (at your option) any later version.
86 This program is distributed in the hope that it will be useful,
87 but WITHOUT ANY WARRANTY; without even the implied warranty of
88 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
89 General Public License for more details.
91 You should have received a copy of the GNU General Public License
92 along with this program. If not, see <https://www.gnu.org/licenses/>. */
97 /* Begin/end the GNULIB_NAMESPACE namespace. */
98 #if defined __cplusplus && defined GNULIB_NAMESPACE
99 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
100 # define _GL_END_NAMESPACE }
102 # define _GL_BEGIN_NAMESPACE
103 # define _GL_END_NAMESPACE
106 /* The three most frequent use cases of these macros are:
108 * For providing a substitute for a function that is missing on some
109 platforms, but is declared and works fine on the platforms on which
114 _GL_FUNCDECL_SYS (foo, ...);
116 _GL_CXXALIAS_SYS (foo, ...);
117 _GL_CXXALIASWARN (foo);
118 #elif defined GNULIB_POSIXCHECK
122 * For providing a replacement for a function that exists on all platforms,
123 but is broken/insufficient and needs to be replaced on some platforms:
127 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
131 _GL_FUNCDECL_RPL (foo, ...);
132 _GL_CXXALIAS_RPL (foo, ...);
134 _GL_CXXALIAS_SYS (foo, ...);
136 _GL_CXXALIASWARN (foo);
137 #elif defined GNULIB_POSIXCHECK
141 * For providing a replacement for a function that exists on some platforms
142 but is broken/insufficient and needs to be replaced on some of them and
143 is additionally either missing or undeclared on some other platforms:
147 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
151 _GL_FUNCDECL_RPL (foo, ...);
152 _GL_CXXALIAS_RPL (foo, ...);
154 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
155 _GL_FUNCDECL_SYS (foo, ...);
157 _GL_CXXALIAS_SYS (foo, ...);
159 _GL_CXXALIASWARN (foo);
160 #elif defined GNULIB_POSIXCHECK
165 /* _GL_EXTERN_C declaration;
166 performs the declaration with C linkage. */
167 #if defined __cplusplus
168 # define _GL_EXTERN_C extern "C"
170 # define _GL_EXTERN_C extern
173 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
174 declares a replacement function, named rpl_func, with the given prototype,
175 consisting of return type, parameters, and attributes.
177 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
178 _GL_ARG_NONNULL ((1)));
180 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
181 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
182 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
183 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
185 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
186 declares the system function, named func, with the given prototype,
187 consisting of return type, parameters, and attributes.
189 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
190 _GL_ARG_NONNULL ((1)));
192 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
193 _GL_EXTERN_C rettype func parameters_and_attributes
195 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
196 declares a C++ alias called GNULIB_NAMESPACE::func
197 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
199 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
201 Wrapping rpl_func in an object with an inline conversion operator
202 avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
203 actually used in the program. */
204 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
205 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
206 #if defined __cplusplus && defined GNULIB_NAMESPACE
207 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
208 namespace GNULIB_NAMESPACE \
210 static const struct _gl_ ## func ## _wrapper \
212 typedef rettype (*type) parameters; \
214 inline operator type () const \
220 _GL_EXTERN_C int _gl_cxxalias_dummy
222 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
223 _GL_EXTERN_C int _gl_cxxalias_dummy
226 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
227 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
228 except that the C function rpl_func may have a slightly different
229 declaration. A cast is used to silence the "invalid conversion" error
230 that would otherwise occur. */
231 #if defined __cplusplus && defined GNULIB_NAMESPACE
232 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
233 namespace GNULIB_NAMESPACE \
235 static const struct _gl_ ## func ## _wrapper \
237 typedef rettype (*type) parameters; \
239 inline operator type () const \
241 return reinterpret_cast<type>(::rpl_func); \
245 _GL_EXTERN_C int _gl_cxxalias_dummy
247 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
248 _GL_EXTERN_C int _gl_cxxalias_dummy
251 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
252 declares a C++ alias called GNULIB_NAMESPACE::func
253 that redirects to the system provided function func, if GNULIB_NAMESPACE
256 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
258 Wrapping func in an object with an inline conversion operator
259 avoids a reference to func unless GNULIB_NAMESPACE::func is
260 actually used in the program. */
261 #if defined __cplusplus && defined GNULIB_NAMESPACE
262 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
263 namespace GNULIB_NAMESPACE \
265 static const struct _gl_ ## func ## _wrapper \
267 typedef rettype (*type) parameters; \
269 inline operator type () const \
275 _GL_EXTERN_C int _gl_cxxalias_dummy
277 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
278 _GL_EXTERN_C int _gl_cxxalias_dummy
281 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
282 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
283 except that the C function func may have a slightly different declaration.
284 A cast is used to silence the "invalid conversion" error that would
286 #if defined __cplusplus && defined GNULIB_NAMESPACE
287 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
288 namespace GNULIB_NAMESPACE \
290 static const struct _gl_ ## func ## _wrapper \
292 typedef rettype (*type) parameters; \
294 inline operator type () const \
296 return reinterpret_cast<type>(::func); \
300 _GL_EXTERN_C int _gl_cxxalias_dummy
302 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
303 _GL_EXTERN_C int _gl_cxxalias_dummy
306 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
307 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
308 except that the C function is picked among a set of overloaded functions,
309 namely the one with rettype2 and parameters2. Two consecutive casts
310 are used to silence the "cannot find a match" and "invalid conversion"
311 errors that would otherwise occur. */
312 #if defined __cplusplus && defined GNULIB_NAMESPACE
313 /* The outer cast must be a reinterpret_cast.
314 The inner cast: When the function is defined as a set of overloaded
315 functions, it works as a static_cast<>, choosing the designated variant.
316 When the function is defined as a single variant, it works as a
317 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
318 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
319 namespace GNULIB_NAMESPACE \
321 static const struct _gl_ ## func ## _wrapper \
323 typedef rettype (*type) parameters; \
325 inline operator type () const \
327 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
331 _GL_EXTERN_C int _gl_cxxalias_dummy
333 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
334 _GL_EXTERN_C int _gl_cxxalias_dummy
337 /* _GL_CXXALIASWARN (func);
338 causes a warning to be emitted when ::func is used but not when
339 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
341 #if defined __cplusplus && defined GNULIB_NAMESPACE
342 # define _GL_CXXALIASWARN(func) \
343 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
344 # define _GL_CXXALIASWARN_1(func,namespace) \
345 _GL_CXXALIASWARN_2 (func, namespace)
346 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
347 we enable the warning only when not optimizing. */
349 # define _GL_CXXALIASWARN_2(func,namespace) \
350 _GL_WARN_ON_USE (func, \
351 "The symbol ::" #func " refers to the system function. " \
352 "Use " #namespace "::" #func " instead.")
353 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
354 # define _GL_CXXALIASWARN_2(func,namespace) \
355 extern __typeof__ (func) func
357 # define _GL_CXXALIASWARN_2(func,namespace) \
358 _GL_EXTERN_C int _gl_cxxalias_dummy
361 # define _GL_CXXALIASWARN(func) \
362 _GL_EXTERN_C int _gl_cxxalias_dummy
365 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
366 causes a warning to be emitted when the given overloaded variant of ::func
367 is used but not when GNULIB_NAMESPACE::func is used. */
368 #if defined __cplusplus && defined GNULIB_NAMESPACE
369 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
370 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
372 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
373 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, 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. */
377 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
378 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
379 "The symbol ::" #func " refers to the system function. " \
380 "Use " #namespace "::" #func " instead.")
381 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
382 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
383 extern __typeof__ (func) func
385 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
386 _GL_EXTERN_C int _gl_cxxalias_dummy
389 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
390 _GL_EXTERN_C int _gl_cxxalias_dummy
393 #endif /* _GL_CXXDEFS_H */
395 /* The definition of _GL_ARG_NONNULL is copied here. */
396 /* A C macro for declaring that specific arguments must not be NULL.
397 Copyright (C) 2009-2019 Free Software Foundation, Inc.
399 This program is free software: you can redistribute it and/or modify it
400 under the terms of the GNU General Public License as published
401 by the Free Software Foundation; either version 3 of the License, or
402 (at your option) any later version.
404 This program is distributed in the hope that it will be useful,
405 but WITHOUT ANY WARRANTY; without even the implied warranty of
406 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
407 General Public License for more details.
409 You should have received a copy of the GNU General Public License
410 along with this program. If not, see <https://www.gnu.org/licenses/>. */
412 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
413 that the values passed as arguments n, ..., m must be non-NULL pointers.
414 n = 1 stands for the first argument, n = 2 for the second argument etc. */
415 #ifndef _GL_ARG_NONNULL
416 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
417 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
419 # define _GL_ARG_NONNULL(params)
423 /* The definition of _GL_WARN_ON_USE is copied here. */
424 /* A C macro for emitting warnings if a function is used.
425 Copyright (C) 2010-2019 Free Software Foundation, Inc.
427 This program is free software: you can redistribute it and/or modify it
428 under the terms of the GNU General Public License as published
429 by the Free Software Foundation; either version 3 of the License, or
430 (at your option) any later version.
432 This program is distributed in the hope that it will be useful,
433 but WITHOUT ANY WARRANTY; without even the implied warranty of
434 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
435 General Public License for more details.
437 You should have received a copy of the GNU General Public License
438 along with this program. If not, see <https://www.gnu.org/licenses/>. */
440 /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
441 for FUNCTION which will then trigger a compiler warning containing
442 the text of "literal string" anywhere that function is called, if
443 supported by the compiler. If the compiler does not support this
444 feature, the macro expands to an unused extern declaration.
446 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
447 attribute used in _GL_WARN_ON_USE. If the compiler does not support
448 this feature, it expands to empty.
450 These macros are useful for marking a function as a potential
451 portability trap, with the intent that "literal string" include
452 instructions on the replacement function that should be used
454 _GL_WARN_ON_USE is for functions with 'extern' linkage.
455 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
458 However, one of the reasons that a function is a portability trap is
459 if it has the wrong signature. Declaring FUNCTION with a different
460 signature in C is a compilation error, so this macro must use the
461 same type as any existing declaration so that programs that avoid
462 the problematic FUNCTION do not fail to compile merely because they
463 included a header that poisoned the function. But this implies that
464 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
465 have a declaration. Use of this macro implies that there must not
466 be any other macro hiding the declaration of FUNCTION; but
467 undefining FUNCTION first is part of the poisoning process anyway
468 (although for symbols that are provided only via a macro, the result
469 is a compilation error rather than a warning containing
470 "literal string"). Also note that in C++, it is only safe to use if
471 FUNCTION has no overloads.
473 For an example, it is possible to poison 'getline' by:
474 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
475 [getline]) in configure.ac, which potentially defines
476 HAVE_RAW_DECL_GETLINE
477 - adding this code to a header that wraps the system <stdio.h>:
479 #if HAVE_RAW_DECL_GETLINE
480 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
481 "not universally present; use the gnulib module getline");
484 It is not possible to directly poison global variables. But it is
485 possible to write a wrapper accessor function, and poison that
486 (less common usage, like &environ, will cause a compilation error
487 rather than issue the nice warning, but the end result of informing
488 the developer about their portability problem is still achieved):
489 #if HAVE_RAW_DECL_ENVIRON
491 rpl_environ (void) { return &environ; }
492 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
494 # define environ (*rpl_environ ())
496 or better (avoiding contradictory use of 'static' and 'extern'):
497 #if HAVE_RAW_DECL_ENVIRON
499 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
500 rpl_environ (void) { return &environ; }
502 # define environ (*rpl_environ ())
505 #ifndef _GL_WARN_ON_USE
507 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
508 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
509 # define _GL_WARN_ON_USE(function, message) \
510 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
511 # define _GL_WARN_ON_USE_ATTRIBUTE(message) \
512 __attribute__ ((__warning__ (message)))
513 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
514 /* Verify the existence of the function. */
515 # define _GL_WARN_ON_USE(function, message) \
516 extern __typeof__ (function) function
517 # define _GL_WARN_ON_USE_ATTRIBUTE(message)
518 # else /* Unsupported. */
519 # define _GL_WARN_ON_USE(function, message) \
520 _GL_WARN_EXTERN_C int _gl_warn_on_use
521 # define _GL_WARN_ON_USE_ATTRIBUTE(message)
525 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
526 is like _GL_WARN_ON_USE (function, "string"), except that the function is
527 declared with the given prototype, consisting of return type, parameters,
529 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
530 not work in this case. */
531 #ifndef _GL_WARN_ON_USE_CXX
532 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
533 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
534 extern rettype function parameters_and_attributes \
535 __attribute__ ((__warning__ (msg)))
536 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
537 /* Verify the existence of the function. */
538 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
539 extern rettype function parameters_and_attributes
540 # else /* Unsupported. */
541 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
542 _GL_WARN_EXTERN_C int _gl_warn_on_use
546 /* _GL_WARN_EXTERN_C declaration;
547 performs the declaration with C linkage. */
548 #ifndef _GL_WARN_EXTERN_C
549 # if defined __cplusplus
550 # define _GL_WARN_EXTERN_C extern "C"
552 # define _GL_WARN_EXTERN_C extern
557 /* Declare overridden functions. */
561 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
563 # define fcntl rpl_fcntl
565 _GL_FUNCDECL_RPL (fcntl
, int, (int fd
, int action
, ...));
566 _GL_CXXALIAS_RPL (fcntl
, int, (int fd
, int action
, ...));
569 _GL_FUNCDECL_SYS (fcntl
, int, (int fd
, int action
, ...));
571 _GL_CXXALIAS_SYS (fcntl
, int, (int fd
, int action
, ...));
573 _GL_CXXALIASWARN (fcntl
);
574 #elif defined GNULIB_POSIXCHECK
576 # if HAVE_RAW_DECL_FCNTL
577 _GL_WARN_ON_USE (fcntl
, "fcntl is not always POSIX compliant - "
578 "use gnulib module fcntl for portability");
584 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
586 # define open rpl_open
588 _GL_FUNCDECL_RPL (open
, int, (const char *filename
, int flags
, ...)
589 _GL_ARG_NONNULL ((1)));
590 _GL_CXXALIAS_RPL (open
, int, (const char *filename
, int flags
, ...));
592 _GL_CXXALIAS_SYS (open
, int, (const char *filename
, int flags
, ...));
594 /* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
595 default argument. _GL_CXXALIASWARN does not work in this case. */
597 _GL_CXXALIASWARN (open
);
599 #elif defined GNULIB_POSIXCHECK
601 /* Assume open is always declared. */
602 _GL_WARN_ON_USE (open
, "open is not always POSIX compliant - "
603 "use gnulib module open for portability");
608 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
610 # define openat rpl_openat
612 _GL_FUNCDECL_RPL (openat
, int,
613 (int fd
, char const *file
, int flags
, /* mode_t mode */ ...)
614 _GL_ARG_NONNULL ((2)));
615 _GL_CXXALIAS_RPL (openat
, int,
616 (int fd
, char const *file
, int flags
, /* mode_t mode */ ...));
619 _GL_FUNCDECL_SYS (openat
, int,
620 (int fd
, char const *file
, int flags
, /* mode_t mode */ ...)
621 _GL_ARG_NONNULL ((2)));
623 _GL_CXXALIAS_SYS (openat
, int,
624 (int fd
, char const *file
, int flags
, /* mode_t mode */ ...));
626 _GL_CXXALIASWARN (openat
);
627 #elif defined GNULIB_POSIXCHECK
629 # if HAVE_RAW_DECL_OPENAT
630 _GL_WARN_ON_USE (openat
, "openat is not portable - "
631 "use gnulib module openat for portability");
636 /* Fix up the FD_* macros, only known to be missing on mingw. */
639 # define FD_CLOEXEC 1
642 /* Fix up the supported F_* macros. Intentionally leave other F_*
643 macros undefined. Only known to be missing on mingw. */
645 #ifndef F_DUPFD_CLOEXEC
646 # define F_DUPFD_CLOEXEC 0x40000000
647 /* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
648 # define GNULIB_defined_F_DUPFD_CLOEXEC 1
650 # define GNULIB_defined_F_DUPFD_CLOEXEC 0
661 /* Fix up the O_* macros. */
663 /* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
664 to values outside 'int' range, so omit these misdefinitions.
665 But avoid namespace pollution on non-AIX systems. */
668 # if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
671 # if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
674 # if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
679 #if !defined O_DIRECT && defined O_DIRECTIO
680 /* Tru64 spells it 'O_DIRECTIO'. */
681 # define O_DIRECT O_DIRECTIO
684 #if !defined O_CLOEXEC && defined O_NOINHERIT
685 /* Mingw spells it 'O_NOINHERIT'. */
686 # define O_CLOEXEC O_NOINHERIT
690 # define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */
691 # define GNULIB_defined_O_CLOEXEC 1
693 # define GNULIB_defined_O_CLOEXEC 0
701 # define O_DIRECTORY 0
709 # define O_EXEC O_RDONLY /* This is often close enough in older systems. */
712 #ifndef O_IGNORE_CTTY
713 # define O_IGNORE_CTTY 0
725 # define O_NONBLOCK O_NDELAY
728 /* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
729 value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
730 or to 0 as fallback. */
733 # define GNULIB_defined_O_NONBLOCK 0
735 # define GNULIB_defined_O_NONBLOCK 1
737 # define O_NONBLOCK 0x40000000
746 # define O_NOFOLLOW 0
766 # define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
774 # define O_TTY_INIT 0
777 #if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
779 # define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
782 /* For systems that distinguish between text and binary I/O.
783 O_BINARY is usually declared in fcntl.h */
784 #if !defined O_BINARY && defined _O_BINARY
785 /* For MSC-compatible compilers. */
786 # define O_BINARY _O_BINARY
787 # define O_TEXT _O_TEXT
790 #if defined __BEOS__ || defined __HAIKU__
791 /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
801 /* Fix up the AT_* macros. */
803 /* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
804 value exceeds INT_MAX, so its use as an int doesn't conform to the
805 C standard, and GCC and Sun C complain in some cases. If the bug
806 is present, undef AT_FDCWD here, so it can be redefined below. */
807 #if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
811 /* Use the same bit pattern as Solaris 9, but with the proper
812 signedness. The bit pattern is important, in case this actually is
813 Solaris with the above workaround. */
815 # define AT_FDCWD (-3041965)
818 /* Use the same values as Solaris 9. This shouldn't matter, but
819 there's no real reason to differ. */
820 #ifndef AT_SYMLINK_NOFOLLOW
821 # define AT_SYMLINK_NOFOLLOW 4096
825 # define AT_REMOVEDIR 1
828 /* Solaris 9 lacks these two, so just pick unique values. */
829 #ifndef AT_SYMLINK_FOLLOW
830 # define AT_SYMLINK_FOLLOW 2
834 # define AT_EACCESS 4
838 #endif /* _GL_FCNTL_H */
839 #endif /* _GL_FCNTL_H */