diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2025-04-19 12:18:28 -0700 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2025-04-19 19:31:25 -0700 |
| commit | 71ee484cac3e0e5b68f006b4cca81c13ca6ce11e (patch) | |
| tree | 21476621d11357283ad30c8b2bcec2871e604ba1 /lib | |
| parent | 30335bb73483fce9d4204f1e18618fe777d0f45e (diff) | |
Update from Gnulib by running admin/merge-gnulib
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/acl-internal.c | 8 | ||||
| -rw-r--r-- | lib/acl-internal.h | 14 | ||||
| -rw-r--r-- | lib/acl_entries.c | 6 | ||||
| -rw-r--r-- | lib/fcntl.in.h | 12 | ||||
| -rw-r--r-- | lib/file-has-acl.c | 26 | ||||
| -rw-r--r-- | lib/fpending.c | 2 | ||||
| -rw-r--r-- | lib/getloadavg.c | 41 | ||||
| -rw-r--r-- | lib/getopt-pfx-ext.h | 2 | ||||
| -rw-r--r-- | lib/getopt.in.h | 5 | ||||
| -rw-r--r-- | lib/gnulib.mk.in | 30 | ||||
| -rw-r--r-- | lib/intprops.h | 2 | ||||
| -rw-r--r-- | lib/nproc.c | 25 | ||||
| -rw-r--r-- | lib/readutmp.h | 22 | ||||
| -rw-r--r-- | lib/regcomp.c | 12 | ||||
| -rw-r--r-- | lib/regex.h | 31 | ||||
| -rw-r--r-- | lib/regex_internal.c | 4 | ||||
| -rw-r--r-- | lib/regexec.c | 14 | ||||
| -rw-r--r-- | lib/stdio-impl.h | 43 | ||||
| -rw-r--r-- | lib/stdlib.in.h | 14 | ||||
| -rw-r--r-- | lib/string.in.h | 128 | ||||
| -rw-r--r-- | lib/time.in.h | 2 | ||||
| -rw-r--r-- | lib/unistd.in.h | 27 | ||||
| -rw-r--r-- | lib/utimens.h | 2 | ||||
| -rw-r--r-- | lib/utimensat.c | 7 | ||||
| -rw-r--r-- | lib/verify.h | 7 |
25 files changed, 371 insertions, 115 deletions
diff --git a/lib/acl-internal.c b/lib/acl-internal.c index 1a6087b03a9..6c50feacbb8 100644 --- a/lib/acl-internal.c +++ b/lib/acl-internal.c @@ -31,7 +31,7 @@ # include <string.h> #endif -#if USE_ACL && HAVE_ACL_GET_FILE /* Linux, FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */ +#if USE_ACL && HAVE_ACL_GET_FILE /* Linux, FreeBSD, NetBSD >= 10, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */ # if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ @@ -45,7 +45,7 @@ acl_extended_nontrivial (acl_t acl) return (acl_entries (acl) > 0); } -# else /* Linux, FreeBSD, IRIX, Tru64, Cygwin >= 2.5 */ +# else /* Linux, FreeBSD, NetBSD >= 10, IRIX, Tru64, Cygwin >= 2.5 */ /* ACL is an ACL, from a file, stored as type ACL_TYPE_ACCESS. Return 1 if the given ACL is non-trivial. @@ -59,7 +59,7 @@ acl_access_nontrivial (acl_t acl) at least, allowing us to write return (3 < acl_entries (acl)); but the following code is more robust. */ -# if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD, Cygwin >= 2.5 */ +# if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */ acl_entry_t ace; int got_one; @@ -548,7 +548,7 @@ void free_permission_context (struct permission_context *ctx) { #if USE_ACL -# if HAVE_ACL_GET_FILE /* Linux, FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */ +# if HAVE_ACL_GET_FILE /* Linux, FreeBSD, NetBSD >= 10, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */ if (ctx->acl) acl_free (ctx->acl); # if !HAVE_ACL_TYPE_EXTENDED diff --git a/lib/acl-internal.h b/lib/acl-internal.h index f37b3bcff5b..cb969e9797e 100644 --- a/lib/acl-internal.h +++ b/lib/acl-internal.h @@ -52,10 +52,7 @@ extern int aclsort (int, int, struct acl *); #include <errno.h> #include <limits.h> - -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -#endif +#include <stdint.h> #ifndef HAVE_FCHMOD # define HAVE_FCHMOD false @@ -121,8 +118,13 @@ rpl_acl_set_fd (int fd, acl_t acl) # endif /* Linux-specific */ -/* Cygwin >= 2.5 implements this function, but it returns 1 for all - directories, thus is unusable. */ +/* Cygwin >= 2.5 implements acl_extended_file(), but it returns 1 for nearly all + directories — for reasons explained in + <https://sourceware.org/pipermail/cygwin/2025-March/257762.html> —, thus is + unusable. For the user, 'ls' should not print a '+' sign, indicating the + presence of an ACL, for 99,9% of the files; this would not be useful. + Therefore, on Cygwin, we ignore the acl_extended_file function and instead + use our own acl_access_nontrivial function. */ # if !defined HAVE_ACL_EXTENDED_FILE || defined __CYGWIN__ # undef HAVE_ACL_EXTENDED_FILE # define HAVE_ACL_EXTENDED_FILE false diff --git a/lib/acl_entries.c b/lib/acl_entries.c index 808ad93fe2c..57b7b4998c0 100644 --- a/lib/acl_entries.c +++ b/lib/acl_entries.c @@ -22,7 +22,7 @@ #include "acl-internal.h" /* This file assumes POSIX-draft like ACLs - (Linux, FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5). */ + (Linux, FreeBSD, NetBSD >= 10, Mac OS X, IRIX, Tru64, Cygwin >= 2.5). */ /* Return the number of entries in ACL. Return -1 and set errno upon failure to determine it. */ @@ -34,7 +34,7 @@ acl_entries (acl_t acl) if (acl != NULL) { -#if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD, Mac OS X, Cygwin >= 2.5 */ +#if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD, NetBSD >= 10, Mac OS X, Cygwin >= 2.5 */ # if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ /* acl_get_entry returns 0 when it successfully fetches an entry, and -1/EINVAL at the end. */ @@ -45,7 +45,7 @@ acl_entries (acl_t acl) got_one >= 0; got_one = acl_get_entry (acl, ACL_NEXT_ENTRY, &ace)) count++; -# else /* Linux, FreeBSD, Cygwin >= 2.5 */ +# else /* Linux, FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */ /* acl_get_entry returns 1 when it successfully fetches an entry, and 0 at the end. */ acl_entry_t ace; diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h index ac61c0865a4..d7f551b30f3 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -22,8 +22,12 @@ #endif @PRAGMA_COLUMNS@ -#if defined __need_system_fcntl_h -/* Special invocation convention. */ +#if defined __need_system_fcntl_h || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H +/* Special invocation convention: + - On Haiku we have a sequence of nested includes + <fcntl.h> -> <unistd.h> -> <fcntl.h> + In this situation, GNULIB_defined_O_NONBLOCK gets defined before the + system's definition of O_NONBLOCK is processed. */ /* Needed before <sys/stat.h>. May also define off_t to a 64-bit type on native Windows. */ @@ -50,6 +54,8 @@ #ifndef _@GUARD_PREFIX@_FCNTL_H +#define _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H + /* Needed before <sys/stat.h>. May also define off_t to a 64-bit type on native Windows. Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */ @@ -72,6 +78,8 @@ # include <io.h> #endif +#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H + #ifndef _@GUARD_PREFIX@_FCNTL_H #define _@GUARD_PREFIX@_FCNTL_H diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index c02cfee842b..66b920c1ab2 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c @@ -50,7 +50,6 @@ static char const UNKNOWN_SECURITY_CONTEXT[] = "?"; # include <selinux/selinux.h> # endif # include <stdckdint.h> -# include <stdint.h> # include <string.h> # include <arpa/inet.h> # include <sys/xattr.h> @@ -363,6 +362,29 @@ acl_nfs4_nontrivial (uint32_t *xattr, ssize_t nbytes) } #endif +#if (!USE_LINUX_XATTR && USE_ACL && HAVE_ACL_GET_FD \ + && !HAVE_ACL_EXTENDED_FILE && !HAVE_ACL_TYPE_EXTENDED \ + && !HAVE_ACL_GET_LINK_NP) +# include <fcntl.h> +# ifdef O_PATH + +/* Like acl_get_file, but do not follow symbolic links. */ +static acl_t +acl_get_link_np (char const *name, acl_type_t type) +{ + int fd = open (name, O_PATH | O_NOFOLLOW); + if (fd < 0) + return NULL; + acl_t r = acl_get_fd (fd); + int err = errno; + close (fd); + errno = err; + return r; +} +# define HAVE_ACL_GET_LINK_NP 1 +# endif +#endif + /* Return 1 if NAME has a nontrivial access control list, 0 if ACLs are not supported, or if NAME has no or only a base ACL, and -1 (setting errno) on error. Note callers can determine @@ -468,7 +490,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, ret = -1; # else /* FreeBSD, NetBSD >= 10, IRIX, Tru64, Cygwin >= 2.5 */ acl_t (*acl_get_file_or_link) (char const *, acl_type_t) = acl_get_file; -# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10 */ +# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */ if (! (flags & ACL_SYMLINK_FOLLOW)) acl_get_file_or_link = acl_get_link_np; # endif diff --git a/lib/fpending.c b/lib/fpending.c index 7614b607832..be8a9877349 100644 --- a/lib/fpending.c +++ b/lib/fpending.c @@ -26,7 +26,7 @@ /* This file is not used on systems that already have the __fpending function, namely glibc >= 2.2, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.34, - Android API >= 23. */ + Android API >= 23, musl libc, Haiku >= hrev58760. */ /* Return the number of pending (aka buffered, unflushed) bytes on the stream, FP, that is open for writing. */ diff --git a/lib/getloadavg.c b/lib/getloadavg.c index a7966462c73..9da41c16c02 100644 --- a/lib/getloadavg.c +++ b/lib/getloadavg.c @@ -47,8 +47,6 @@ N_NAME_POINTER The nlist n_name element is a pointer, not an array. HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'. - LINUX_LDAV_FILE [__linux__, __ANDROID__, __CYGWIN__]: File - containing load averages. Specific system predefines this file uses, aside from setting default values if not emacs: @@ -65,8 +63,7 @@ UMAX4_3 VMS _WIN32 Native Windows (possibly also defined on Cygwin) - __linux__, __ANDROID__ Linux: assumes /proc file system mounted. - Support from Michael K. Johnson. + __linux__, __ANDROID__ Linux: assumes sysinfo() call. __CYGWIN__ Cygwin emulates linux /proc/loadavg. __NetBSD__ NetBSD: assumes /kern file system mounted. @@ -108,10 +105,10 @@ # endif /* Same issues as for NeXT apply to the HURD-based GNU system. */ -# ifdef __GNU__ +# if defined __gnu_hurd__ || defined NeXT # undef BSD # undef FSCALE -# endif /* __GNU__ */ +# endif /* __gnu_hurd__ || NeXT */ /* Set values that are different from the defaults, which are set a little farther down with #ifndef. */ @@ -312,8 +309,7 @@ # endif # endif -# if defined (__GNU__) && !defined (NeXT) -/* Note that NeXT Openstep defines __GNU__ even though it should not. */ +# if defined __gnu_hurd__ && !defined NeXT /* GNU system acts much like NeXT, for load average purposes, but not exactly. */ # define NeXT @@ -358,6 +354,11 @@ # include <sys/dg_sys_info.h> # endif +# if defined __linux__ || defined __ANDROID__ +# include <sys/param.h> +# include <sys/sysinfo.h> +# endif + # if (defined __linux__ || defined __ANDROID__ \ || defined __CYGWIN__ || defined SUNOS_5 \ || (defined LOAD_AVE_TYPE && ! defined __VMS)) @@ -498,20 +499,32 @@ getloadavg (double loadavg[], int nelem) } # endif -# if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__ || defined __CYGWIN__) +# if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__) /* Linux without glibc, Android, Cygwin */ # define LDAV_DONE # undef LOAD_AVE_TYPE -# ifndef LINUX_LDAV_FILE -# define LINUX_LDAV_FILE "/proc/loadavg" -# endif + { + struct sysinfo info; + if (sysinfo (&info) < 0) + return -1; + loadavg[0] = info.loads[0] / (double)(1U << SI_LOAD_SHIFT); + loadavg[1] = info.loads[1] / (double)(1U << SI_LOAD_SHIFT); + loadavg[2] = info.loads[2] / (double)(1U << SI_LOAD_SHIFT); + elem = 3; + } +# endif /* __linux__ || __ANDROID__ */ + +# if !defined (LDAV_DONE) && defined __CYGWIN__ + /* Cygwin */ +# define LDAV_DONE +# undef LOAD_AVE_TYPE char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")]; char const *ptr = ldavgbuf; int fd, count, saved_errno; - fd = open (LINUX_LDAV_FILE, O_RDONLY | O_CLOEXEC); + fd = open ("/proc/loadavg", O_RDONLY | O_CLOEXEC); if (fd == -1) return -1; count = read (fd, ldavgbuf, sizeof ldavgbuf - 1); @@ -554,7 +567,7 @@ getloadavg (double loadavg[], int nelem) return elem; -# endif /* __linux__ || __ANDROID__ || __CYGWIN__ */ +# endif /* __CYGWIN__ */ # if !defined (LDAV_DONE) && defined (__NetBSD__) /* NetBSD < 0.9 */ # define LDAV_DONE diff --git a/lib/getopt-pfx-ext.h b/lib/getopt-pfx-ext.h index 1f2b2d71bf7..a61c68c795e 100644 --- a/lib/getopt-pfx-ext.h +++ b/lib/getopt-pfx-ext.h @@ -38,11 +38,9 @@ # endif # undef getopt_long # undef getopt_long_only -# undef option # undef _getopt_internal # define getopt_long __GETOPT_ID (getopt_long) # define getopt_long_only __GETOPT_ID (getopt_long_only) -# define option __GETOPT_ID (option) # define _getopt_internal __GETOPT_ID (getopt_internal) /* The system's getopt.h may have already included getopt-ext.h to diff --git a/lib/getopt.in.h b/lib/getopt.in.h index 79200ecdab9..4a87a2d53bf 100644 --- a/lib/getopt.in.h +++ b/lib/getopt.in.h @@ -30,7 +30,12 @@ <getopt.h>; our definitions will be present soon enough. */ #if @HAVE_GETOPT_H@ # define _GL_SYSTEM_GETOPT +/* Rename the system's 'struct option' to 'struct sys_option', + so that we don't have to rename ours to 'struct rpl_option' + (which would cause significant trouble in C++ mode). */ +# define option sys_option # @INCLUDE_NEXT@ @NEXT_GETOPT_H@ +# undef option # undef _GL_SYSTEM_GETOPT #endif diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index fa2250cf686..fb34cf2cc1d 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -49,6 +49,7 @@ # --avoid=iswxdigit \ # --avoid=langinfo-h \ # --avoid=libgmp-mpq \ +# --avoid=locale-h \ # --avoid=localename-unsafe-limited \ # --avoid=lock \ # --avoid=mbrtowc \ @@ -624,6 +625,7 @@ GL_GNULIB_STRCHRNUL = @GL_GNULIB_STRCHRNUL@ GL_GNULIB_STRDUP = @GL_GNULIB_STRDUP@ GL_GNULIB_STRERROR = @GL_GNULIB_STRERROR@ GL_GNULIB_STRERRORNAME_NP = @GL_GNULIB_STRERRORNAME_NP@ +GL_GNULIB_STRERROR_L = @GL_GNULIB_STRERROR_L@ GL_GNULIB_STRERROR_R = @GL_GNULIB_STRERROR_R@ GL_GNULIB_STRFTIME = @GL_GNULIB_STRFTIME@ GL_GNULIB_STRNCAT = @GL_GNULIB_STRNCAT@ @@ -916,6 +918,7 @@ HAVE_STR2SIG = @HAVE_STR2SIG@ HAVE_STRCASESTR = @HAVE_STRCASESTR@ HAVE_STRCHRNUL = @HAVE_STRCHRNUL@ HAVE_STRERRORNAME_NP = @HAVE_STRERRORNAME_NP@ +HAVE_STRERROR_L = @HAVE_STRERROR_L@ HAVE_STRPBRK = @HAVE_STRPBRK@ HAVE_STRPTIME = @HAVE_STRPTIME@ HAVE_STRSEP = @HAVE_STRSEP@ @@ -1213,6 +1216,7 @@ REPLACE_GETENTROPY = @REPLACE_GETENTROPY@ REPLACE_GETGROUPS = @REPLACE_GETGROUPS@ REPLACE_GETLINE = @REPLACE_GETLINE@ REPLACE_GETLOADAVG = @REPLACE_GETLOADAVG@ +REPLACE_GETLOGIN = @REPLACE_GETLOGIN@ REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@ REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@ REPLACE_GETPASS = @REPLACE_GETPASS@ @@ -1307,6 +1311,7 @@ REPLACE_STRCHRNUL = @REPLACE_STRCHRNUL@ REPLACE_STRDUP = @REPLACE_STRDUP@ REPLACE_STRERROR = @REPLACE_STRERROR@ REPLACE_STRERRORNAME_NP = @REPLACE_STRERRORNAME_NP@ +REPLACE_STRERROR_L = @REPLACE_STRERROR_L@ REPLACE_STRERROR_R = @REPLACE_STRERROR_R@ REPLACE_STRFTIME = @REPLACE_STRFTIME@ REPLACE_STRNCAT = @REPLACE_STRNCAT@ @@ -1543,6 +1548,7 @@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ standardlisppath = @standardlisppath@ sysconfdir = @sysconfdir@ +systemduserunitdir = @systemduserunitdir@ target_alias = @target_alias@ version = @version@ with_mailutils = @with_mailutils@ @@ -1715,13 +1721,25 @@ libgnu_a_SOURCES += c-ctype.h c-ctype.c endif ## end gnulib module c-ctype -## begin gnulib module c-strcase -ifeq (,$(OMIT_GNULIB_MODULE_c-strcase)) +## begin gnulib module c-strcasecmp +ifeq (,$(OMIT_GNULIB_MODULE_c-strcasecmp)) -libgnu_a_SOURCES += c-strcase.h c-strcasecmp.c c-strncasecmp.c +libgnu_a_SOURCES += c-strcasecmp.c + +EXTRA_DIST += c-strcase.h + +endif +## end gnulib module c-strcasecmp + +## begin gnulib module c-strncasecmp +ifeq (,$(OMIT_GNULIB_MODULE_c-strncasecmp)) + +libgnu_a_SOURCES += c-strncasecmp.c + +EXTRA_DIST += c-strcase.h endif -## end gnulib module c-strcase +## end gnulib module c-strncasecmp ## begin gnulib module canonicalize-lgpl ifeq (,$(OMIT_GNULIB_MODULE_canonicalize-lgpl)) @@ -3681,6 +3699,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's/@''GNULIB_STR_STARTSWITH''@/$(GL_GNULIB_STR_STARTSWITH)/g' \ -e 's/@''GNULIB_STRERROR''@/$(GL_GNULIB_STRERROR)/g' \ -e 's/@''GNULIB_STRERROR_R''@/$(GL_GNULIB_STRERROR_R)/g' \ + -e 's/@''GNULIB_STRERROR_L''@/$(GL_GNULIB_STRERROR_L)/g' \ -e 's/@''GNULIB_STRERRORNAME_NP''@/$(GL_GNULIB_STRERRORNAME_NP)/g' \ -e 's/@''GNULIB_SIGABBREV_NP''@/$(GL_GNULIB_SIGABBREV_NP)/g' \ -e 's/@''GNULIB_SIGDESCR_NP''@/$(GL_GNULIB_SIGDESCR_NP)/g' \ @@ -3711,6 +3730,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \ + -e 's|@''HAVE_STRERROR_L''@|$(HAVE_STRERROR_L)|g' \ -e 's|@''HAVE_STRERRORNAME_NP''@|$(HAVE_STRERRORNAME_NP)|g' \ -e 's|@''HAVE_SIGABBREV_NP''@|$(HAVE_SIGABBREV_NP)|g' \ -e 's|@''HAVE_SIGDESCR_NP''@|$(HAVE_SIGDESCR_NP)|g' \ @@ -3734,6 +3754,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \ + -e 's|@''REPLACE_STRERROR_L''@|$(REPLACE_STRERROR_L)|g' \ -e 's|@''REPLACE_STRERRORNAME_NP''@|$(REPLACE_STRERRORNAME_NP)|g' \ -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ -e 's|@''REPLACE_STRVERSCMP''@|$(REPLACE_STRVERSCMP)|g' \ @@ -4328,6 +4349,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \ -e 's|@''REPLACE_GETENTROPY''@|$(REPLACE_GETENTROPY)|g' \ + -e 's|@''REPLACE_GETLOGIN''@|$(REPLACE_GETLOGIN)|g' \ -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ diff --git a/lib/intprops.h b/lib/intprops.h index 83efe39910a..2f9fa0a0222 100644 --- a/lib/intprops.h +++ b/lib/intprops.h @@ -39,7 +39,7 @@ then 'switch (INT_PROMOTE (E))' pacifies gcc -Wswitch-enum if some enum values are deliberately omitted from the switch's cases. Here, unary + is safer than a cast or inline function, as unary + - does only integer promotions. */ + does only integer promotions and is disallowed on pointers. */ #define INT_PROMOTE(e) (+ (e)) diff --git a/lib/nproc.c b/lib/nproc.c index d48e4dd94f5..83439aa0eb2 100644 --- a/lib/nproc.c +++ b/lib/nproc.c @@ -398,20 +398,16 @@ parse_omp_threads (char const* threads) /* Convert it from positive decimal to 'unsigned long'. */ if (c_isdigit (*threads)) { - char *endptr = NULL; + char *endptr; unsigned long int value = strtoul (threads, &endptr, 10); - - if (endptr != NULL) - { - while (*endptr != '\0' && c_isspace (*endptr)) - endptr++; - if (*endptr == '\0') - return value; - /* Also accept the first value in a nesting level, - since we can't determine the nesting level from env vars. */ - else if (*endptr == ',') - return value; - } + while (*endptr != '\0' && c_isspace (*endptr)) + endptr++; + if (*endptr == '\0') + return value; + /* Also accept the first value in a nesting level, + since we can't determine the nesting level from env vars. */ + else if (*endptr == ',') + return value; } return ret; @@ -438,6 +434,9 @@ num_processors (enum nproc_query query) query = NPROC_CURRENT; } /* Here query is one of NPROC_ALL, NPROC_CURRENT. */ + if (omp_env_limit == 1) + /* No need to even call num_processors_ignoring_omp (query). */ + return 1; { unsigned long nprocs = num_processors_ignoring_omp (query); return MIN (nprocs, omp_env_limit); diff --git a/lib/readutmp.h b/lib/readutmp.h index b5e8133c7c6..60d63df9598 100644 --- a/lib/readutmp.h +++ b/lib/readutmp.h @@ -45,7 +45,7 @@ # include <utmp.h> #endif -/* Needed for BOOT_TIME and USER_PROCESS. */ +/* Needed for BOOT_TIME, USER_PROCESS, LOGIN_PROCESS. */ #if HAVE_UTMPX_H # if defined _THREAD_SAFE && defined UTMP_DATA_INIT /* When including both utmp.h and utmpx.h on AIX 4.3, with _THREAD_SAFE @@ -74,7 +74,8 @@ struct gl_utmp struct timespec ut_ts; /* time */ pid_t ut_pid; /* process ID of ? */ pid_t ut_session; /* process ID of session leader */ - short ut_type; /* BOOT_TIME, USER_PROCESS, or other */ + short ut_type; /* BOOT_TIME, USER_PROCESS, LOGIN_PROCESS, + or other */ struct { int e_termination; int e_exit; } ut_exit; }; @@ -257,19 +258,21 @@ struct utmpx32 # define WTMP_FILE "/etc/wtmp" #endif -/* In early versions of Android, <utmp.h> did not define BOOT_TIME, only - USER_PROCESS. We need to use the value that is defined in newer versions - of Android. */ +/* In early versions of Android, <utmp.h> did not define BOOT_TIME or + LOGIN_PROCESS, only USER_PROCESS. We need to use the value that is defined + in newer versions of Android. */ #if defined __ANDROID__ && !defined BOOT_TIME # define BOOT_TIME 2 +# define LOGIN_PROCESS 6 #endif /* Some platforms, such as OpenBSD, don't have an ut_type field and don't have - the BOOT_TIME and USER_PROCESS macros. But we want to support them in - 'struct gl_utmp'. */ + the BOOT_TIME, USER_PROCESS, and LOGIN_PROCESS macros. But we want to + support them in 'struct gl_utmp'. */ #if !(HAVE_UTMPX_H ? HAVE_STRUCT_UTMPX_UT_TYPE : HAVE_STRUCT_UTMP_UT_TYPE) # define BOOT_TIME 2 # define USER_PROCESS 0 +# define LOGIN_PROCESS 6 #endif /* Macros that test (UT)->ut_type. */ @@ -283,6 +286,11 @@ struct utmpx32 #else # define UT_TYPE_USER_PROCESS(UT) 0 #endif +#ifdef LOGIN_PROCESS +# define UT_TYPE_LOGIN_PROCESS(UT) ((UT)->ut_type == LOGIN_PROCESS) +#else +# define UT_TYPE_LOGIN_PROCESS(UT) 0 +#endif /* Determines whether an entry *UT corresponds to a user process. */ #define IS_USER_PROCESS(UT) \ diff --git a/lib/regcomp.c b/lib/regcomp.c index 41b0f989c03..a23f289d7a1 100644 --- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -831,7 +831,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len) if (table_size > pat_len) break; - dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size); + dfa->state_table = calloc (table_size, sizeof (struct re_state_table_entry)); dfa->state_hash_mask = table_size - 1; dfa->mb_cur_max = MB_CUR_MAX; @@ -862,7 +862,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len) { int i, j, ch; - dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); + dfa->sb_char = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t)); if (__glibc_unlikely (dfa->sb_char == NULL)) return REG_ESPACE; @@ -3055,8 +3055,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, _NL_COLLATE_SYMB_EXTRAMB); } #endif - sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); - mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); + sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t)); + mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t)); if (__glibc_unlikely (sbcset == NULL || mbcset == NULL)) { re_free (sbcset); @@ -3548,13 +3548,13 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, reg_errcode_t ret; bin_tree_t *tree; - sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); + sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t)); if (__glibc_unlikely (sbcset == NULL)) { *err = REG_ESPACE; return NULL; } - mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); + mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t)); if (__glibc_unlikely (mbcset == NULL)) { re_free (sbcset); diff --git a/lib/regex.h b/lib/regex.h index 67a3aa70a51..e9ab85e8b5a 100644 --- a/lib/regex.h +++ b/lib/regex.h @@ -66,15 +66,14 @@ typedef unsigned long int active_reg_t; /* The following bits are used to determine the regexp syntax we recognize. The set/not-set meanings are chosen so that Emacs syntax - remains the value 0. The bits are given in alphabetical order, and - the definitions shifted by one from the previous bit; thus, when we - add or remove a bit, only one other definition need change. */ + is the value 0 for Emacs 20 (2000) and earlier, and the value + RE_SYNTAX_EMACS for Emacs 21 (2001) and later. */ typedef unsigned long int reg_syntax_t; #ifdef __USE_GNU /* If this bit is not set, then \ inside a bracket expression is literal. If set, then such a \ quotes the following character. */ -# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) +# define RE_BACKSLASH_ESCAPE_IN_LISTS 1ul /* If this bit is not set, then + and ? are operators, and \+ and \? are literals. @@ -215,7 +214,8 @@ extern reg_syntax_t re_syntax_options; (The [[[ comments delimit what gets put into the Texinfo file, so don't delete them!) */ /* [[[begin syntaxes]]] */ -# define RE_SYNTAX_EMACS 0 +# define RE_SYNTAX_EMACS \ + (RE_CHAR_CLASSES | RE_INTERVALS) # define RE_SYNTAX_AWK \ (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ @@ -522,20 +522,6 @@ typedef struct /* Declarations for routines. */ -#ifndef _REGEX_NELTS -# if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \ - && !defined __STDC_NO_VLA__) -# define _REGEX_NELTS(n) n -# else -# define _REGEX_NELTS(n) -# endif -#endif - -#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wvla" -#endif - #ifndef _Attr_access_ # ifdef __attr_access # define _Attr_access_(arg) __attr_access (arg) @@ -682,8 +668,7 @@ extern int regcomp (regex_t *_Restrict_ __preg, extern int regexec (const regex_t *_Restrict_ __preg, const char *_Restrict_ __String, size_t __nmatch, - regmatch_t __pmatch[_Restrict_arr_ - _REGEX_NELTS (__nmatch)], + regmatch_t __pmatch[_Restrict_arr_], int __eflags); extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, @@ -692,10 +677,6 @@ extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, extern void regfree (regex_t *__preg); -#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) -# pragma GCC diagnostic pop -#endif - #ifdef __cplusplus } #endif /* C++ */ diff --git a/lib/regex_internal.c b/lib/regex_internal.c index 8bf761c7616..9b89cc9372b 100644 --- a/lib/regex_internal.c +++ b/lib/regex_internal.c @@ -1595,7 +1595,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, reg_errcode_t err; re_dfastate_t *newstate; - newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); + newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t)); if (__glibc_unlikely (newstate == NULL)) return NULL; err = re_node_set_init_copy (&newstate->nodes, nodes); @@ -1643,7 +1643,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, reg_errcode_t err; re_dfastate_t *newstate; - newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); + newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t)); if (__glibc_unlikely (newstate == NULL)) return NULL; err = re_node_set_init_copy (&newstate->nodes, nodes); diff --git a/lib/regexec.c b/lib/regexec.c index 58215bd3766..c5ab9b6649f 100644 --- a/lib/regexec.c +++ b/lib/regexec.c @@ -185,7 +185,7 @@ static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len); int regexec (const regex_t *__restrict preg, const char *__restrict string, - size_t nmatch, regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags) + size_t nmatch, regmatch_t pmatch[], int eflags) { reg_errcode_t err; Idx start, length; @@ -229,7 +229,7 @@ int attribute_compat_text_section __compat_regexec (const regex_t *__restrict preg, const char *__restrict string, size_t nmatch, - regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags) + regmatch_t pmatch[], int eflags) { return regexec (preg, string, nmatch, pmatch, eflags & (REG_NOTBOL | REG_NOTEOL)); @@ -2721,8 +2721,8 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx) continue; /* No. */ if (sub_top->path == NULL) { - sub_top->path = calloc (sizeof (state_array_t), - sl_str - sub_top->str_idx + 1); + sub_top->path = calloc (sl_str - sub_top->str_idx + 1, + sizeof (state_array_t)); if (sub_top->path == NULL) return REG_ESPACE; } @@ -3266,7 +3266,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) if (ndests == 0) { state->trtable = (re_dfastate_t **) - calloc (sizeof (re_dfastate_t *), SBC_MAX); + calloc (SBC_MAX, sizeof (re_dfastate_t *)); if (__glibc_unlikely (state->trtable == NULL)) return false; return true; @@ -3338,7 +3338,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) discern by looking at the character code: allocate a 256-entry transition table. */ trtable = state->trtable = - (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); + (re_dfastate_t **) calloc (SBC_MAX, sizeof (re_dfastate_t *)); if (__glibc_unlikely (trtable == NULL)) goto out_free; @@ -3369,7 +3369,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) transition tables, one starting at trtable[0] and one starting at trtable[SBC_MAX]. */ trtable = state->word_trtable = - (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX); + (re_dfastate_t **) calloc (2 * SBC_MAX, sizeof (re_dfastate_t *)); if (__glibc_unlikely (trtable == NULL)) goto out_free; diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h index 878e9f8c97d..4b4263fe908 100644 --- a/lib/stdio-impl.h +++ b/lib/stdio-impl.h @@ -30,6 +30,49 @@ # endif #endif +/* Haiku stdio implementation. */ +#if defined __HAIKU__ +# include <stdint.h> +/* This FILE structure was made into an incomplete type in 2025. + See <https://cgit.haiku-os.org/haiku/tree/src/system/libroot/posix/glibc/libio/libio.h>. */ +# define fp_ ((struct { int _flags; \ + char *_IO_read_ptr; \ + char *_IO_read_end; \ + char *_IO_read_base; \ + char *_IO_write_base; \ + char *_IO_write_ptr; \ + char *_IO_write_end; \ + char *_IO_buf_base; \ + char *_IO_buf_end; \ + char *_IO_save_base; \ + char *_IO_backup_base; \ + char *_IO_save_end; \ + void *_markers; \ + void *_chain; \ + int _fileno; \ + int _flags2; \ + off_t _old_offset; \ + unsigned short _cur_column; \ + signed char _vtable_offset; \ + char _shortbuf[1]; \ + void *_lock; \ + int64_t _offset; \ + /* More fields, not relevant here. */ \ + } *) fp) +# if !defined _IO_UNBUFFERED +# define _IO_UNBUFFERED 0x2 +# endif +# if !defined _IO_EOF_SEEN +# define _IO_EOF_SEEN 0x10 +# endif +# if !defined _IO_IN_BACKUP +# define _IO_IN_BACKUP 0x100 +# endif +# if !defined _IO_LINE_BUF +# define _IO_LINE_BUF 0x200 +# endif +#endif + /* BSD stdio derived implementations. */ #if defined __NetBSD__ /* NetBSD */ diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index bd82086ff37..dbe8ebc8502 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -63,7 +63,7 @@ #include <stddef.h> /* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. - glibc 2.40 defines WCOREDUMP in <sys/wait.h>, not in <stdlib.h>. */ + glibc 2.41 defines WCOREDUMP in <sys/wait.h>, not in <stdlib.h>. */ #if @GNULIB_SYSTEM_POSIX@ && !(defined WEXITSTATUS && defined WCOREDUMP) # include <sys/wait.h> #endif @@ -120,14 +120,14 @@ struct random_data # include <unistd.h> #endif -#if ((@GNULIB_STRTOL@ && @REPLACE_STRTOL@) || (@GNULIB_STRTOLL@ && @REPLACE_STRTOLL@) || (@GNULIB_STRTOUL@ && @REPLACE_STRTOUL@) || (@GNULIB_STRTOULL@ && @REPLACE_STRTOULL@)) && defined __cplusplus && !defined GNULIB_NAMESPACE && defined __GNUG__ && !defined __clang__ && defined __sun +#if ((@GNULIB_STRTOL@ && @REPLACE_STRTOL@) || (@GNULIB_STRTOLL@ && @REPLACE_STRTOLL@) || (@GNULIB_STRTOUL@ && @REPLACE_STRTOUL@) || (@GNULIB_STRTOULL@ && @REPLACE_STRTOULL@)) && defined __cplusplus && !defined GNULIB_NAMESPACE && defined __GNUG__ && !defined __clang__ && (defined __sun || defined _AIX) /* When strtol, strtoll, strtoul, or strtoull is going to be defined as a macro below, this may cause compilation errors later in the libstdc++ header files (that are part of GCC), such as: error: 'rpl_strtol' is not a member of 'std' To avoid this, include the relevant header files here, before these symbols - get defined as macros. But do so only on Solaris 11 (where it is needed), - not on mingw (where it would cause other compilation errors). */ + get defined as macros. But do so only on Solaris 11 and AIX (where it is + needed), not on mingw (where it would cause other compilation errors). */ # include <string> #endif @@ -1473,11 +1473,17 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " # if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ # if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2 # define _GL_INLINE_RPL_REALLOC 1 +# ifdef __cplusplus +extern "C" { +# endif _GL_REALLOC_INLINE void * rpl_realloc (void *ptr, size_t size) { return realloc (ptr, size ? size : 1); } +# ifdef __cplusplus +} +# endif # endif # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ || _GL_USE_STDLIB_ALLOC) diff --git a/lib/string.in.h b/lib/string.in.h index ce488299006..44b9497d802 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -54,6 +54,11 @@ /* NetBSD 5.0 mis-defines NULL. */ #include <stddef.h> +#if @GNULIB_STRERROR_L@ +/* Get locale_t. */ +# include <locale.h> +#endif + /* MirBSD defines mbslen as a macro. */ #if @GNULIB_MBSLEN@ && defined __MirBSD__ # include <wchar.h> @@ -429,7 +434,9 @@ _GL_FUNCDECL_SYS (memset_explicit, void *, # endif _GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (memset_explicit); +# endif #elif defined GNULIB_POSIXCHECK # undef memset_explicit # if HAVE_RAW_DECL_MEMSET_EXPLICIT @@ -1178,6 +1185,33 @@ _GL_CXXALIASWARN (mbsrchr); _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2)); +# ifndef _GL_NO_CONST_GENERICS +/* Don't silently convert a 'const char *' to a 'char *'. Programmers want + compiler warnings for 'const' related mistakes. */ +# ifdef __cplusplus +extern "C++" { /* needed for AIX */ +template <typename T> + T * mbsstr_template (T* haystack, const char *needle); +template <> + inline char * mbsstr_template (char *haystack, const char *needle) + { return mbsstr (haystack, needle); } +template <> + inline const char * mbsstr_template (const char *haystack, const char *needle) + { return mbsstr (haystack, needle); } +} +# undef mbsstr +# define mbsstr mbsstr_template +# elif !defined mbsstr +# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \ + || defined __ICC || defined __TINYC__ \ + || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__))) +# define mbsstr(h,n) \ + _Generic ((h), \ + char const *: (char const *) mbsstr ((h), (n)), \ + default : mbsstr ((h), (n))) +# endif +# endif +# endif #endif #if @GNULIB_MBSCASECMP@ @@ -1219,6 +1253,33 @@ _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2)); +# ifndef _GL_NO_CONST_GENERICS +/* Don't silently convert a 'const char *' to a 'char *'. Programmers want + compiler warnings for 'const' related mistakes. */ +# ifdef __cplusplus +extern "C++" { /* needed for AIX */ +template <typename T> + T * mbspcasecmp_template (T* string, const char *prefix); +template <> + inline char * mbspcasecmp_template (char *string, const char *prefix) + { return mbspcasecmp (string, prefix); } +template <> + inline const char * mbspcasecmp_template (const char *string, const char *prefix) + { return mbspcasecmp (string, prefix); } +} +# undef mbspcasecmp +# define mbspcasecmp mbspcasecmp_template +# elif !defined mbspcasecmp +# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \ + || defined __ICC || defined __TINYC__ \ + || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__))) +# define mbspcasecmp(s,p) \ + _Generic ((s), \ + char const *: (char const *) mbspcasecmp ((s), (p)), \ + default : mbspcasecmp ((s), (p))) +# endif +# endif +# endif #endif #if @GNULIB_MBSCASESTR@ @@ -1230,6 +1291,33 @@ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2)); +# ifndef _GL_NO_CONST_GENERICS +/* Don't silently convert a 'const char *' to a 'char *'. Programmers want + compiler warnings for 'const' related mistakes. */ +# ifdef __cplusplus +extern "C++" { /* needed for AIX */ +template <typename T> + T * mbscasestr_template (T* haystack, const char *needle); +template <> + inline char * mbscasestr_template (char *haystack, const char *needle) + { return mbscasestr (haystack, needle); } +template <> + inline const char * mbscasestr_template (const char *haystack, const char *needle) + { return mbscasestr (haystack, needle); } +} +# undef mbscasestr +# define mbscasestr mbscasestr_template +# elif !defined mbscasestr +# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \ + || defined __ICC || defined __TINYC__ \ + || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__))) +# define mbscasestr(h,n) \ + _Generic ((h), \ + char const *: (char const *) mbscasestr ((h), (n)), \ + default : mbscasestr ((h), (n))) +# endif +# endif +# endif #endif #if @GNULIB_MBSCSPN@ @@ -1388,6 +1476,44 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " # endif #endif +/* Map any int, typically from errno, into an error message. + With locale_t argument. */ +#if @GNULIB_STRERROR_L@ +# if @REPLACE_STRERROR_L@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strerror_l +# define strerror_l rpl_strerror_l +# endif +_GL_FUNCDECL_RPL (strerror_l, char *, (int errnum, locale_t locale), + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (strerror_l, char *, (int errnum, locale_t locale)); +# else +# if !@HAVE_STRERROR_L@ +_GL_FUNCDECL_SYS (strerror_l, char *, (int errnum, locale_t locale), + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (strerror_l, char *, (int errnum, locale_t locale)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (strerror_l); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strerror_l +# if HAVE_RAW_DECL_STRERROR_L +_GL_WARN_ON_USE (strerror_l, "strerror_l is unportable - " + "use gnulib module strerror_l for portability"); +# endif +#endif + +/* Map any int, typically from errno, into an error message. Multithread-safe, + with locale_t argument. + Not portable! Only provided by gnulib. */ +#if @GNULIB_STRERROR_L@ +_GL_FUNCDECL_SYS (strerror_l_r, int, + (int errnum, char *buf, size_t buflen, locale_t locale), + _GL_ARG_NONNULL ((2, 4))); +#endif + /* Return the name of the system error code ERRNUM. */ #if @GNULIB_STRERRORNAME_NP@ # if @REPLACE_STRERRORNAME_NP@ @@ -1403,7 +1529,9 @@ _GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum), ); # endif _GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (strerrorname_np); +# endif #elif defined GNULIB_POSIXCHECK # undef strerrorname_np # if HAVE_RAW_DECL_STRERRORNAME_NP diff --git a/lib/time.in.h b/lib/time.in.h index 60801c972c9..3ff16e3b3e4 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -186,7 +186,9 @@ _GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base), # endif _GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (timespec_getres); +# endif # elif defined GNULIB_POSIXCHECK # undef timespec_getres # if HAVE_RAW_DECL_TIMESPEC_GETRES diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 3f96e10d7e7..c135a770dc1 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -95,12 +95,15 @@ # include <stdio.h> #endif +/* FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Solaris 11.4, and glibc 2.41 + do not define O_CLOEXEC 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__ || defined __ANDROID__) \ - && ! defined __GLIBC__ +#if ! defined O_CLOEXEC \ + || ((@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \ + && (defined __CYGWIN__ || defined __ANDROID__) \ + && ! defined __GLIBC__) # include <fcntl.h> #endif @@ -463,7 +466,9 @@ _GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos, int ofd, off_t *opos, size_t len, unsigned flags)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (copy_file_range); +# endif #elif defined GNULIB_POSIXCHECK # undef copy_file_range # if HAVE_RAW_DECL_COPY_FILE_RANGE @@ -1362,11 +1367,21 @@ _GL_WARN_ON_USE (gethostname, "gethostname is unportable - " ${LOGNAME-$USER} on Unix platforms, $USERNAME on native Windows platforms. */ -# if !@HAVE_DECL_GETLOGIN@ +# if @REPLACE_GETLOGIN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define getlogin rpl_getlogin +# endif +_GL_FUNCDECL_RPL (getlogin, char *, (void), ); +_GL_CXXALIAS_RPL (getlogin, char *, (void)); +# else +# if !@HAVE_DECL_GETLOGIN@ _GL_FUNCDECL_SYS (getlogin, char *, (void), ); -# endif +# endif _GL_CXXALIAS_SYS (getlogin, char *, (void)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (getlogin); +# endif #elif defined GNULIB_POSIXCHECK # undef getlogin # if HAVE_RAW_DECL_GETLOGIN @@ -2405,7 +2420,7 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " #if @GNULIB_USLEEP@ /* Pause the execution of the current thread for N microseconds. Returns 0 on completion, or -1 on range error. - See the POSIX:2001 specification + See the POSIX.1-2004 specification <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */ # if @REPLACE_USLEEP@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) diff --git a/lib/utimens.h b/lib/utimens.h index 007958dd933..62ea7d8f5fd 100644 --- a/lib/utimens.h +++ b/lib/utimens.h @@ -25,7 +25,7 @@ #include <time.h> #if HAVE_UTIMENS || HAVE_LUTIMENS -# include <sys/time.h> +# include <sys/stat.h> #endif #ifdef __cplusplus diff --git a/lib/utimensat.c b/lib/utimensat.c index 227474fdaa5..ca1d39e5900 100644 --- a/lib/utimensat.c +++ b/lib/utimensat.c @@ -136,8 +136,9 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2], } # endif # endif -# if defined __APPLE__ && defined __MACH__ - /* macOS 10.13 does not reject invalid tv_nsec values either. */ +# if (defined __APPLE__ && defined __MACH__) || defined __gnu_hurd__ + /* macOS 10.13 and GNU Hurd do not reject invalid tv_nsec values + either. */ if (times && ((times[0].tv_nsec != UTIME_OMIT && times[0].tv_nsec != UTIME_NOW @@ -151,6 +152,7 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2], errno = EINVAL; return -1; } +# if defined __APPLE__ && defined __MACH__ size_t len = strlen (file); if (len > 0 && file[len - 1] == '/') { @@ -163,6 +165,7 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2], return -1; } } +# endif # endif result = utimensat (fd, file, times, flag); /* Linux kernel 2.6.25 has a bug where it returns EINVAL for diff --git a/lib/verify.h b/lib/verify.h index 96fde0b9c81..3b01d7c2fb3 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -157,9 +157,10 @@ #define _GL_CONCAT0(x, y) x##y /* _GL_COUNTER is an integer, preferably one that changes each time we - use it. Use __COUNTER__ if it works, falling back on __LINE__ - otherwise. __LINE__ isn't perfect, but it's better than a - constant. */ + use it. Use __COUNTER__ if it works (it does so with most compilers, + see <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3457.htm>), + falling back on __LINE__ otherwise. __LINE__ isn't perfect, but it's + better than a constant. */ #if defined __COUNTER__ && __COUNTER__ != __COUNTER__ # define _GL_COUNTER __COUNTER__ #else |
