diff options
Diffstat (limited to 'lib/unistd.in.h')
-rw-r--r-- | lib/unistd.in.h | 129 |
1 files changed, 90 insertions, 39 deletions
diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 66f254d..d6176ad 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-2018 Free Software Foundation, Inc. + Copyright (C) 2003-2020 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ #endif @PRAGMA_COLUMNS@ -#ifdef _GL_INCLUDING_UNISTD_H +#if @HAVE_UNISTD_H@ && defined _GL_INCLUDING_UNISTD_H /* Special invocation convention: - On Mac OS X 10.3.9 we have a sequence of nested includes <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h> @@ -52,7 +52,10 @@ #define _@GUARD_PREFIX@_UNISTD_H /* NetBSD 5.0 mis-defines NULL. Also get size_t. */ -#include <stddef.h> +/* But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include <stddef.h> +#endif /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */ /* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include @@ -68,9 +71,11 @@ # include <stdio.h> #endif -/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */ +/* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in + <unistd.h>. */ /* But avoid namespace pollution on glibc systems. */ -#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \ +#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \ + && (defined __CYGWIN__ || defined __ANDROID__) \ && ! defined __GLIBC__ # include <fcntl.h> #endif @@ -113,17 +118,18 @@ # include <netdb.h> #endif -/* MSVC defines off_t in <sys/types.h>. - May also define off_t to a 64-bit type on native Windows. */ -#if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@ -/* Get off_t. */ -# include <sys/types.h> +/* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>. */ +/* But avoid namespace pollution on glibc systems. */ +#if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \ + && !defined __GLIBC__ +# include <sys/stat.h> #endif -#if (@GNULIB_READ@ || @GNULIB_WRITE@ \ - || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ - || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK) -/* Get ssize_t. */ +/* MSVC defines off_t in <sys/types.h>. + May also define off_t to a 64-bit type on native Windows. */ +/* But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +/* Get off_t, ssize_t. */ # include <sys/types.h> #endif @@ -135,7 +141,7 @@ /* Get getopt(), optarg, optind, opterr, optopt. */ -#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT +#if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT # include <getopt-cdefs.h> # include <getopt-pfx-core.h> #endif @@ -247,10 +253,28 @@ _GL_INLINE_HEADER_BEGIN /* Declare overridden functions. */ -#if defined GNULIB_POSIXCHECK +#if @GNULIB_ACCESS@ +# if @REPLACE_ACCESS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef access +# define access rpl_access +# endif +_GL_FUNCDECL_RPL (access, int, (const char *file, int mode) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (access, int, (const char *file, int mode)); +# else +_GL_CXXALIAS_SYS (access, int, (const char *file, int mode)); +# endif +_GL_CXXALIASWARN (access); +#elif defined GNULIB_POSIXCHECK +# undef access +# if HAVE_RAW_DECL_ACCESS /* The access() function is a security risk. */ -_GL_WARN_ON_USE (access, "the access function is a security risk - " +_GL_WARN_ON_USE (access, "access does not always support X_OK - " + "use gnulib module access for portability; " + "also, this function is a security risk - " "use the gnulib module faccessat instead"); +# endif #endif @@ -271,7 +295,7 @@ _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - " to GID (if GID is not -1). Follow symbolic links. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */ # if @REPLACE_CHOWN@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef chown @@ -322,6 +346,24 @@ _GL_WARN_ON_USE (close, "close does not portably work on sockets - " #endif +#if @GNULIB_COPY_FILE_RANGE@ +# if !@HAVE_COPY_FILE_RANGE@ +_GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos, + int ofd, off_t *opos, + size_t len, unsigned flags)); +_GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos, + int ofd, off_t *opos, + size_t len, unsigned flags)); +# endif +_GL_CXXALIASWARN (copy_file_range); +#elif defined GNULIB_POSIXCHECK +/* Assume copy_file_range is always declared. */ +_GL_WARN_ON_USE (copy_file_range, + "copy_file_range is unportable - " + "use gnulib module copy_file_range for portability"); +#endif + + #if @GNULIB_DUP@ # if @REPLACE_DUP@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -347,7 +389,7 @@ _GL_WARN_ON_USE (dup, "dup is unportable - " NEWFD = OLDFD, otherwise close NEWFD first if it is open. Return newfd if successful, otherwise -1 and errno set. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */ # if @REPLACE_DUP2@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define dup2 rpl_dup2 @@ -502,7 +544,7 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - " the given file descriptor is open. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */ # if ! @HAVE_FCHDIR@ _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); @@ -563,7 +605,7 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - " /* Synchronize changes to a file. Return 0 if successful, otherwise -1 and errno set. See POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */ # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@ _GL_FUNCDECL_SYS (fdatasync, int, (int fd)); # endif @@ -582,7 +624,7 @@ _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - " /* Synchronize changes, including metadata, to a file. Return 0 if successful, otherwise -1 and errno set. See POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */ # if !@HAVE_FSYNC@ _GL_FUNCDECL_SYS (fsync, int, (int fd)); # endif @@ -601,7 +643,7 @@ _GL_WARN_ON_USE (fsync, "fsync is unportable - " /* Change the size of the file to which FD is opened to become equal to LENGTH. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */ # if @REPLACE_FTRUNCATE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ftruncate @@ -631,7 +673,7 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - " Return BUF if successful, or NULL if the directory couldn't be determined or SIZE was too small. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>. + <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 @@ -707,7 +749,9 @@ _GL_CXXALIAS_RPL (getdtablesize, int, (void)); # if !@HAVE_GETDTABLESIZE@ _GL_FUNCDECL_SYS (getdtablesize, int, (void)); # endif -_GL_CXXALIAS_SYS (getdtablesize, int, (void)); +/* Need to cast, because on AIX, the parameter list is + (...). */ +_GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void)); # endif _GL_CXXALIASWARN (getdtablesize); #elif defined GNULIB_POSIXCHECK @@ -791,7 +835,7 @@ _GL_WARN_ON_USE (gethostname, "gethostname is unportable - " /* Returns the user's login name, or NULL if it cannot be found. Upon error, returns NULL with errno set. - See <http://www.opengroup.org/susv3xsh/getlogin.html>. + See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>. Most programs don't need to use this function, because the information is available through environment variables: @@ -820,7 +864,7 @@ _GL_WARN_ON_USE (getlogin, "getlogin is unportable - " the case that the login name cannot be found but no specific error is provided (this case is hopefully rare but is left open by the POSIX spec). - See <http://www.opengroup.org/susv3xsh/getlogin.html>. + See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>. Most programs don't need to use this function, because the information is available through environment variables: @@ -861,6 +905,11 @@ _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - " _GL_FUNCDECL_RPL (getpagesize, int, (void)); _GL_CXXALIAS_RPL (getpagesize, int, (void)); # else +/* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if + the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */ +# if defined __hpux +_GL_FUNCDECL_SYS (getpagesize, int, (void)); +# endif # if !@HAVE_GETPAGESIZE@ # if !defined getpagesize /* This is for POSIX systems. */ @@ -1055,7 +1104,7 @@ _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - " to GID (if GID is not -1). Do not follow symbolic links. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */ # if @REPLACE_LCHOWN@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef lchown @@ -1085,7 +1134,7 @@ _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - " /* Create a new hard link for an existing file. Return 0 if successful, otherwise -1 and errno set. See POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */ # if @REPLACE_LINK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define link rpl_link @@ -1151,7 +1200,7 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - " /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. Return the new offset if successful, otherwise -1 and errno set. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */ # if @REPLACE_LSEEK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define lseek rpl_lseek @@ -1223,7 +1272,7 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - " Return the number of bytes placed into BUF if successful, otherwise set errno and return -1. 0 indicates EOF. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */ # if @REPLACE_PREAD@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef pread @@ -1258,7 +1307,7 @@ _GL_WARN_ON_USE (pread, "pread is unportable - " Return the number of bytes written if successful, otherwise set errno and return -1. 0 indicates nothing written. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */ # if @REPLACE_PWRITE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef pwrite @@ -1291,7 +1340,7 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - " #if @GNULIB_READ@ /* Read up to COUNT bytes from file descriptor FD into the buffer starting at BUF. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */ # if @REPLACE_READ@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef read @@ -1315,7 +1364,7 @@ _GL_CXXALIASWARN (read); bytes of it into BUF. Return the number of bytes placed into BUF if successful, otherwise -1 and errno set. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */ # if @REPLACE_READLINK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define readlink rpl_readlink @@ -1425,7 +1474,7 @@ _GL_WARN_ON_USE (sethostname, "sethostname is unportable - " /* Pause the execution of the current thread for N seconds. Returns the number of seconds left to sleep. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */ # if @REPLACE_SLEEP@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef sleep @@ -1509,7 +1558,7 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - " /* Change the size of the file designated by FILENAME to become equal to LENGTH. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */ # if @REPLACE_TRUNCATE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef truncate @@ -1616,7 +1665,7 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " /* Pause the execution of the current thread for N microseconds. Returns 0 on completion, or -1 on range error. See the POSIX:2001 specification - <http://www.opengroup.org/susv3xsh/usleep.html>. */ + <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */ # if @REPLACE_USLEEP@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef usleep @@ -1628,7 +1677,9 @@ _GL_CXXALIAS_RPL (usleep, int, (useconds_t n)); # if !@HAVE_USLEEP@ _GL_FUNCDECL_SYS (usleep, int, (useconds_t n)); # endif -_GL_CXXALIAS_SYS (usleep, int, (useconds_t n)); +/* Need to cast, because on Haiku, the first parameter is + unsigned int n. */ +_GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n)); # endif _GL_CXXALIASWARN (usleep); #elif defined GNULIB_POSIXCHECK @@ -1643,7 +1694,7 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - " #if @GNULIB_WRITE@ /* Write up to COUNT bytes starting at BUF to file descriptor FD. See the POSIX:2008 specification - <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */ + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */ # if @REPLACE_WRITE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef write |