1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Like <fcntl.h>, but with non-working flags defined to 0.
4 Copyright (C) 2006-2013 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 <http://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 && !(__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 && !(__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 __WIN32__) && ! defined __CYGWIN__)
77 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
81 /* The three most frequent use cases of these macros are:
83 * For providing a substitute for a function that is missing on some
84 platforms, but is declared and works fine on the platforms on which
89 _GL_FUNCDECL_SYS (foo, ...);
91 _GL_CXXALIAS_SYS (foo, ...);
92 _GL_CXXALIASWARN (foo);
93 #elif defined GNULIB_POSIXCHECK
97 * For providing a replacement for a function that exists on all platforms,
98 but is broken/insufficient and needs to be replaced on some platforms:
102 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
106 _GL_FUNCDECL_RPL (foo, ...);
107 _GL_CXXALIAS_RPL (foo, ...);
109 _GL_CXXALIAS_SYS (foo, ...);
111 _GL_CXXALIASWARN (foo);
112 #elif defined GNULIB_POSIXCHECK
116 * For providing a replacement for a function that exists on some platforms
117 but is broken/insufficient and needs to be replaced on some of them and
118 is additionally either missing or undeclared on some other platforms:
122 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
126 _GL_FUNCDECL_RPL (foo, ...);
127 _GL_CXXALIAS_RPL (foo, ...);
129 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
130 _GL_FUNCDECL_SYS (foo, ...);
132 _GL_CXXALIAS_SYS (foo, ...);
134 _GL_CXXALIASWARN (foo);
135 #elif defined GNULIB_POSIXCHECK
140 /* _GL_EXTERN_C declaration;
141 performs the declaration with C linkage. */
142 #if defined __cplusplus
143 # define _GL_EXTERN_C extern "C"
145 # define _GL_EXTERN_C extern
148 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
149 declares a replacement function, named rpl_func, with the given prototype,
150 consisting of return type, parameters, and attributes.
152 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
153 _GL_ARG_NONNULL ((1)));
155 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
156 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
157 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
158 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
160 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
161 declares the system function, named func, with the given prototype,
162 consisting of return type, parameters, and attributes.
164 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
165 _GL_ARG_NONNULL ((1)));
167 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
168 _GL_EXTERN_C rettype func parameters_and_attributes
170 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
171 declares a C++ alias called GNULIB_NAMESPACE::func
172 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
174 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
176 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
177 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
178 #if defined __cplusplus && defined GNULIB_NAMESPACE
179 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
180 namespace GNULIB_NAMESPACE \
182 rettype (*const func) parameters = ::rpl_func; \
184 _GL_EXTERN_C int _gl_cxxalias_dummy
186 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
187 _GL_EXTERN_C int _gl_cxxalias_dummy
190 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
191 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
192 except that the C function rpl_func may have a slightly different
193 declaration. A cast is used to silence the "invalid conversion" error
194 that would otherwise occur. */
195 #if defined __cplusplus && defined GNULIB_NAMESPACE
196 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
197 namespace GNULIB_NAMESPACE \
199 rettype (*const func) parameters = \
200 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
202 _GL_EXTERN_C int _gl_cxxalias_dummy
204 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
205 _GL_EXTERN_C int _gl_cxxalias_dummy
208 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
209 declares a C++ alias called GNULIB_NAMESPACE::func
210 that redirects to the system provided function func, if GNULIB_NAMESPACE
213 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
215 #if defined __cplusplus && defined GNULIB_NAMESPACE
216 /* If we were to write
217 rettype (*const func) parameters = ::func;
218 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
219 better (remove an indirection through a 'static' pointer variable),
220 but then the _GL_CXXALIASWARN macro below would cause a warning not only
221 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
222 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
223 namespace GNULIB_NAMESPACE \
225 static rettype (*func) parameters = ::func; \
227 _GL_EXTERN_C int _gl_cxxalias_dummy
229 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
230 _GL_EXTERN_C int _gl_cxxalias_dummy
233 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
234 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
235 except that the C function func may have a slightly different declaration.
236 A cast is used to silence the "invalid conversion" error that would
238 #if defined __cplusplus && defined GNULIB_NAMESPACE
239 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
240 namespace GNULIB_NAMESPACE \
242 static rettype (*func) parameters = \
243 reinterpret_cast<rettype(*)parameters>(::func); \
245 _GL_EXTERN_C int _gl_cxxalias_dummy
247 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
248 _GL_EXTERN_C int _gl_cxxalias_dummy
251 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
252 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
253 except that the C function is picked among a set of overloaded functions,
254 namely the one with rettype2 and parameters2. Two consecutive casts
255 are used to silence the "cannot find a match" and "invalid conversion"
256 errors that would otherwise occur. */
257 #if defined __cplusplus && defined GNULIB_NAMESPACE
258 /* The outer cast must be a reinterpret_cast.
259 The inner cast: When the function is defined as a set of overloaded
260 functions, it works as a static_cast<>, choosing the designated variant.
261 When the function is defined as a single variant, it works as a
262 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
263 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
264 namespace GNULIB_NAMESPACE \
266 static rettype (*func) parameters = \
267 reinterpret_cast<rettype(*)parameters>( \
268 (rettype2(*)parameters2)(::func)); \
270 _GL_EXTERN_C int _gl_cxxalias_dummy
272 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
273 _GL_EXTERN_C int _gl_cxxalias_dummy
276 /* _GL_CXXALIASWARN (func);
277 causes a warning to be emitted when ::func is used but not when
278 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
280 #if defined __cplusplus && defined GNULIB_NAMESPACE
281 # define _GL_CXXALIASWARN(func) \
282 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
283 # define _GL_CXXALIASWARN_1(func,namespace) \
284 _GL_CXXALIASWARN_2 (func, namespace)
285 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
286 we enable the warning only when not optimizing. */
288 # define _GL_CXXALIASWARN_2(func,namespace) \
289 _GL_WARN_ON_USE (func, \
290 "The symbol ::" #func " refers to the system function. " \
291 "Use " #namespace "::" #func " instead.")
292 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
293 # define _GL_CXXALIASWARN_2(func,namespace) \
294 extern __typeof__ (func) func
296 # define _GL_CXXALIASWARN_2(func,namespace) \
297 _GL_EXTERN_C int _gl_cxxalias_dummy
300 # define _GL_CXXALIASWARN(func) \
301 _GL_EXTERN_C int _gl_cxxalias_dummy
304 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
305 causes a warning to be emitted when the given overloaded variant of ::func
306 is used but not when GNULIB_NAMESPACE::func is used. */
307 #if defined __cplusplus && defined GNULIB_NAMESPACE
308 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
309 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
311 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
312 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
313 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
314 we enable the warning only when not optimizing. */
316 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
317 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
318 "The symbol ::" #func " refers to the system function. " \
319 "Use " #namespace "::" #func " instead.")
320 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
321 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
322 extern __typeof__ (func) func
324 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
325 _GL_EXTERN_C int _gl_cxxalias_dummy
328 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
329 _GL_EXTERN_C int _gl_cxxalias_dummy
332 #endif /* _GL_CXXDEFS_H */
334 /* The definition of _GL_ARG_NONNULL is copied here. */
335 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
336 that the values passed as arguments n, ..., m must be non-NULL pointers.
337 n = 1 stands for the first argument, n = 2 for the second argument etc. */
338 #ifndef _GL_ARG_NONNULL
339 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
340 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
342 # define _GL_ARG_NONNULL(params)
346 /* The definition of _GL_WARN_ON_USE is copied here. */
347 #ifndef _GL_WARN_ON_USE
349 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
350 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
351 # define _GL_WARN_ON_USE(function, message) \
352 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
353 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
354 /* Verify the existence of the function. */
355 # define _GL_WARN_ON_USE(function, message) \
356 extern __typeof__ (function) function
357 # else /* Unsupported. */
358 # define _GL_WARN_ON_USE(function, message) \
359 _GL_WARN_EXTERN_C int _gl_warn_on_use
363 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
364 is like _GL_WARN_ON_USE (function, "string"), except that the function is
365 declared with the given prototype, consisting of return type, parameters,
367 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
368 not work in this case. */
369 #ifndef _GL_WARN_ON_USE_CXX
370 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
371 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
372 extern rettype function parameters_and_attributes \
373 __attribute__ ((__warning__ (msg)))
374 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
375 /* Verify the existence of the function. */
376 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
377 extern rettype function parameters_and_attributes
378 # else /* Unsupported. */
379 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
380 _GL_WARN_EXTERN_C int _gl_warn_on_use
384 /* _GL_WARN_EXTERN_C declaration;
385 performs the declaration with C linkage. */
386 #ifndef _GL_WARN_EXTERN_C
387 # if defined __cplusplus
388 # define _GL_WARN_EXTERN_C extern "C"
390 # define _GL_WARN_EXTERN_C extern
395 /* Declare overridden functions. */
399 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
401 # define fcntl rpl_fcntl
403 _GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
404 _GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
407 _GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
409 _GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
411 _GL_CXXALIASWARN (fcntl);
412 #elif defined GNULIB_POSIXCHECK
414 # if HAVE_RAW_DECL_FCNTL
415 _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
416 "use gnulib module fcntl for portability");
422 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
424 # define open rpl_open
426 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
427 _GL_ARG_NONNULL ((1)));
428 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
430 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
432 /* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
433 default argument. _GL_CXXALIASWARN does not work in this case. */
435 _GL_CXXALIASWARN (open);
437 #elif defined GNULIB_POSIXCHECK
439 /* Assume open is always declared. */
440 _GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
441 "use gnulib module open for portability");
446 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
448 # define openat rpl_openat
450 _GL_FUNCDECL_RPL (openat, int,
451 (int fd, char const *file, int flags, /* mode_t mode */ ...)
452 _GL_ARG_NONNULL ((2)));
453 _GL_CXXALIAS_RPL (openat, int,
454 (int fd, char const *file, int flags, /* mode_t mode */ ...));
457 _GL_FUNCDECL_SYS (openat, int,
458 (int fd, char const *file, int flags, /* mode_t mode */ ...)
459 _GL_ARG_NONNULL ((2)));
461 _GL_CXXALIAS_SYS (openat, int,
462 (int fd, char const *file, int flags, /* mode_t mode */ ...));
464 _GL_CXXALIASWARN (openat);
465 #elif defined GNULIB_POSIXCHECK
467 # if HAVE_RAW_DECL_OPENAT
468 _GL_WARN_ON_USE (openat, "openat is not portable - "
469 "use gnulib module openat for portability");
474 /* Fix up the FD_* macros, only known to be missing on mingw. */
477 # define FD_CLOEXEC 1
480 /* Fix up the supported F_* macros. Intentionally leave other F_*
481 macros undefined. Only known to be missing on mingw. */
483 #ifndef F_DUPFD_CLOEXEC
484 # define F_DUPFD_CLOEXEC 0x40000000
485 /* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
486 # define GNULIB_defined_F_DUPFD_CLOEXEC 1
488 # define GNULIB_defined_F_DUPFD_CLOEXEC 0
499 /* Fix up the O_* macros. */
501 #if !defined O_DIRECT && defined O_DIRECTIO
502 /* Tru64 spells it 'O_DIRECTIO'. */
503 # define O_DIRECT O_DIRECTIO
506 #if !defined O_CLOEXEC && defined O_NOINHERIT
507 /* Mingw spells it 'O_NOINHERIT'. */
508 # define O_CLOEXEC O_NOINHERIT
520 # define O_DIRECTORY 0
528 # define O_EXEC O_RDONLY /* This is often close enough in older systems. */
531 #ifndef O_IGNORE_CTTY
532 # define O_IGNORE_CTTY 0
544 # define O_NONBLOCK O_NDELAY
547 /* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
548 value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
549 or to 0 as fallback. */
552 # define GNULIB_defined_O_NONBLOCK 0
554 # define GNULIB_defined_O_NONBLOCK 1
556 # define O_NONBLOCK 0x40000000
565 # define O_NOFOLLOW 0
585 # define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
593 # define O_TTY_INIT 0
596 #if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
598 # define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
601 /* For systems that distinguish between text and binary I/O.
602 O_BINARY is usually declared in fcntl.h */
603 #if !defined O_BINARY && defined _O_BINARY
604 /* For MSC-compatible compilers. */
605 # define O_BINARY _O_BINARY
606 # define O_TEXT _O_TEXT
609 #if defined __BEOS__ || defined __HAIKU__
610 /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
620 /* Fix up the AT_* macros. */
622 /* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
623 value exceeds INT_MAX, so its use as an int doesn't conform to the
624 C standard, and GCC and Sun C complain in some cases. If the bug
625 is present, undef AT_FDCWD here, so it can be redefined below. */
626 #if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
630 /* Use the same bit pattern as Solaris 9, but with the proper
631 signedness. The bit pattern is important, in case this actually is
632 Solaris with the above workaround. */
634 # define AT_FDCWD (-3041965)
637 /* Use the same values as Solaris 9. This shouldn't matter, but
638 there's no real reason to differ. */
639 #ifndef AT_SYMLINK_NOFOLLOW
640 # define AT_SYMLINK_NOFOLLOW 4096
644 # define AT_REMOVEDIR 1
647 /* Solaris 9 lacks these two, so just pick unique values. */
648 #ifndef AT_SYMLINK_FOLLOW
649 # define AT_SYMLINK_FOLLOW 2
653 # define AT_EACCESS 4
657 #endif /* _GL_FCNTL_H */
658 #endif /* _GL_FCNTL_H */