Blame lib/fcntl.in.h

Packit 8f70b4
/* Like <fcntl.h>, but with non-working flags defined to 0.
Packit 8f70b4
Packit 8f70b4
   Copyright (C) 2006-2018 Free Software Foundation, Inc.
Packit 8f70b4
Packit 8f70b4
   This program is free software: you can redistribute it and/or modify
Packit 8f70b4
   it under the terms of the GNU General Public License as published by
Packit 8f70b4
   the Free Software Foundation; either version 3 of the License, or
Packit 8f70b4
   (at your option) any later version.
Packit 8f70b4
Packit 8f70b4
   This program is distributed in the hope that it will be useful,
Packit 8f70b4
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8f70b4
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 8f70b4
   GNU General Public License for more details.
Packit 8f70b4
Packit 8f70b4
   You should have received a copy of the GNU General Public License
Packit 8f70b4
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit 8f70b4
Packit 8f70b4
/* written by Paul Eggert */
Packit 8f70b4
Packit 8f70b4
#if __GNUC__ >= 3
Packit 8f70b4
@PRAGMA_SYSTEM_HEADER@
Packit 8f70b4
#endif
Packit 8f70b4
@PRAGMA_COLUMNS@
Packit 8f70b4
Packit 8f70b4
#if defined __need_system_fcntl_h
Packit 8f70b4
/* Special invocation convention.  */
Packit 8f70b4
Packit 8f70b4
/* Needed before <sys/stat.h>.
Packit 8f70b4
   May also define off_t to a 64-bit type on native Windows.  */
Packit 8f70b4
#include <sys/types.h>
Packit 8f70b4
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
Packit 8f70b4
   <fcntl.h>.  On glibc systems, we would like to avoid namespace pollution.
Packit 8f70b4
   But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
Packit 8f70b4
   extern "C" { ... } block, which leads to errors in C++ mode with the
Packit 8f70b4
   overridden <sys/stat.h> from gnulib.  These errors are known to be gone
Packit 8f70b4
   with g++ version >= 4.3.  */
Packit 8f70b4
#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
Packit 8f70b4
# include <sys/stat.h>
Packit 8f70b4
#endif
Packit 8f70b4
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
Packit 8f70b4
Packit 8f70b4
#else
Packit 8f70b4
/* Normal invocation convention.  */
Packit 8f70b4
Packit 8f70b4
#ifndef _@GUARD_PREFIX@_FCNTL_H
Packit 8f70b4
Packit 8f70b4
/* Needed before <sys/stat.h>.
Packit 8f70b4
   May also define off_t to a 64-bit type on native Windows.  */
Packit 8f70b4
#include <sys/types.h>
Packit 8f70b4
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
Packit 8f70b4
   <fcntl.h>.  On glibc systems, we would like to avoid namespace pollution.
Packit 8f70b4
   But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
Packit 8f70b4
   extern "C" { ... } block, which leads to errors in C++ mode with the
Packit 8f70b4
   overridden <sys/stat.h> from gnulib.  These errors are known to be gone
Packit 8f70b4
   with g++ version >= 4.3.  */
Packit 8f70b4
#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
Packit 8f70b4
# include <sys/stat.h>
Packit 8f70b4
#endif
Packit 8f70b4
/* The include_next requires a split double-inclusion guard.  */
Packit 8f70b4
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
Packit 8f70b4
Packit 8f70b4
#ifndef _@GUARD_PREFIX@_FCNTL_H
Packit 8f70b4
#define _@GUARD_PREFIX@_FCNTL_H
Packit 8f70b4
Packit 8f70b4
#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems.  */
Packit 8f70b4
# include <unistd.h>
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
/* Native Windows platforms declare open(), creat() in <io.h>.  */
Packit 8f70b4
#if (@GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
Packit 8f70b4
    && (defined _WIN32 && ! defined __CYGWIN__)
Packit 8f70b4
# include <io.h>
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
Packit 8f70b4
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
Packit 8f70b4
Packit 8f70b4
/* The definition of _GL_ARG_NONNULL is copied here.  */
Packit 8f70b4
Packit 8f70b4
/* The definition of _GL_WARN_ON_USE is copied here.  */
Packit 8f70b4
Packit 8f70b4
Packit 8f70b4
/* Declare overridden functions.  */
Packit 8f70b4
Packit 8f70b4
#if @GNULIB_FCNTL@
Packit 8f70b4
# if @REPLACE_FCNTL@
Packit 8f70b4
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 8f70b4
#   undef fcntl
Packit 8f70b4
#   define fcntl rpl_fcntl
Packit 8f70b4
#  endif
Packit 8f70b4
_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
Packit 8f70b4
_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
Packit 8f70b4
# else
Packit 8f70b4
#  if !@HAVE_FCNTL@
Packit 8f70b4
_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
Packit 8f70b4
#  endif
Packit 8f70b4
_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
Packit 8f70b4
# endif
Packit 8f70b4
_GL_CXXALIASWARN (fcntl);
Packit 8f70b4
#elif defined GNULIB_POSIXCHECK
Packit 8f70b4
# undef fcntl
Packit 8f70b4
# if HAVE_RAW_DECL_FCNTL
Packit 8f70b4
_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
Packit 8f70b4
                 "use gnulib module fcntl for portability");
Packit 8f70b4
# endif
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#if @GNULIB_OPEN@
Packit 8f70b4
# if @REPLACE_OPEN@
Packit 8f70b4
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 8f70b4
#   undef open
Packit 8f70b4
#   define open rpl_open
Packit 8f70b4
#  endif
Packit 8f70b4
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
Packit 8f70b4
                             _GL_ARG_NONNULL ((1)));
Packit 8f70b4
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
Packit 8f70b4
# else
Packit 8f70b4
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
Packit 8f70b4
# endif
Packit 8f70b4
/* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
Packit 8f70b4
   default argument.  _GL_CXXALIASWARN does not work in this case.  */
Packit 8f70b4
# if !defined __hpux
Packit 8f70b4
_GL_CXXALIASWARN (open);
Packit 8f70b4
# endif
Packit 8f70b4
#elif defined GNULIB_POSIXCHECK
Packit 8f70b4
# undef open
Packit 8f70b4
/* Assume open is always declared.  */
Packit 8f70b4
_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
Packit 8f70b4
                 "use gnulib module open for portability");
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#if @GNULIB_OPENAT@
Packit 8f70b4
# if @REPLACE_OPENAT@
Packit 8f70b4
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 8f70b4
#   undef openat
Packit 8f70b4
#   define openat rpl_openat
Packit 8f70b4
#  endif
Packit 8f70b4
_GL_FUNCDECL_RPL (openat, int,
Packit 8f70b4
                  (int fd, char const *file, int flags, /* mode_t mode */ ...)
Packit 8f70b4
                  _GL_ARG_NONNULL ((2)));
Packit 8f70b4
_GL_CXXALIAS_RPL (openat, int,
Packit 8f70b4
                  (int fd, char const *file, int flags, /* mode_t mode */ ...));
Packit 8f70b4
# else
Packit 8f70b4
#  if !@HAVE_OPENAT@
Packit 8f70b4
_GL_FUNCDECL_SYS (openat, int,
Packit 8f70b4
                  (int fd, char const *file, int flags, /* mode_t mode */ ...)
Packit 8f70b4
                  _GL_ARG_NONNULL ((2)));
Packit 8f70b4
#  endif
Packit 8f70b4
_GL_CXXALIAS_SYS (openat, int,
Packit 8f70b4
                  (int fd, char const *file, int flags, /* mode_t mode */ ...));
Packit 8f70b4
# endif
Packit 8f70b4
_GL_CXXALIASWARN (openat);
Packit 8f70b4
#elif defined GNULIB_POSIXCHECK
Packit 8f70b4
# undef openat
Packit 8f70b4
# if HAVE_RAW_DECL_OPENAT
Packit 8f70b4
_GL_WARN_ON_USE (openat, "openat is not portable - "
Packit 8f70b4
                 "use gnulib module openat for portability");
Packit 8f70b4
# endif
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
Packit 8f70b4
/* Fix up the FD_* macros, only known to be missing on mingw.  */
Packit 8f70b4
Packit 8f70b4
#ifndef FD_CLOEXEC
Packit 8f70b4
# define FD_CLOEXEC 1
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
/* Fix up the supported F_* macros.  Intentionally leave other F_*
Packit 8f70b4
   macros undefined.  Only known to be missing on mingw.  */
Packit 8f70b4
Packit 8f70b4
#ifndef F_DUPFD_CLOEXEC
Packit 8f70b4
# define F_DUPFD_CLOEXEC 0x40000000
Packit 8f70b4
/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise.  */
Packit 8f70b4
# define GNULIB_defined_F_DUPFD_CLOEXEC 1
Packit 8f70b4
#else
Packit 8f70b4
# define GNULIB_defined_F_DUPFD_CLOEXEC 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef F_DUPFD
Packit 8f70b4
# define F_DUPFD 1
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef F_GETFD
Packit 8f70b4
# define F_GETFD 2
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
/* Fix up the O_* macros.  */
Packit 8f70b4
Packit 8f70b4
/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
Packit 8f70b4
   to values outside 'int' range, so omit these misdefinitions.
Packit 8f70b4
   But avoid namespace pollution on non-AIX systems.  */
Packit 8f70b4
#ifdef _AIX
Packit 8f70b4
# include <limits.h>
Packit 8f70b4
# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
Packit 8f70b4
#  undef O_CLOEXEC
Packit 8f70b4
# endif
Packit 8f70b4
# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
Packit 8f70b4
#  undef O_NOFOLLOW
Packit 8f70b4
# endif
Packit 8f70b4
# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
Packit 8f70b4
#  undef O_TTY_INIT
Packit 8f70b4
# endif
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#if !defined O_DIRECT && defined O_DIRECTIO
Packit 8f70b4
/* Tru64 spells it 'O_DIRECTIO'.  */
Packit 8f70b4
# define O_DIRECT O_DIRECTIO
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#if !defined O_CLOEXEC && defined O_NOINHERIT
Packit 8f70b4
/* Mingw spells it 'O_NOINHERIT'.  */
Packit 8f70b4
# define O_CLOEXEC O_NOINHERIT
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_CLOEXEC
Packit 8f70b4
# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags.  */
Packit 8f70b4
# define GNULIB_defined_O_CLOEXEC 1
Packit 8f70b4
#else
Packit 8f70b4
# define GNULIB_defined_O_CLOEXEC 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_DIRECT
Packit 8f70b4
# define O_DIRECT 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_DIRECTORY
Packit 8f70b4
# define O_DIRECTORY 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_DSYNC
Packit 8f70b4
# define O_DSYNC 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_EXEC
Packit 8f70b4
# define O_EXEC O_RDONLY /* This is often close enough in older systems.  */
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_IGNORE_CTTY
Packit 8f70b4
# define O_IGNORE_CTTY 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_NDELAY
Packit 8f70b4
# define O_NDELAY 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_NOATIME
Packit 8f70b4
# define O_NOATIME 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_NONBLOCK
Packit 8f70b4
# define O_NONBLOCK O_NDELAY
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
/* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
Packit 8f70b4
   value of O_NONBLOCK.  Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
Packit 8f70b4
   or to 0 as fallback.  */
Packit 8f70b4
#if @GNULIB_NONBLOCKING@
Packit 8f70b4
# if O_NONBLOCK
Packit 8f70b4
#  define GNULIB_defined_O_NONBLOCK 0
Packit 8f70b4
# else
Packit 8f70b4
#  define GNULIB_defined_O_NONBLOCK 1
Packit 8f70b4
#  undef O_NONBLOCK
Packit 8f70b4
#  define O_NONBLOCK 0x40000000
Packit 8f70b4
# endif
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_NOCTTY
Packit 8f70b4
# define O_NOCTTY 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_NOFOLLOW
Packit 8f70b4
# define O_NOFOLLOW 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_NOLINK
Packit 8f70b4
# define O_NOLINK 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_NOLINKS
Packit 8f70b4
# define O_NOLINKS 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_NOTRANS
Packit 8f70b4
# define O_NOTRANS 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_RSYNC
Packit 8f70b4
# define O_RSYNC 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_SEARCH
Packit 8f70b4
# define O_SEARCH O_RDONLY /* This is often close enough in older systems.  */
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_SYNC
Packit 8f70b4
# define O_SYNC 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_TTY_INIT
Packit 8f70b4
# define O_TTY_INIT 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
Packit 8f70b4
# undef O_ACCMODE
Packit 8f70b4
# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
/* For systems that distinguish between text and binary I/O.
Packit 8f70b4
   O_BINARY is usually declared in fcntl.h  */
Packit 8f70b4
#if !defined O_BINARY && defined _O_BINARY
Packit 8f70b4
  /* For MSC-compatible compilers.  */
Packit 8f70b4
# define O_BINARY _O_BINARY
Packit 8f70b4
# define O_TEXT _O_TEXT
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#if defined __BEOS__ || defined __HAIKU__
Packit 8f70b4
  /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect.  */
Packit 8f70b4
# undef O_BINARY
Packit 8f70b4
# undef O_TEXT
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef O_BINARY
Packit 8f70b4
# define O_BINARY 0
Packit 8f70b4
# define O_TEXT 0
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
/* Fix up the AT_* macros.  */
Packit 8f70b4
Packit 8f70b4
/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive.  Its
Packit 8f70b4
   value exceeds INT_MAX, so its use as an int doesn't conform to the
Packit 8f70b4
   C standard, and GCC and Sun C complain in some cases.  If the bug
Packit 8f70b4
   is present, undef AT_FDCWD here, so it can be redefined below.  */
Packit 8f70b4
#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
Packit 8f70b4
# undef AT_FDCWD
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
/* Use the same bit pattern as Solaris 9, but with the proper
Packit 8f70b4
   signedness.  The bit pattern is important, in case this actually is
Packit 8f70b4
   Solaris with the above workaround.  */
Packit 8f70b4
#ifndef AT_FDCWD
Packit 8f70b4
# define AT_FDCWD (-3041965)
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
/* Use the same values as Solaris 9.  This shouldn't matter, but
Packit 8f70b4
   there's no real reason to differ.  */
Packit 8f70b4
#ifndef AT_SYMLINK_NOFOLLOW
Packit 8f70b4
# define AT_SYMLINK_NOFOLLOW 4096
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef AT_REMOVEDIR
Packit 8f70b4
# define AT_REMOVEDIR 1
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
/* Solaris 9 lacks these two, so just pick unique values.  */
Packit 8f70b4
#ifndef AT_SYMLINK_FOLLOW
Packit 8f70b4
# define AT_SYMLINK_FOLLOW 2
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#ifndef AT_EACCESS
Packit 8f70b4
# define AT_EACCESS 4
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
Packit 8f70b4
#endif /* _@GUARD_PREFIX@_FCNTL_H */
Packit 8f70b4
#endif /* _@GUARD_PREFIX@_FCNTL_H */
Packit 8f70b4
#endif