Blame lib/fcntl.in.h

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