1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Like <fcntl.h>, but with non-working flags defined to 0.
4 Copyright (C) 2006-2020 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>
43 /* Native Windows platforms declare open(), creat() in <io.h>. */
44 #if (0 || 1 || defined GNULIB_POSIXCHECK) \
45 && (defined _WIN32 && ! defined __CYGWIN__)
50 /* Normal invocation convention. */
54 /* Needed before <sys/stat.h>.
55 May also define off_t to a 64-bit type on native Windows. */
56 #include <sys/types.h>
57 /* On some systems other than glibc, <sys/stat.h> is a prerequisite of
58 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
59 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
60 extern "C" { ... } block, which leads to errors in C++ mode with the
61 overridden <sys/stat.h> from gnulib. These errors are known to be gone
62 with g++ version >= 4.3. */
63 #if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
64 # include <sys/stat.h>
66 /* The include_next requires a split double-inclusion guard. */
67 #include_next <fcntl.h>
69 /* Native Windows platforms declare open(), creat() in <io.h>. */
70 #if (0 || 1 || defined GNULIB_POSIXCHECK) \
71 && (defined _WIN32 && ! defined __CYGWIN__)
78 #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
83 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
84 /* C++ compatible function declaration macros.
85 Copyright (C) 2010-2020 Free Software Foundation, Inc.
87 This program is free software: you can redistribute it and/or modify it
88 under the terms of the GNU General Public License as published
89 by the Free Software Foundation; either version 3 of the License, or
90 (at your option) any later version.
92 This program is distributed in the hope that it will be useful,
93 but WITHOUT ANY WARRANTY; without even the implied warranty of
94 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
95 General Public License for more details.
97 You should have received a copy of the GNU General Public License
98 along with this program. If not, see <https://www.gnu.org/licenses/>. */
100 #ifndef _GL_CXXDEFS_H
101 #define _GL_CXXDEFS_H
103 /* Begin/end the GNULIB_NAMESPACE namespace. */
104 #if defined __cplusplus && defined GNULIB_NAMESPACE
105 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
106 # define _GL_END_NAMESPACE }
108 # define _GL_BEGIN_NAMESPACE
109 # define _GL_END_NAMESPACE
112 /* The three most frequent use cases of these macros are:
114 * For providing a substitute for a function that is missing on some
115 platforms, but is declared and works fine on the platforms on which
120 _GL_FUNCDECL_SYS (foo, ...);
122 _GL_CXXALIAS_SYS (foo, ...);
123 _GL_CXXALIASWARN (foo);
124 #elif defined GNULIB_POSIXCHECK
128 * For providing a replacement for a function that exists on all platforms,
129 but is broken/insufficient and needs to be replaced on some platforms:
133 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
137 _GL_FUNCDECL_RPL (foo, ...);
138 _GL_CXXALIAS_RPL (foo, ...);
140 _GL_CXXALIAS_SYS (foo, ...);
142 _GL_CXXALIASWARN (foo);
143 #elif defined GNULIB_POSIXCHECK
147 * For providing a replacement for a function that exists on some platforms
148 but is broken/insufficient and needs to be replaced on some of them and
149 is additionally either missing or undeclared on some other platforms:
153 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
157 _GL_FUNCDECL_RPL (foo, ...);
158 _GL_CXXALIAS_RPL (foo, ...);
160 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
161 _GL_FUNCDECL_SYS (foo, ...);
163 _GL_CXXALIAS_SYS (foo, ...);
165 _GL_CXXALIASWARN (foo);
166 #elif defined GNULIB_POSIXCHECK
171 /* _GL_EXTERN_C declaration;
172 performs the declaration with C linkage. */
173 #if defined __cplusplus
174 # define _GL_EXTERN_C extern "C"
176 # define _GL_EXTERN_C extern
179 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
180 declares a replacement function, named rpl_func, with the given prototype,
181 consisting of return type, parameters, and attributes.
183 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
184 _GL_ARG_NONNULL ((1)));
186 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
187 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
188 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
189 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
191 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
192 declares the system function, named func, with the given prototype,
193 consisting of return type, parameters, and attributes.
195 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
196 _GL_ARG_NONNULL ((1)));
198 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
199 _GL_EXTERN_C rettype func parameters_and_attributes
201 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
202 declares a C++ alias called GNULIB_NAMESPACE::func
203 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
205 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
207 Wrapping rpl_func in an object with an inline conversion operator
208 avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
209 actually used in the program. */
210 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
211 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
212 #if defined __cplusplus && defined GNULIB_NAMESPACE
213 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
214 namespace GNULIB_NAMESPACE \
216 static const struct _gl_ ## func ## _wrapper \
218 typedef rettype (*type) parameters; \
220 inline operator type () const \
226 _GL_EXTERN_C int _gl_cxxalias_dummy
228 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
229 _GL_EXTERN_C int _gl_cxxalias_dummy
232 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
233 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
234 except that the C function rpl_func may have a slightly different
235 declaration. A cast is used to silence the "invalid conversion" error
236 that would otherwise occur. */
237 #if defined __cplusplus && defined GNULIB_NAMESPACE
238 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
239 namespace GNULIB_NAMESPACE \
241 static const struct _gl_ ## func ## _wrapper \
243 typedef rettype (*type) parameters; \
245 inline operator type () const \
247 return reinterpret_cast<type>(::rpl_func); \
251 _GL_EXTERN_C int _gl_cxxalias_dummy
253 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
254 _GL_EXTERN_C int _gl_cxxalias_dummy
257 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
258 declares a C++ alias called GNULIB_NAMESPACE::func
259 that redirects to the system provided function func, if GNULIB_NAMESPACE
262 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
264 Wrapping func in an object with an inline conversion operator
265 avoids a reference to func unless GNULIB_NAMESPACE::func is
266 actually used in the program. */
267 #if defined __cplusplus && defined GNULIB_NAMESPACE
268 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
269 namespace GNULIB_NAMESPACE \
271 static const struct _gl_ ## func ## _wrapper \
273 typedef rettype (*type) parameters; \
275 inline operator type () const \
281 _GL_EXTERN_C int _gl_cxxalias_dummy
283 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
284 _GL_EXTERN_C int _gl_cxxalias_dummy
287 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
288 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
289 except that the C function func may have a slightly different declaration.
290 A cast is used to silence the "invalid conversion" error that would
292 #if defined __cplusplus && defined GNULIB_NAMESPACE
293 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
294 namespace GNULIB_NAMESPACE \
296 static const struct _gl_ ## func ## _wrapper \
298 typedef rettype (*type) parameters; \
300 inline operator type () const \
302 return reinterpret_cast<type>(::func); \
306 _GL_EXTERN_C int _gl_cxxalias_dummy
308 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
309 _GL_EXTERN_C int _gl_cxxalias_dummy
312 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
313 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
314 except that the C function is picked among a set of overloaded functions,
315 namely the one with rettype2 and parameters2. Two consecutive casts
316 are used to silence the "cannot find a match" and "invalid conversion"
317 errors that would otherwise occur. */
318 #if defined __cplusplus && defined GNULIB_NAMESPACE
319 /* The outer cast must be a reinterpret_cast.
320 The inner cast: When the function is defined as a set of overloaded
321 functions, it works as a static_cast<>, choosing the designated variant.
322 When the function is defined as a single variant, it works as a
323 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
324 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
325 namespace GNULIB_NAMESPACE \
327 static const struct _gl_ ## func ## _wrapper \
329 typedef rettype (*type) parameters; \
331 inline operator type () const \
333 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
337 _GL_EXTERN_C int _gl_cxxalias_dummy
339 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
340 _GL_EXTERN_C int _gl_cxxalias_dummy
343 /* _GL_CXXALIASWARN (func);
344 causes a warning to be emitted when ::func is used but not when
345 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
347 #if defined __cplusplus && defined GNULIB_NAMESPACE
348 # define _GL_CXXALIASWARN(func) \
349 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
350 # define _GL_CXXALIASWARN_1(func,namespace) \
351 _GL_CXXALIASWARN_2 (func, namespace)
352 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
353 we enable the warning only when not optimizing. */
355 # define _GL_CXXALIASWARN_2(func,namespace) \
356 _GL_WARN_ON_USE (func, \
357 "The symbol ::" #func " refers to the system function. " \
358 "Use " #namespace "::" #func " instead.")
359 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
360 # define _GL_CXXALIASWARN_2(func,namespace) \
361 extern __typeof__ (func) func
363 # define _GL_CXXALIASWARN_2(func,namespace) \
364 _GL_EXTERN_C int _gl_cxxalias_dummy
367 # define _GL_CXXALIASWARN(func) \
368 _GL_EXTERN_C int _gl_cxxalias_dummy
371 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
372 causes a warning to be emitted when the given overloaded variant of ::func
373 is used but not when GNULIB_NAMESPACE::func is used. */
374 #if defined __cplusplus && defined GNULIB_NAMESPACE
375 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
376 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
378 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
379 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
380 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
381 we enable the warning only when not optimizing. */
383 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
384 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
385 "The symbol ::" #func " refers to the system function. " \
386 "Use " #namespace "::" #func " instead.")
387 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
388 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
389 extern __typeof__ (func) func
391 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
392 _GL_EXTERN_C int _gl_cxxalias_dummy
395 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
396 _GL_EXTERN_C int _gl_cxxalias_dummy
399 #endif /* _GL_CXXDEFS_H */
401 /* The definition of _GL_ARG_NONNULL is copied here. */
402 /* A C macro for declaring that specific arguments must not be NULL.
403 Copyright (C) 2009-2020 Free Software Foundation, Inc.
405 This program is free software: you can redistribute it and/or modify it
406 under the terms of the GNU General Public License as published
407 by the Free Software Foundation; either version 3 of the License, or
408 (at your option) any later version.
410 This program is distributed in the hope that it will be useful,
411 but WITHOUT ANY WARRANTY; without even the implied warranty of
412 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
413 General Public License for more details.
415 You should have received a copy of the GNU General Public License
416 along with this program. If not, see <https://www.gnu.org/licenses/>. */
418 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
419 that the values passed as arguments n, ..., m must be non-NULL pointers.
420 n = 1 stands for the first argument, n = 2 for the second argument etc. */
421 #ifndef _GL_ARG_NONNULL
422 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
423 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
425 # define _GL_ARG_NONNULL(params)
429 /* The definition of _GL_WARN_ON_USE is copied here. */
430 /* A C macro for emitting warnings if a function is used.
431 Copyright (C) 2010-2020 Free Software Foundation, Inc.
433 This program is free software: you can redistribute it and/or modify it
434 under the terms of the GNU General Public License as published
435 by the Free Software Foundation; either version 3 of the License, or
436 (at your option) any later version.
438 This program is distributed in the hope that it will be useful,
439 but WITHOUT ANY WARRANTY; without even the implied warranty of
440 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
441 General Public License for more details.
443 You should have received a copy of the GNU General Public License
444 along with this program. If not, see <https://www.gnu.org/licenses/>. */
446 /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
447 for FUNCTION which will then trigger a compiler warning containing
448 the text of "literal string" anywhere that function is called, if
449 supported by the compiler. If the compiler does not support this
450 feature, the macro expands to an unused extern declaration.
452 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
453 attribute used in _GL_WARN_ON_USE. If the compiler does not support
454 this feature, it expands to empty.
456 These macros are useful for marking a function as a potential
457 portability trap, with the intent that "literal string" include
458 instructions on the replacement function that should be used
460 _GL_WARN_ON_USE is for functions with 'extern' linkage.
461 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
464 However, one of the reasons that a function is a portability trap is
465 if it has the wrong signature. Declaring FUNCTION with a different
466 signature in C is a compilation error, so this macro must use the
467 same type as any existing declaration so that programs that avoid
468 the problematic FUNCTION do not fail to compile merely because they
469 included a header that poisoned the function. But this implies that
470 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
471 have a declaration. Use of this macro implies that there must not
472 be any other macro hiding the declaration of FUNCTION; but
473 undefining FUNCTION first is part of the poisoning process anyway
474 (although for symbols that are provided only via a macro, the result
475 is a compilation error rather than a warning containing
476 "literal string"). Also note that in C++, it is only safe to use if
477 FUNCTION has no overloads.
479 For an example, it is possible to poison 'getline' by:
480 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
481 [getline]) in configure.ac, which potentially defines
482 HAVE_RAW_DECL_GETLINE
483 - adding this code to a header that wraps the system <stdio.h>:
485 #if HAVE_RAW_DECL_GETLINE
486 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
487 "not universally present; use the gnulib module getline");
490 It is not possible to directly poison global variables. But it is
491 possible to write a wrapper accessor function, and poison that
492 (less common usage, like &environ, will cause a compilation error
493 rather than issue the nice warning, but the end result of informing
494 the developer about their portability problem is still achieved):
495 #if HAVE_RAW_DECL_ENVIRON
497 rpl_environ (void) { return &environ; }
498 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
500 # define environ (*rpl_environ ())
502 or better (avoiding contradictory use of 'static' and 'extern'):
503 #if HAVE_RAW_DECL_ENVIRON
505 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
506 rpl_environ (void) { return &environ; }
508 # define environ (*rpl_environ ())
511 #ifndef _GL_WARN_ON_USE
513 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
514 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
515 # define _GL_WARN_ON_USE(function, message) \
516 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
517 # define _GL_WARN_ON_USE_ATTRIBUTE(message) \
518 __attribute__ ((__warning__ (message)))
519 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
520 /* Verify the existence of the function. */
521 # define _GL_WARN_ON_USE(function, message) \
522 extern __typeof__ (function) function
523 # define _GL_WARN_ON_USE_ATTRIBUTE(message)
524 # else /* Unsupported. */
525 # define _GL_WARN_ON_USE(function, message) \
526 _GL_WARN_EXTERN_C int _gl_warn_on_use
527 # define _GL_WARN_ON_USE_ATTRIBUTE(message)
531 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
532 is like _GL_WARN_ON_USE (function, "string"), except that the function is
533 declared with the given prototype, consisting of return type, parameters,
535 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
536 not work in this case. */
537 #ifndef _GL_WARN_ON_USE_CXX
538 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
539 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
540 extern rettype function parameters_and_attributes \
541 __attribute__ ((__warning__ (msg)))
542 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
543 /* Verify the existence of the function. */
544 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
545 extern rettype function parameters_and_attributes
546 # else /* Unsupported. */
547 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
548 _GL_WARN_EXTERN_C int _gl_warn_on_use
552 /* _GL_WARN_EXTERN_C declaration;
553 performs the declaration with C linkage. */
554 #ifndef _GL_WARN_EXTERN_C
555 # if defined __cplusplus
556 # define _GL_WARN_EXTERN_C extern "C"
558 # define _GL_WARN_EXTERN_C extern
563 /* Declare overridden functions. */
567 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
569 # define creat rpl_creat
571 _GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode)
572 _GL_ARG_NONNULL ((1)));
573 _GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
575 _GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
577 _GL_CXXALIASWARN (creat);
578 #elif defined GNULIB_POSIXCHECK
580 /* Assume creat is always declared. */
581 _GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - "
582 "use gnulib module creat for portability");
587 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
589 # define fcntl rpl_fcntl
591 _GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
592 _GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
595 _GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
597 _GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
599 _GL_CXXALIASWARN (fcntl);
600 #elif defined GNULIB_POSIXCHECK
602 # if HAVE_RAW_DECL_FCNTL
603 _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
604 "use gnulib module fcntl for portability");
610 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
612 # define open rpl_open
614 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
615 _GL_ARG_NONNULL ((1)));
616 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
618 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
620 /* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
621 default argument. _GL_CXXALIASWARN does not work in this case. */
623 _GL_CXXALIASWARN (open);
625 #elif defined GNULIB_POSIXCHECK
627 /* Assume open is always declared. */
628 _GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
629 "use gnulib module open for portability");
634 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
636 # define openat rpl_openat
638 _GL_FUNCDECL_RPL (openat, int,
639 (int fd, char const *file, int flags, /* mode_t mode */ ...)
640 _GL_ARG_NONNULL ((2)));
641 _GL_CXXALIAS_RPL (openat, int,
642 (int fd, char const *file, int flags, /* mode_t mode */ ...));
645 _GL_FUNCDECL_SYS (openat, int,
646 (int fd, char const *file, int flags, /* mode_t mode */ ...)
647 _GL_ARG_NONNULL ((2)));
649 _GL_CXXALIAS_SYS (openat, int,
650 (int fd, char const *file, int flags, /* mode_t mode */ ...));
652 _GL_CXXALIASWARN (openat);
653 #elif defined GNULIB_POSIXCHECK
655 # if HAVE_RAW_DECL_OPENAT
656 _GL_WARN_ON_USE (openat, "openat is not portable - "
657 "use gnulib module openat for portability");
662 /* Fix up the FD_* macros, only known to be missing on mingw. */
665 # define FD_CLOEXEC 1
668 /* Fix up the supported F_* macros. Intentionally leave other F_*
669 macros undefined. Only known to be missing on mingw. */
671 #ifndef F_DUPFD_CLOEXEC
672 # define F_DUPFD_CLOEXEC 0x40000000
673 /* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
674 # define GNULIB_defined_F_DUPFD_CLOEXEC 1
676 # define GNULIB_defined_F_DUPFD_CLOEXEC 0
687 /* Fix up the O_* macros. */
689 /* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
690 to values outside 'int' range, so omit these misdefinitions.
691 But avoid namespace pollution on non-AIX systems. */
694 # if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
697 # if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
700 # if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
705 #if !defined O_DIRECT && defined O_DIRECTIO
706 /* Tru64 spells it 'O_DIRECTIO'. */
707 # define O_DIRECT O_DIRECTIO
710 #if !defined O_CLOEXEC && defined O_NOINHERIT
711 /* Mingw spells it 'O_NOINHERIT'. */
712 # define O_CLOEXEC O_NOINHERIT
716 # define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */
717 # define GNULIB_defined_O_CLOEXEC 1
719 # define GNULIB_defined_O_CLOEXEC 0
727 # define O_DIRECTORY 0
735 # define O_EXEC O_RDONLY /* This is often close enough in older systems. */
738 #ifndef O_IGNORE_CTTY
739 # define O_IGNORE_CTTY 0
751 # define O_NONBLOCK O_NDELAY
754 /* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
755 value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
756 or to 0 as fallback. */
759 # define GNULIB_defined_O_NONBLOCK 0
761 # define GNULIB_defined_O_NONBLOCK 1
763 # define O_NONBLOCK 0x40000000
772 # define O_NOFOLLOW 0
792 # define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
800 # define O_TTY_INIT 0
803 #if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
805 # define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
808 /* For systems that distinguish between text and binary I/O.
809 O_BINARY is usually declared in fcntl.h */
810 #if !defined O_BINARY && defined _O_BINARY
811 /* For MSC-compatible compilers. */
812 # define O_BINARY _O_BINARY
813 # define O_TEXT _O_TEXT
816 #if defined __BEOS__ || defined __HAIKU__
817 /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
827 /* Fix up the AT_* macros. */
829 /* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
830 value exceeds INT_MAX, so its use as an int doesn't conform to the
831 C standard, and GCC and Sun C complain in some cases. If the bug
832 is present, undef AT_FDCWD here, so it can be redefined below. */
833 #if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
837 /* Use the same bit pattern as Solaris 9, but with the proper
838 signedness. The bit pattern is important, in case this actually is
839 Solaris with the above workaround. */
841 # define AT_FDCWD (-3041965)
844 /* Use the same values as Solaris 9. This shouldn't matter, but
845 there's no real reason to differ. */
846 #ifndef AT_SYMLINK_NOFOLLOW
847 # define AT_SYMLINK_NOFOLLOW 4096
851 # define AT_REMOVEDIR 1
854 /* Solaris 9 lacks these two, so just pick unique values. */
855 #ifndef AT_SYMLINK_FOLLOW
856 # define AT_SYMLINK_FOLLOW 2
860 # define AT_EACCESS 4
864 #endif /* _GL_FCNTL_H */
865 #endif /* _GL_FCNTL_H */