Blame lib/fcntl.in.h

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