Blame src/gl/fcntl.in.h

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