diff options
Diffstat (limited to 'lib/unistd.in.h')
| -rw-r--r-- | lib/unistd.in.h | 140 | 
1 files changed, 115 insertions, 25 deletions
| diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 50f6e565..b4129663 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -1,5 +1,5 @@  /* Substitute for and wrapper around <unistd.h>. -   Copyright (C) 2003-2022 Free Software Foundation, Inc. +   Copyright (C) 2003-2024 Free Software Foundation, Inc.     This file is free software: you can redistribute it and/or modify     it under the terms of the GNU Lesser General Public License as @@ -40,6 +40,24 @@  # undef _GL_INCLUDING_UNISTD_H  #endif +/* Avoid lseek bugs in FreeBSD, macOS <https://bugs.gnu.org/61386>. +   This bug is fixed after FreeBSD 13; see <https://bugs.freebsd.org/256205>. +   Use macOS "9999" to stand for a future fixed macOS version.  */ +#if defined __FreeBSD__ && __FreeBSD__ < 14 +# undef SEEK_DATA +# undef SEEK_HOLE +#elif defined __APPLE__ && defined __MACH__ && defined SEEK_DATA +# ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +#  include <AvailabilityMacros.h> +# endif +# if (!defined MAC_OS_X_VERSION_MIN_REQUIRED \ +      || MAC_OS_X_VERSION_MIN_REQUIRED < 99990000) +#  include <sys/fcntl.h> /* It also defines the two macros.  */ +#  undef SEEK_DATA +#  undef SEEK_HOLE +# endif +#endif +  /* Get all possible declarations of gethostname().  */  #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \    && !defined _GL_INCLUDING_WINSOCK2_H @@ -51,6 +69,12 @@  #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H  #define _@GUARD_PREFIX@_UNISTD_H +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK, +   HAVE_RAW_DECL_*.  */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif +  /* NetBSD 5.0 mis-defines NULL.  Also get size_t.  */  /* But avoid namespace pollution on glibc systems.  */  #ifndef __GLIBC__ @@ -152,9 +176,6 @@  # include <getopt-pfx-core.h>  #endif -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif  _GL_INLINE_HEADER_BEGIN  #ifndef _GL_UNISTD_INLINE  # define _GL_UNISTD_INLINE _GL_INLINE @@ -541,17 +562,22 @@ _GL_CXXALIASWARN (dup2);     Return newfd if successful, otherwise -1 and errno set.     See the Linux man page at     <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */ -# if @HAVE_DUP3@ +# if @REPLACE_DUP3@  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) +#   undef dup3  #   define dup3 rpl_dup3  #  endif  _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));  _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));  # else +#  if !@HAVE_DUP3@  _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags)); +#  endif  _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (dup3); +# endif  #elif defined GNULIB_POSIXCHECK  # undef dup3  # if HAVE_RAW_DECL_DUP3 @@ -870,7 +896,9 @@ _GL_FUNCDECL_SYS (execvpe, int,  _GL_CXXALIAS_SYS (execvpe, int,                    (const char *program, char * const *argv, char * const *env));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (execvpe); +# endif  #elif defined GNULIB_POSIXCHECK  # undef execvpe  # if HAVE_RAW_DECL_EXECVPE @@ -925,7 +953,9 @@ _GL_FUNCDECL_SYS (faccessat, int,  _GL_CXXALIAS_SYS (faccessat, int,                    (int fd, char const *file, int mode, int flag));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (faccessat); +# endif  #elif defined GNULIB_POSIXCHECK  # undef faccessat  # if HAVE_RAW_DECL_FACCESSAT @@ -941,23 +971,28 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "     Return 0 if successful, otherwise -1 and errno set.     See the POSIX:2008 specification     <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>.  */ -# if ! @HAVE_FCHDIR@ +# if @REPLACE_FCHDIR@ +#  if !(defined __cplusplus && defined GNULIB_NAMESPACE) +#   undef fchdir +#   define fchdir rpl_fchdir +#  endif +_GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/)); +_GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/)); +# else +#  if !@HAVE_FCHDIR@ || !@HAVE_DECL_FCHDIR@  _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); - +#  endif +_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); +# endif +_GL_CXXALIASWARN (fchdir); +# if @REPLACE_FCHDIR@ || !@HAVE_FCHDIR@  /* Gnulib internal hooks needed to maintain the fchdir metadata.  */  _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)       _GL_ARG_NONNULL ((2));  _GL_EXTERN_C void _gl_unregister_fd (int fd);  _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);  _GL_EXTERN_C const char *_gl_directory_name (int fd); - -# else -#  if !@HAVE_DECL_FCHDIR@ -_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); -#  endif  # endif -_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); -_GL_CXXALIASWARN (fchdir);  #elif defined GNULIB_POSIXCHECK  # undef fchdir  # if HAVE_RAW_DECL_FCHDIR @@ -1002,11 +1037,22 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "     Return 0 if successful, otherwise -1 and errno set.     See POSIX:2008 specification     <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>.  */ -# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@ +# if @REPLACE_FDATASYNC@ +#  if !(defined __cplusplus && defined GNULIB_NAMESPACE) +#   undef fdatasync +#   define fdatasync rpl_fdatasync +#  endif +_GL_FUNCDECL_RPL (fdatasync, int, (int fd)); +_GL_CXXALIAS_RPL (fdatasync, int, (int fd)); +# else +#  if !@HAVE_FDATASYNC@|| !@HAVE_DECL_FDATASYNC@  _GL_FUNCDECL_SYS (fdatasync, int, (int fd)); -# endif +#  endif  _GL_CXXALIAS_SYS (fdatasync, int, (int fd)); +# endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (fdatasync); +# endif  #elif defined GNULIB_POSIXCHECK  # undef fdatasync  # if HAVE_RAW_DECL_FDATASYNC @@ -1053,7 +1099,9 @@ _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));  #  endif  _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (ftruncate); +# endif  #elif defined GNULIB_POSIXCHECK  # undef ftruncate  # if HAVE_RAW_DECL_FTRUNCATE @@ -1070,10 +1118,10 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "     or SIZE was too small.     See the POSIX:2008 specification     <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>. -   Additionally, the gnulib module 'getcwd' guarantees the following GNU -   extension: If BUF is NULL, an array is allocated with 'malloc'; the array -   is SIZE bytes long, unless SIZE == 0, in which case it is as big as -   necessary.  */ +   Additionally, the gnulib module 'getcwd' or 'getcwd-lgpl' guarantees the +   following GNU extension: If BUF is NULL, an array is allocated with +   'malloc'; the array is SIZE bytes long, unless SIZE == 0, in which case +   it is as big as necessary.  */  # if @REPLACE_GETCWD@  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)  #   define getcwd rpl_getcwd @@ -1185,11 +1233,22 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "  #if @GNULIB_GETENTROPY@  /* Fill a buffer with random bytes.  */ -# if !@HAVE_GETENTROPY@ +# if @REPLACE_GETENTROPY@ +#  if !(defined __cplusplus && defined GNULIB_NAMESPACE) +#   undef getentropy +#   define getentropy rpl_getentropy +#  endif +_GL_FUNCDECL_RPL (getentropy, int, (void *buffer, size_t length)); +_GL_CXXALIAS_RPL (getentropy, int, (void *buffer, size_t length)); +# else +#  if !@HAVE_GETENTROPY@  _GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length)); -# endif +#  endif  _GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length)); +# endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (getentropy); +# endif  #elif defined GNULIB_POSIXCHECK  # undef getentropy  # if HAVE_RAW_DECL_GETENTROPY @@ -1323,7 +1382,9 @@ _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)                                                       int size.  */  _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (getlogin_r); +# endif  #elif defined GNULIB_POSIXCHECK  # undef getlogin_r  # if HAVE_RAW_DECL_GETLOGIN_R @@ -1661,7 +1722,9 @@ _GL_CXXALIAS_SYS (linkat, int,                    (int fd1, const char *path1, int fd2, const char *path2,                     int flag));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (linkat); +# endif  #elif defined GNULIB_POSIXCHECK  # undef linkat  # if HAVE_RAW_DECL_LINKAT @@ -1742,8 +1805,9 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - "     Return 0 upon success, or -1 with errno set upon failure.     See also the Linux man page at     <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */ -# if @HAVE_PIPE2@ +# if @REPLACE_PIPE2@  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) +#   undef pipe2  #   define pipe2 rpl_pipe2  #  endif  _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); @@ -1752,7 +1816,9 @@ _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));  _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));  _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (pipe2); +# endif  #elif defined GNULIB_POSIXCHECK  # undef pipe2  # if HAVE_RAW_DECL_PIPE2 @@ -1787,7 +1853,9 @@ _GL_FUNCDECL_SYS (pread, ssize_t,  _GL_CXXALIAS_SYS (pread, ssize_t,                    (int fd, void *buf, size_t bufsize, off_t offset));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (pread); +# endif  #elif defined GNULIB_POSIXCHECK  # undef pread  # if HAVE_RAW_DECL_PREAD @@ -1822,7 +1890,9 @@ _GL_FUNCDECL_SYS (pwrite, ssize_t,  _GL_CXXALIAS_SYS (pwrite, ssize_t,                    (int fd, const void *buf, size_t bufsize, off_t offset));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (pwrite); +# endif  #elif defined GNULIB_POSIXCHECK  # undef pwrite  # if HAVE_RAW_DECL_PWRITE @@ -1936,7 +2006,9 @@ _GL_CXXALIAS_SYS (readlinkat, ssize_t,                    (int fd, char const *restrict file,                     char *restrict buf, size_t len));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (readlinkat); +# endif  #elif defined GNULIB_POSIXCHECK  # undef readlinkat  # if HAVE_RAW_DECL_READLINKAT @@ -1996,15 +2068,27 @@ _GL_CXXALIASWARN (rmdir);     Platforms with no ability to set the hostname return -1 and set     errno = ENOSYS.  */ -# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ +# if @REPLACE_SETHOSTNAME@ +#  if !(defined __cplusplus && defined GNULIB_NAMESPACE) +#   undef sethostname +#   define sethostname rpl_sethostname +#  endif +_GL_FUNCDECL_RPL (sethostname, int, (const char *name, size_t len) +                                    _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (sethostname, int, (const char *name, size_t len)); +# else +#  if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@  _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)                                      _GL_ARG_NONNULL ((1))); -# endif +#  endif  /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5     and FreeBSD 6.4 the second parameter is int.  On Solaris 11     2011-10, the first parameter is not const.  */  _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len)); +# endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (sethostname); +# endif  #elif defined GNULIB_POSIXCHECK  # undef sethostname  # if HAVE_RAW_DECL_SETHOSTNAME @@ -2113,7 +2197,9 @@ _GL_FUNCDECL_SYS (symlinkat, int,  _GL_CXXALIAS_SYS (symlinkat, int,                    (char const *contents, int fd, char const *file));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (symlinkat); +# endif  #elif defined GNULIB_POSIXCHECK  # undef symlinkat  # if HAVE_RAW_DECL_SYMLINKAT @@ -2143,7 +2229,9 @@ _GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)  #  endif  _GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (truncate); +# endif  #elif defined GNULIB_POSIXCHECK  # undef truncate  # if HAVE_RAW_DECL_TRUNCATE @@ -2173,7 +2261,9 @@ _GL_FUNCDECL_SYS (ttyname_r, int,  _GL_CXXALIAS_SYS (ttyname_r, int,                    (int fd, char *buf, size_t buflen));  # endif +# if __GLIBC__ >= 2  _GL_CXXALIASWARN (ttyname_r); +# endif  #elif defined GNULIB_POSIXCHECK  # undef ttyname_r  # if HAVE_RAW_DECL_TTYNAME_R | 
