Blame lib/fcntl.in.h

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