aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2025-04-19 12:18:28 -0700
committerPaul Eggert2025-04-19 19:31:25 -0700
commit71ee484cac3e0e5b68f006b4cca81c13ca6ce11e (patch)
tree21476621d11357283ad30c8b2bcec2871e604ba1 /lib
parent30335bb73483fce9d4204f1e18618fe777d0f45e (diff)
downloademacs-71ee484cac3e0e5b68f006b4cca81c13ca6ce11e.tar.gz
emacs-71ee484cac3e0e5b68f006b4cca81c13ca6ce11e.zip
Update from Gnulib by running admin/merge-gnulib
Diffstat (limited to 'lib')
-rw-r--r--lib/acl-internal.c8
-rw-r--r--lib/acl-internal.h14
-rw-r--r--lib/acl_entries.c6
-rw-r--r--lib/fcntl.in.h12
-rw-r--r--lib/file-has-acl.c26
-rw-r--r--lib/fpending.c2
-rw-r--r--lib/getloadavg.c41
-rw-r--r--lib/getopt-pfx-ext.h2
-rw-r--r--lib/getopt.in.h5
-rw-r--r--lib/gnulib.mk.in30
-rw-r--r--lib/intprops.h2
-rw-r--r--lib/nproc.c25
-rw-r--r--lib/readutmp.h22
-rw-r--r--lib/regcomp.c12
-rw-r--r--lib/regex.h31
-rw-r--r--lib/regex_internal.c4
-rw-r--r--lib/regexec.c14
-rw-r--r--lib/stdio-impl.h43
-rw-r--r--lib/stdlib.in.h14
-rw-r--r--lib/string.in.h128
-rw-r--r--lib/time.in.h2
-rw-r--r--lib/unistd.in.h27
-rw-r--r--lib/utimens.h2
-rw-r--r--lib/utimensat.c7
-rw-r--r--lib/verify.h7
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 @@
31# include <string.h> 31# include <string.h>
32#endif 32#endif
33 33
34#if USE_ACL && HAVE_ACL_GET_FILE /* Linux, FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */ 34#if USE_ACL && HAVE_ACL_GET_FILE /* Linux, FreeBSD, NetBSD >= 10, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */
35 35
36# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ 36# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
37 37
@@ -45,7 +45,7 @@ acl_extended_nontrivial (acl_t acl)
45 return (acl_entries (acl) > 0); 45 return (acl_entries (acl) > 0);
46} 46}
47 47
48# else /* Linux, FreeBSD, IRIX, Tru64, Cygwin >= 2.5 */ 48# else /* Linux, FreeBSD, NetBSD >= 10, IRIX, Tru64, Cygwin >= 2.5 */
49 49
50/* ACL is an ACL, from a file, stored as type ACL_TYPE_ACCESS. 50/* ACL is an ACL, from a file, stored as type ACL_TYPE_ACCESS.
51 Return 1 if the given ACL is non-trivial. 51 Return 1 if the given ACL is non-trivial.
@@ -59,7 +59,7 @@ acl_access_nontrivial (acl_t acl)
59 at least, allowing us to write 59 at least, allowing us to write
60 return (3 < acl_entries (acl)); 60 return (3 < acl_entries (acl));
61 but the following code is more robust. */ 61 but the following code is more robust. */
62# if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD, Cygwin >= 2.5 */ 62# if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */
63 63
64 acl_entry_t ace; 64 acl_entry_t ace;
65 int got_one; 65 int got_one;
@@ -548,7 +548,7 @@ void
548free_permission_context (struct permission_context *ctx) 548free_permission_context (struct permission_context *ctx)
549{ 549{
550#if USE_ACL 550#if USE_ACL
551# if HAVE_ACL_GET_FILE /* Linux, FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */ 551# if HAVE_ACL_GET_FILE /* Linux, FreeBSD, NetBSD >= 10, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */
552 if (ctx->acl) 552 if (ctx->acl)
553 acl_free (ctx->acl); 553 acl_free (ctx->acl);
554# if !HAVE_ACL_TYPE_EXTENDED 554# 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 *);
52#include <errno.h> 52#include <errno.h>
53 53
54#include <limits.h> 54#include <limits.h>
55 55#include <stdint.h>
56#ifndef SIZE_MAX
57# define SIZE_MAX ((size_t) -1)
58#endif
59 56
60#ifndef HAVE_FCHMOD 57#ifndef HAVE_FCHMOD
61# define HAVE_FCHMOD false 58# define HAVE_FCHMOD false
@@ -121,8 +118,13 @@ rpl_acl_set_fd (int fd, acl_t acl)
121# endif 118# endif
122 119
123/* Linux-specific */ 120/* Linux-specific */
124/* Cygwin >= 2.5 implements this function, but it returns 1 for all 121/* Cygwin >= 2.5 implements acl_extended_file(), but it returns 1 for nearly all
125 directories, thus is unusable. */ 122 directories — for reasons explained in
123 <https://sourceware.org/pipermail/cygwin/2025-March/257762.html> —, thus is
124 unusable. For the user, 'ls' should not print a '+' sign, indicating the
125 presence of an ACL, for 99,9% of the files; this would not be useful.
126 Therefore, on Cygwin, we ignore the acl_extended_file function and instead
127 use our own acl_access_nontrivial function. */
126# if !defined HAVE_ACL_EXTENDED_FILE || defined __CYGWIN__ 128# if !defined HAVE_ACL_EXTENDED_FILE || defined __CYGWIN__
127# undef HAVE_ACL_EXTENDED_FILE 129# undef HAVE_ACL_EXTENDED_FILE
128# define HAVE_ACL_EXTENDED_FILE false 130# 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 @@
22#include "acl-internal.h" 22#include "acl-internal.h"
23 23
24/* This file assumes POSIX-draft like ACLs 24/* This file assumes POSIX-draft like ACLs
25 (Linux, FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5). */ 25 (Linux, FreeBSD, NetBSD >= 10, Mac OS X, IRIX, Tru64, Cygwin >= 2.5). */
26 26
27/* Return the number of entries in ACL. 27/* Return the number of entries in ACL.
28 Return -1 and set errno upon failure to determine it. */ 28 Return -1 and set errno upon failure to determine it. */
@@ -34,7 +34,7 @@ acl_entries (acl_t acl)
34 34
35 if (acl != NULL) 35 if (acl != NULL)
36 { 36 {
37#if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD, Mac OS X, Cygwin >= 2.5 */ 37#if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD, NetBSD >= 10, Mac OS X, Cygwin >= 2.5 */
38# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ 38# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
39 /* acl_get_entry returns 0 when it successfully fetches an entry, 39 /* acl_get_entry returns 0 when it successfully fetches an entry,
40 and -1/EINVAL at the end. */ 40 and -1/EINVAL at the end. */
@@ -45,7 +45,7 @@ acl_entries (acl_t acl)
45 got_one >= 0; 45 got_one >= 0;
46 got_one = acl_get_entry (acl, ACL_NEXT_ENTRY, &ace)) 46 got_one = acl_get_entry (acl, ACL_NEXT_ENTRY, &ace))
47 count++; 47 count++;
48# else /* Linux, FreeBSD, Cygwin >= 2.5 */ 48# else /* Linux, FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */
49 /* acl_get_entry returns 1 when it successfully fetches an entry, 49 /* acl_get_entry returns 1 when it successfully fetches an entry,
50 and 0 at the end. */ 50 and 0 at the end. */
51 acl_entry_t ace; 51 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 @@
22#endif 22#endif
23@PRAGMA_COLUMNS@ 23@PRAGMA_COLUMNS@
24 24
25#if defined __need_system_fcntl_h 25#if defined __need_system_fcntl_h || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H
26/* Special invocation convention. */ 26/* Special invocation convention:
27 - On Haiku we have a sequence of nested includes
28 <fcntl.h> -> <unistd.h> -> <fcntl.h>
29 In this situation, GNULIB_defined_O_NONBLOCK gets defined before the
30 system's definition of O_NONBLOCK is processed. */
27 31
28/* Needed before <sys/stat.h>. 32/* Needed before <sys/stat.h>.
29 May also define off_t to a 64-bit type on native Windows. */ 33 May also define off_t to a 64-bit type on native Windows. */
@@ -50,6 +54,8 @@
50 54
51#ifndef _@GUARD_PREFIX@_FCNTL_H 55#ifndef _@GUARD_PREFIX@_FCNTL_H
52 56
57#define _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H
58
53/* Needed before <sys/stat.h>. 59/* Needed before <sys/stat.h>.
54 May also define off_t to a 64-bit type on native Windows. 60 May also define off_t to a 64-bit type on native Windows.
55 Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */ 61 Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */
@@ -72,6 +78,8 @@
72# include <io.h> 78# include <io.h>
73#endif 79#endif
74 80
81#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H
82
75#ifndef _@GUARD_PREFIX@_FCNTL_H 83#ifndef _@GUARD_PREFIX@_FCNTL_H
76#define _@GUARD_PREFIX@_FCNTL_H 84#define _@GUARD_PREFIX@_FCNTL_H
77 85
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[] = "?";
50# include <selinux/selinux.h> 50# include <selinux/selinux.h>
51# endif 51# endif
52# include <stdckdint.h> 52# include <stdckdint.h>
53# include <stdint.h>
54# include <string.h> 53# include <string.h>
55# include <arpa/inet.h> 54# include <arpa/inet.h>
56# include <sys/xattr.h> 55# include <sys/xattr.h>
@@ -363,6 +362,29 @@ acl_nfs4_nontrivial (uint32_t *xattr, ssize_t nbytes)
363} 362}
364#endif 363#endif
365 364
365#if (!USE_LINUX_XATTR && USE_ACL && HAVE_ACL_GET_FD \
366 && !HAVE_ACL_EXTENDED_FILE && !HAVE_ACL_TYPE_EXTENDED \
367 && !HAVE_ACL_GET_LINK_NP)
368# include <fcntl.h>
369# ifdef O_PATH
370
371/* Like acl_get_file, but do not follow symbolic links. */
372static acl_t
373acl_get_link_np (char const *name, acl_type_t type)
374{
375 int fd = open (name, O_PATH | O_NOFOLLOW);
376 if (fd < 0)
377 return NULL;
378 acl_t r = acl_get_fd (fd);
379 int err = errno;
380 close (fd);
381 errno = err;
382 return r;
383}
384# define HAVE_ACL_GET_LINK_NP 1
385# endif
386#endif
387
366/* Return 1 if NAME has a nontrivial access control list, 388/* Return 1 if NAME has a nontrivial access control list,
367 0 if ACLs are not supported, or if NAME has no or only a base ACL, 389 0 if ACLs are not supported, or if NAME has no or only a base ACL,
368 and -1 (setting errno) on error. Note callers can determine 390 and -1 (setting errno) on error. Note callers can determine
@@ -468,7 +490,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name,
468 ret = -1; 490 ret = -1;
469# else /* FreeBSD, NetBSD >= 10, IRIX, Tru64, Cygwin >= 2.5 */ 491# else /* FreeBSD, NetBSD >= 10, IRIX, Tru64, Cygwin >= 2.5 */
470 acl_t (*acl_get_file_or_link) (char const *, acl_type_t) = acl_get_file; 492 acl_t (*acl_get_file_or_link) (char const *, acl_type_t) = acl_get_file;
471# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10 */ 493# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */
472 if (! (flags & ACL_SYMLINK_FOLLOW)) 494 if (! (flags & ACL_SYMLINK_FOLLOW))
473 acl_get_file_or_link = acl_get_link_np; 495 acl_get_file_or_link = acl_get_link_np;
474# endif 496# 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 @@
26 26
27/* This file is not used on systems that already have the __fpending function, 27/* This file is not used on systems that already have the __fpending function,
28 namely glibc >= 2.2, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.34, 28 namely glibc >= 2.2, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.34,
29 Android API >= 23. */ 29 Android API >= 23, musl libc, Haiku >= hrev58760. */
30 30
31/* Return the number of pending (aka buffered, unflushed) 31/* Return the number of pending (aka buffered, unflushed)
32 bytes on the stream, FP, that is open for writing. */ 32 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 @@
47 N_NAME_POINTER The nlist n_name element is a pointer, 47 N_NAME_POINTER The nlist n_name element is a pointer,
48 not an array. 48 not an array.
49 HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'. 49 HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'.
50 LINUX_LDAV_FILE [__linux__, __ANDROID__, __CYGWIN__]: File
51 containing load averages.
52 50
53 Specific system predefines this file uses, aside from setting 51 Specific system predefines this file uses, aside from setting
54 default values if not emacs: 52 default values if not emacs:
@@ -65,8 +63,7 @@
65 UMAX4_3 63 UMAX4_3
66 VMS 64 VMS
67 _WIN32 Native Windows (possibly also defined on Cygwin) 65 _WIN32 Native Windows (possibly also defined on Cygwin)
68 __linux__, __ANDROID__ Linux: assumes /proc file system mounted. 66 __linux__, __ANDROID__ Linux: assumes sysinfo() call.
69 Support from Michael K. Johnson.
70 __CYGWIN__ Cygwin emulates linux /proc/loadavg. 67 __CYGWIN__ Cygwin emulates linux /proc/loadavg.
71 __NetBSD__ NetBSD: assumes /kern file system mounted. 68 __NetBSD__ NetBSD: assumes /kern file system mounted.
72 69
@@ -108,10 +105,10 @@
108# endif 105# endif
109 106
110/* Same issues as for NeXT apply to the HURD-based GNU system. */ 107/* Same issues as for NeXT apply to the HURD-based GNU system. */
111# ifdef __GNU__ 108# if defined __gnu_hurd__ || defined NeXT
112# undef BSD 109# undef BSD
113# undef FSCALE 110# undef FSCALE
114# endif /* __GNU__ */ 111# endif /* __gnu_hurd__ || NeXT */
115 112
116/* Set values that are different from the defaults, which are 113/* Set values that are different from the defaults, which are
117 set a little farther down with #ifndef. */ 114 set a little farther down with #ifndef. */
@@ -312,8 +309,7 @@
312# endif 309# endif
313# endif 310# endif
314 311
315# if defined (__GNU__) && !defined (NeXT) 312# if defined __gnu_hurd__ && !defined NeXT
316/* Note that NeXT Openstep defines __GNU__ even though it should not. */
317/* GNU system acts much like NeXT, for load average purposes, 313/* GNU system acts much like NeXT, for load average purposes,
318 but not exactly. */ 314 but not exactly. */
319# define NeXT 315# define NeXT
@@ -358,6 +354,11 @@
358# include <sys/dg_sys_info.h> 354# include <sys/dg_sys_info.h>
359# endif 355# endif
360 356
357# if defined __linux__ || defined __ANDROID__
358# include <sys/param.h>
359# include <sys/sysinfo.h>
360# endif
361
361# if (defined __linux__ || defined __ANDROID__ \ 362# if (defined __linux__ || defined __ANDROID__ \
362 || defined __CYGWIN__ || defined SUNOS_5 \ 363 || defined __CYGWIN__ || defined SUNOS_5 \
363 || (defined LOAD_AVE_TYPE && ! defined __VMS)) 364 || (defined LOAD_AVE_TYPE && ! defined __VMS))
@@ -498,20 +499,32 @@ getloadavg (double loadavg[], int nelem)
498 } 499 }
499# endif 500# endif
500 501
501# if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__ || defined __CYGWIN__) 502# if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__)
502 /* Linux without glibc, Android, Cygwin */ 503 /* Linux without glibc, Android, Cygwin */
503# define LDAV_DONE 504# define LDAV_DONE
504# undef LOAD_AVE_TYPE 505# undef LOAD_AVE_TYPE
505 506
506# ifndef LINUX_LDAV_FILE 507 {
507# define LINUX_LDAV_FILE "/proc/loadavg" 508 struct sysinfo info;
508# endif 509 if (sysinfo (&info) < 0)
510 return -1;
511 loadavg[0] = info.loads[0] / (double)(1U << SI_LOAD_SHIFT);
512 loadavg[1] = info.loads[1] / (double)(1U << SI_LOAD_SHIFT);
513 loadavg[2] = info.loads[2] / (double)(1U << SI_LOAD_SHIFT);
514 elem = 3;
515 }
516# endif /* __linux__ || __ANDROID__ */
517
518# if !defined (LDAV_DONE) && defined __CYGWIN__
519 /* Cygwin */
520# define LDAV_DONE
521# undef LOAD_AVE_TYPE
509 522
510 char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")]; 523 char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")];
511 char const *ptr = ldavgbuf; 524 char const *ptr = ldavgbuf;
512 int fd, count, saved_errno; 525 int fd, count, saved_errno;
513 526
514 fd = open (LINUX_LDAV_FILE, O_RDONLY | O_CLOEXEC); 527 fd = open ("/proc/loadavg", O_RDONLY | O_CLOEXEC);
515 if (fd == -1) 528 if (fd == -1)
516 return -1; 529 return -1;
517 count = read (fd, ldavgbuf, sizeof ldavgbuf - 1); 530 count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
@@ -554,7 +567,7 @@ getloadavg (double loadavg[], int nelem)
554 567
555 return elem; 568 return elem;
556 569
557# endif /* __linux__ || __ANDROID__ || __CYGWIN__ */ 570# endif /* __CYGWIN__ */
558 571
559# if !defined (LDAV_DONE) && defined (__NetBSD__) /* NetBSD < 0.9 */ 572# if !defined (LDAV_DONE) && defined (__NetBSD__) /* NetBSD < 0.9 */
560# define LDAV_DONE 573# 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 @@
38# endif 38# endif
39# undef getopt_long 39# undef getopt_long
40# undef getopt_long_only 40# undef getopt_long_only
41# undef option
42# undef _getopt_internal 41# undef _getopt_internal
43# define getopt_long __GETOPT_ID (getopt_long) 42# define getopt_long __GETOPT_ID (getopt_long)
44# define getopt_long_only __GETOPT_ID (getopt_long_only) 43# define getopt_long_only __GETOPT_ID (getopt_long_only)
45# define option __GETOPT_ID (option)
46# define _getopt_internal __GETOPT_ID (getopt_internal) 44# define _getopt_internal __GETOPT_ID (getopt_internal)
47 45
48/* The system's getopt.h may have already included getopt-ext.h to 46/* 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 @@
30 <getopt.h>; our definitions will be present soon enough. */ 30 <getopt.h>; our definitions will be present soon enough. */
31#if @HAVE_GETOPT_H@ 31#if @HAVE_GETOPT_H@
32# define _GL_SYSTEM_GETOPT 32# define _GL_SYSTEM_GETOPT
33/* Rename the system's 'struct option' to 'struct sys_option',
34 so that we don't have to rename ours to 'struct rpl_option'
35 (which would cause significant trouble in C++ mode). */
36# define option sys_option
33# @INCLUDE_NEXT@ @NEXT_GETOPT_H@ 37# @INCLUDE_NEXT@ @NEXT_GETOPT_H@
38# undef option
34# undef _GL_SYSTEM_GETOPT 39# undef _GL_SYSTEM_GETOPT
35#endif 40#endif
36 41
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 @@
49# --avoid=iswxdigit \ 49# --avoid=iswxdigit \
50# --avoid=langinfo-h \ 50# --avoid=langinfo-h \
51# --avoid=libgmp-mpq \ 51# --avoid=libgmp-mpq \
52# --avoid=locale-h \
52# --avoid=localename-unsafe-limited \ 53# --avoid=localename-unsafe-limited \
53# --avoid=lock \ 54# --avoid=lock \
54# --avoid=mbrtowc \ 55# --avoid=mbrtowc \
@@ -624,6 +625,7 @@ GL_GNULIB_STRCHRNUL = @GL_GNULIB_STRCHRNUL@
624GL_GNULIB_STRDUP = @GL_GNULIB_STRDUP@ 625GL_GNULIB_STRDUP = @GL_GNULIB_STRDUP@
625GL_GNULIB_STRERROR = @GL_GNULIB_STRERROR@ 626GL_GNULIB_STRERROR = @GL_GNULIB_STRERROR@
626GL_GNULIB_STRERRORNAME_NP = @GL_GNULIB_STRERRORNAME_NP@ 627GL_GNULIB_STRERRORNAME_NP = @GL_GNULIB_STRERRORNAME_NP@
628GL_GNULIB_STRERROR_L = @GL_GNULIB_STRERROR_L@
627GL_GNULIB_STRERROR_R = @GL_GNULIB_STRERROR_R@ 629GL_GNULIB_STRERROR_R = @GL_GNULIB_STRERROR_R@
628GL_GNULIB_STRFTIME = @GL_GNULIB_STRFTIME@ 630GL_GNULIB_STRFTIME = @GL_GNULIB_STRFTIME@
629GL_GNULIB_STRNCAT = @GL_GNULIB_STRNCAT@ 631GL_GNULIB_STRNCAT = @GL_GNULIB_STRNCAT@
@@ -916,6 +918,7 @@ HAVE_STR2SIG = @HAVE_STR2SIG@
916HAVE_STRCASESTR = @HAVE_STRCASESTR@ 918HAVE_STRCASESTR = @HAVE_STRCASESTR@
917HAVE_STRCHRNUL = @HAVE_STRCHRNUL@ 919HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
918HAVE_STRERRORNAME_NP = @HAVE_STRERRORNAME_NP@ 920HAVE_STRERRORNAME_NP = @HAVE_STRERRORNAME_NP@
921HAVE_STRERROR_L = @HAVE_STRERROR_L@
919HAVE_STRPBRK = @HAVE_STRPBRK@ 922HAVE_STRPBRK = @HAVE_STRPBRK@
920HAVE_STRPTIME = @HAVE_STRPTIME@ 923HAVE_STRPTIME = @HAVE_STRPTIME@
921HAVE_STRSEP = @HAVE_STRSEP@ 924HAVE_STRSEP = @HAVE_STRSEP@
@@ -1213,6 +1216,7 @@ REPLACE_GETENTROPY = @REPLACE_GETENTROPY@
1213REPLACE_GETGROUPS = @REPLACE_GETGROUPS@ 1216REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
1214REPLACE_GETLINE = @REPLACE_GETLINE@ 1217REPLACE_GETLINE = @REPLACE_GETLINE@
1215REPLACE_GETLOADAVG = @REPLACE_GETLOADAVG@ 1218REPLACE_GETLOADAVG = @REPLACE_GETLOADAVG@
1219REPLACE_GETLOGIN = @REPLACE_GETLOGIN@
1216REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@ 1220REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
1217REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@ 1221REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
1218REPLACE_GETPASS = @REPLACE_GETPASS@ 1222REPLACE_GETPASS = @REPLACE_GETPASS@
@@ -1307,6 +1311,7 @@ REPLACE_STRCHRNUL = @REPLACE_STRCHRNUL@
1307REPLACE_STRDUP = @REPLACE_STRDUP@ 1311REPLACE_STRDUP = @REPLACE_STRDUP@
1308REPLACE_STRERROR = @REPLACE_STRERROR@ 1312REPLACE_STRERROR = @REPLACE_STRERROR@
1309REPLACE_STRERRORNAME_NP = @REPLACE_STRERRORNAME_NP@ 1313REPLACE_STRERRORNAME_NP = @REPLACE_STRERRORNAME_NP@
1314REPLACE_STRERROR_L = @REPLACE_STRERROR_L@
1310REPLACE_STRERROR_R = @REPLACE_STRERROR_R@ 1315REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
1311REPLACE_STRFTIME = @REPLACE_STRFTIME@ 1316REPLACE_STRFTIME = @REPLACE_STRFTIME@
1312REPLACE_STRNCAT = @REPLACE_STRNCAT@ 1317REPLACE_STRNCAT = @REPLACE_STRNCAT@
@@ -1543,6 +1548,7 @@ sharedstatedir = @sharedstatedir@
1543srcdir = @srcdir@ 1548srcdir = @srcdir@
1544standardlisppath = @standardlisppath@ 1549standardlisppath = @standardlisppath@
1545sysconfdir = @sysconfdir@ 1550sysconfdir = @sysconfdir@
1551systemduserunitdir = @systemduserunitdir@
1546target_alias = @target_alias@ 1552target_alias = @target_alias@
1547version = @version@ 1553version = @version@
1548with_mailutils = @with_mailutils@ 1554with_mailutils = @with_mailutils@
@@ -1715,13 +1721,25 @@ libgnu_a_SOURCES += c-ctype.h c-ctype.c
1715endif 1721endif
1716## end gnulib module c-ctype 1722## end gnulib module c-ctype
1717 1723
1718## begin gnulib module c-strcase 1724## begin gnulib module c-strcasecmp
1719ifeq (,$(OMIT_GNULIB_MODULE_c-strcase)) 1725ifeq (,$(OMIT_GNULIB_MODULE_c-strcasecmp))
1720 1726
1721libgnu_a_SOURCES += c-strcase.h c-strcasecmp.c c-strncasecmp.c 1727libgnu_a_SOURCES += c-strcasecmp.c
1728
1729EXTRA_DIST += c-strcase.h
1730
1731endif
1732## end gnulib module c-strcasecmp
1733
1734## begin gnulib module c-strncasecmp
1735ifeq (,$(OMIT_GNULIB_MODULE_c-strncasecmp))
1736
1737libgnu_a_SOURCES += c-strncasecmp.c
1738
1739EXTRA_DIST += c-strcase.h
1722 1740
1723endif 1741endif
1724## end gnulib module c-strcase 1742## end gnulib module c-strncasecmp
1725 1743
1726## begin gnulib module canonicalize-lgpl 1744## begin gnulib module canonicalize-lgpl
1727ifeq (,$(OMIT_GNULIB_MODULE_canonicalize-lgpl)) 1745ifeq (,$(OMIT_GNULIB_MODULE_canonicalize-lgpl))
@@ -3681,6 +3699,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
3681 -e 's/@''GNULIB_STR_STARTSWITH''@/$(GL_GNULIB_STR_STARTSWITH)/g' \ 3699 -e 's/@''GNULIB_STR_STARTSWITH''@/$(GL_GNULIB_STR_STARTSWITH)/g' \
3682 -e 's/@''GNULIB_STRERROR''@/$(GL_GNULIB_STRERROR)/g' \ 3700 -e 's/@''GNULIB_STRERROR''@/$(GL_GNULIB_STRERROR)/g' \
3683 -e 's/@''GNULIB_STRERROR_R''@/$(GL_GNULIB_STRERROR_R)/g' \ 3701 -e 's/@''GNULIB_STRERROR_R''@/$(GL_GNULIB_STRERROR_R)/g' \
3702 -e 's/@''GNULIB_STRERROR_L''@/$(GL_GNULIB_STRERROR_L)/g' \
3684 -e 's/@''GNULIB_STRERRORNAME_NP''@/$(GL_GNULIB_STRERRORNAME_NP)/g' \ 3703 -e 's/@''GNULIB_STRERRORNAME_NP''@/$(GL_GNULIB_STRERRORNAME_NP)/g' \
3685 -e 's/@''GNULIB_SIGABBREV_NP''@/$(GL_GNULIB_SIGABBREV_NP)/g' \ 3704 -e 's/@''GNULIB_SIGABBREV_NP''@/$(GL_GNULIB_SIGABBREV_NP)/g' \
3686 -e 's/@''GNULIB_SIGDESCR_NP''@/$(GL_GNULIB_SIGDESCR_NP)/g' \ 3705 -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
3711 -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ 3730 -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
3712 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ 3731 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
3713 -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \ 3732 -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
3733 -e 's|@''HAVE_STRERROR_L''@|$(HAVE_STRERROR_L)|g' \
3714 -e 's|@''HAVE_STRERRORNAME_NP''@|$(HAVE_STRERRORNAME_NP)|g' \ 3734 -e 's|@''HAVE_STRERRORNAME_NP''@|$(HAVE_STRERRORNAME_NP)|g' \
3715 -e 's|@''HAVE_SIGABBREV_NP''@|$(HAVE_SIGABBREV_NP)|g' \ 3735 -e 's|@''HAVE_SIGABBREV_NP''@|$(HAVE_SIGABBREV_NP)|g' \
3716 -e 's|@''HAVE_SIGDESCR_NP''@|$(HAVE_SIGDESCR_NP)|g' \ 3736 -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
3734 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ 3754 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
3735 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ 3755 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
3736 -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \ 3756 -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
3757 -e 's|@''REPLACE_STRERROR_L''@|$(REPLACE_STRERROR_L)|g' \
3737 -e 's|@''REPLACE_STRERRORNAME_NP''@|$(REPLACE_STRERRORNAME_NP)|g' \ 3758 -e 's|@''REPLACE_STRERRORNAME_NP''@|$(REPLACE_STRERRORNAME_NP)|g' \
3738 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ 3759 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
3739 -e 's|@''REPLACE_STRVERSCMP''@|$(REPLACE_STRVERSCMP)|g' \ 3760 -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
4328 -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ 4349 -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
4329 -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \ 4350 -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \
4330 -e 's|@''REPLACE_GETENTROPY''@|$(REPLACE_GETENTROPY)|g' \ 4351 -e 's|@''REPLACE_GETENTROPY''@|$(REPLACE_GETENTROPY)|g' \
4352 -e 's|@''REPLACE_GETLOGIN''@|$(REPLACE_GETLOGIN)|g' \
4331 -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ 4353 -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
4332 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ 4354 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
4333 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ 4355 -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 @@
39 then 'switch (INT_PROMOTE (E))' pacifies gcc -Wswitch-enum if some 39 then 'switch (INT_PROMOTE (E))' pacifies gcc -Wswitch-enum if some
40 enum values are deliberately omitted from the switch's cases. 40 enum values are deliberately omitted from the switch's cases.
41 Here, unary + is safer than a cast or inline function, as unary + 41 Here, unary + is safer than a cast or inline function, as unary +
42 does only integer promotions. */ 42 does only integer promotions and is disallowed on pointers. */
43#define INT_PROMOTE(e) (+ (e)) 43#define INT_PROMOTE(e) (+ (e))
44 44
45 45
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)
398 /* Convert it from positive decimal to 'unsigned long'. */ 398 /* Convert it from positive decimal to 'unsigned long'. */
399 if (c_isdigit (*threads)) 399 if (c_isdigit (*threads))
400 { 400 {
401 char *endptr = NULL; 401 char *endptr;
402 unsigned long int value = strtoul (threads, &endptr, 10); 402 unsigned long int value = strtoul (threads, &endptr, 10);
403 403 while (*endptr != '\0' && c_isspace (*endptr))
404 if (endptr != NULL) 404 endptr++;
405 { 405 if (*endptr == '\0')
406 while (*endptr != '\0' && c_isspace (*endptr)) 406 return value;
407 endptr++; 407 /* Also accept the first value in a nesting level,
408 if (*endptr == '\0') 408 since we can't determine the nesting level from env vars. */
409 return value; 409 else if (*endptr == ',')
410 /* Also accept the first value in a nesting level, 410 return value;
411 since we can't determine the nesting level from env vars. */
412 else if (*endptr == ',')
413 return value;
414 }
415 } 411 }
416 412
417 return ret; 413 return ret;
@@ -438,6 +434,9 @@ num_processors (enum nproc_query query)
438 query = NPROC_CURRENT; 434 query = NPROC_CURRENT;
439 } 435 }
440 /* Here query is one of NPROC_ALL, NPROC_CURRENT. */ 436 /* Here query is one of NPROC_ALL, NPROC_CURRENT. */
437 if (omp_env_limit == 1)
438 /* No need to even call num_processors_ignoring_omp (query). */
439 return 1;
441 { 440 {
442 unsigned long nprocs = num_processors_ignoring_omp (query); 441 unsigned long nprocs = num_processors_ignoring_omp (query);
443 return MIN (nprocs, omp_env_limit); 442 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 @@
45# include <utmp.h> 45# include <utmp.h>
46#endif 46#endif
47 47
48/* Needed for BOOT_TIME and USER_PROCESS. */ 48/* Needed for BOOT_TIME, USER_PROCESS, LOGIN_PROCESS. */
49#if HAVE_UTMPX_H 49#if HAVE_UTMPX_H
50# if defined _THREAD_SAFE && defined UTMP_DATA_INIT 50# if defined _THREAD_SAFE && defined UTMP_DATA_INIT
51 /* When including both utmp.h and utmpx.h on AIX 4.3, with _THREAD_SAFE 51 /* When including both utmp.h and utmpx.h on AIX 4.3, with _THREAD_SAFE
@@ -74,7 +74,8 @@ struct gl_utmp
74 struct timespec ut_ts; /* time */ 74 struct timespec ut_ts; /* time */
75 pid_t ut_pid; /* process ID of ? */ 75 pid_t ut_pid; /* process ID of ? */
76 pid_t ut_session; /* process ID of session leader */ 76 pid_t ut_session; /* process ID of session leader */
77 short ut_type; /* BOOT_TIME, USER_PROCESS, or other */ 77 short ut_type; /* BOOT_TIME, USER_PROCESS, LOGIN_PROCESS,
78 or other */
78 struct { int e_termination; int e_exit; } ut_exit; 79 struct { int e_termination; int e_exit; } ut_exit;
79}; 80};
80 81
@@ -257,19 +258,21 @@ struct utmpx32
257# define WTMP_FILE "/etc/wtmp" 258# define WTMP_FILE "/etc/wtmp"
258#endif 259#endif
259 260
260/* In early versions of Android, <utmp.h> did not define BOOT_TIME, only 261/* In early versions of Android, <utmp.h> did not define BOOT_TIME or
261 USER_PROCESS. We need to use the value that is defined in newer versions 262 LOGIN_PROCESS, only USER_PROCESS. We need to use the value that is defined
262 of Android. */ 263 in newer versions of Android. */
263#if defined __ANDROID__ && !defined BOOT_TIME 264#if defined __ANDROID__ && !defined BOOT_TIME
264# define BOOT_TIME 2 265# define BOOT_TIME 2
266# define LOGIN_PROCESS 6
265#endif 267#endif
266 268
267/* Some platforms, such as OpenBSD, don't have an ut_type field and don't have 269/* Some platforms, such as OpenBSD, don't have an ut_type field and don't have
268 the BOOT_TIME and USER_PROCESS macros. But we want to support them in 270 the BOOT_TIME, USER_PROCESS, and LOGIN_PROCESS macros. But we want to
269 'struct gl_utmp'. */ 271 support them in 'struct gl_utmp'. */
270#if !(HAVE_UTMPX_H ? HAVE_STRUCT_UTMPX_UT_TYPE : HAVE_STRUCT_UTMP_UT_TYPE) 272#if !(HAVE_UTMPX_H ? HAVE_STRUCT_UTMPX_UT_TYPE : HAVE_STRUCT_UTMP_UT_TYPE)
271# define BOOT_TIME 2 273# define BOOT_TIME 2
272# define USER_PROCESS 0 274# define USER_PROCESS 0
275# define LOGIN_PROCESS 6
273#endif 276#endif
274 277
275/* Macros that test (UT)->ut_type. */ 278/* Macros that test (UT)->ut_type. */
@@ -283,6 +286,11 @@ struct utmpx32
283#else 286#else
284# define UT_TYPE_USER_PROCESS(UT) 0 287# define UT_TYPE_USER_PROCESS(UT) 0
285#endif 288#endif
289#ifdef LOGIN_PROCESS
290# define UT_TYPE_LOGIN_PROCESS(UT) ((UT)->ut_type == LOGIN_PROCESS)
291#else
292# define UT_TYPE_LOGIN_PROCESS(UT) 0
293#endif
286 294
287/* Determines whether an entry *UT corresponds to a user process. */ 295/* Determines whether an entry *UT corresponds to a user process. */
288#define IS_USER_PROCESS(UT) \ 296#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)
831 if (table_size > pat_len) 831 if (table_size > pat_len)
832 break; 832 break;
833 833
834 dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size); 834 dfa->state_table = calloc (table_size, sizeof (struct re_state_table_entry));
835 dfa->state_hash_mask = table_size - 1; 835 dfa->state_hash_mask = table_size - 1;
836 836
837 dfa->mb_cur_max = MB_CUR_MAX; 837 dfa->mb_cur_max = MB_CUR_MAX;
@@ -862,7 +862,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
862 { 862 {
863 int i, j, ch; 863 int i, j, ch;
864 864
865 dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 865 dfa->sb_char = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
866 if (__glibc_unlikely (dfa->sb_char == NULL)) 866 if (__glibc_unlikely (dfa->sb_char == NULL))
867 return REG_ESPACE; 867 return REG_ESPACE;
868 868
@@ -3055,8 +3055,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3055 _NL_COLLATE_SYMB_EXTRAMB); 3055 _NL_COLLATE_SYMB_EXTRAMB);
3056 } 3056 }
3057#endif 3057#endif
3058 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 3058 sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
3059 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); 3059 mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
3060 if (__glibc_unlikely (sbcset == NULL || mbcset == NULL)) 3060 if (__glibc_unlikely (sbcset == NULL || mbcset == NULL))
3061 { 3061 {
3062 re_free (sbcset); 3062 re_free (sbcset);
@@ -3548,13 +3548,13 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3548 reg_errcode_t ret; 3548 reg_errcode_t ret;
3549 bin_tree_t *tree; 3549 bin_tree_t *tree;
3550 3550
3551 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 3551 sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
3552 if (__glibc_unlikely (sbcset == NULL)) 3552 if (__glibc_unlikely (sbcset == NULL))
3553 { 3553 {
3554 *err = REG_ESPACE; 3554 *err = REG_ESPACE;
3555 return NULL; 3555 return NULL;
3556 } 3556 }
3557 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); 3557 mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
3558 if (__glibc_unlikely (mbcset == NULL)) 3558 if (__glibc_unlikely (mbcset == NULL))
3559 { 3559 {
3560 re_free (sbcset); 3560 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;
66 66
67/* The following bits are used to determine the regexp syntax we 67/* The following bits are used to determine the regexp syntax we
68 recognize. The set/not-set meanings are chosen so that Emacs syntax 68 recognize. The set/not-set meanings are chosen so that Emacs syntax
69 remains the value 0. The bits are given in alphabetical order, and 69 is the value 0 for Emacs 20 (2000) and earlier, and the value
70 the definitions shifted by one from the previous bit; thus, when we 70 RE_SYNTAX_EMACS for Emacs 21 (2001) and later. */
71 add or remove a bit, only one other definition need change. */
72typedef unsigned long int reg_syntax_t; 71typedef unsigned long int reg_syntax_t;
73 72
74#ifdef __USE_GNU 73#ifdef __USE_GNU
75/* If this bit is not set, then \ inside a bracket expression is literal. 74/* If this bit is not set, then \ inside a bracket expression is literal.
76 If set, then such a \ quotes the following character. */ 75 If set, then such a \ quotes the following character. */
77# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) 76# define RE_BACKSLASH_ESCAPE_IN_LISTS 1ul
78 77
79/* If this bit is not set, then + and ? are operators, and \+ and \? are 78/* If this bit is not set, then + and ? are operators, and \+ and \? are
80 literals. 79 literals.
@@ -215,7 +214,8 @@ extern reg_syntax_t re_syntax_options;
215 (The [[[ comments delimit what gets put into the Texinfo file, so 214 (The [[[ comments delimit what gets put into the Texinfo file, so
216 don't delete them!) */ 215 don't delete them!) */
217/* [[[begin syntaxes]]] */ 216/* [[[begin syntaxes]]] */
218# define RE_SYNTAX_EMACS 0 217# define RE_SYNTAX_EMACS \
218 (RE_CHAR_CLASSES | RE_INTERVALS)
219 219
220# define RE_SYNTAX_AWK \ 220# define RE_SYNTAX_AWK \
221 (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ 221 (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
@@ -522,20 +522,6 @@ typedef struct
522 522
523/* Declarations for routines. */ 523/* Declarations for routines. */
524 524
525#ifndef _REGEX_NELTS
526# if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \
527 && !defined __STDC_NO_VLA__)
528# define _REGEX_NELTS(n) n
529# else
530# define _REGEX_NELTS(n)
531# endif
532#endif
533
534#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
535# pragma GCC diagnostic push
536# pragma GCC diagnostic ignored "-Wvla"
537#endif
538
539#ifndef _Attr_access_ 525#ifndef _Attr_access_
540# ifdef __attr_access 526# ifdef __attr_access
541# define _Attr_access_(arg) __attr_access (arg) 527# define _Attr_access_(arg) __attr_access (arg)
@@ -682,8 +668,7 @@ extern int regcomp (regex_t *_Restrict_ __preg,
682 668
683extern int regexec (const regex_t *_Restrict_ __preg, 669extern int regexec (const regex_t *_Restrict_ __preg,
684 const char *_Restrict_ __String, size_t __nmatch, 670 const char *_Restrict_ __String, size_t __nmatch,
685 regmatch_t __pmatch[_Restrict_arr_ 671 regmatch_t __pmatch[_Restrict_arr_],
686 _REGEX_NELTS (__nmatch)],
687 int __eflags); 672 int __eflags);
688 673
689extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, 674extern 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,
692 677
693extern void regfree (regex_t *__preg); 678extern void regfree (regex_t *__preg);
694 679
695#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
696# pragma GCC diagnostic pop
697#endif
698
699#ifdef __cplusplus 680#ifdef __cplusplus
700} 681}
701#endif /* C++ */ 682#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,
1595 reg_errcode_t err; 1595 reg_errcode_t err;
1596 re_dfastate_t *newstate; 1596 re_dfastate_t *newstate;
1597 1597
1598 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); 1598 newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
1599 if (__glibc_unlikely (newstate == NULL)) 1599 if (__glibc_unlikely (newstate == NULL))
1600 return NULL; 1600 return NULL;
1601 err = re_node_set_init_copy (&newstate->nodes, nodes); 1601 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,
1643 reg_errcode_t err; 1643 reg_errcode_t err;
1644 re_dfastate_t *newstate; 1644 re_dfastate_t *newstate;
1645 1645
1646 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); 1646 newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
1647 if (__glibc_unlikely (newstate == NULL)) 1647 if (__glibc_unlikely (newstate == NULL))
1648 return NULL; 1648 return NULL;
1649 err = re_node_set_init_copy (&newstate->nodes, nodes); 1649 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);
185 185
186int 186int
187regexec (const regex_t *__restrict preg, const char *__restrict string, 187regexec (const regex_t *__restrict preg, const char *__restrict string,
188 size_t nmatch, regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags) 188 size_t nmatch, regmatch_t pmatch[], int eflags)
189{ 189{
190 reg_errcode_t err; 190 reg_errcode_t err;
191 Idx start, length; 191 Idx start, length;
@@ -229,7 +229,7 @@ int
229attribute_compat_text_section 229attribute_compat_text_section
230__compat_regexec (const regex_t *__restrict preg, 230__compat_regexec (const regex_t *__restrict preg,
231 const char *__restrict string, size_t nmatch, 231 const char *__restrict string, size_t nmatch,
232 regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags) 232 regmatch_t pmatch[], int eflags)
233{ 233{
234 return regexec (preg, string, nmatch, pmatch, 234 return regexec (preg, string, nmatch, pmatch,
235 eflags & (REG_NOTBOL | REG_NOTEOL)); 235 eflags & (REG_NOTBOL | REG_NOTEOL));
@@ -2721,8 +2721,8 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2721 continue; /* No. */ 2721 continue; /* No. */
2722 if (sub_top->path == NULL) 2722 if (sub_top->path == NULL)
2723 { 2723 {
2724 sub_top->path = calloc (sizeof (state_array_t), 2724 sub_top->path = calloc (sl_str - sub_top->str_idx + 1,
2725 sl_str - sub_top->str_idx + 1); 2725 sizeof (state_array_t));
2726 if (sub_top->path == NULL) 2726 if (sub_top->path == NULL)
2727 return REG_ESPACE; 2727 return REG_ESPACE;
2728 } 2728 }
@@ -3266,7 +3266,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3266 if (ndests == 0) 3266 if (ndests == 0)
3267 { 3267 {
3268 state->trtable = (re_dfastate_t **) 3268 state->trtable = (re_dfastate_t **)
3269 calloc (sizeof (re_dfastate_t *), SBC_MAX); 3269 calloc (SBC_MAX, sizeof (re_dfastate_t *));
3270 if (__glibc_unlikely (state->trtable == NULL)) 3270 if (__glibc_unlikely (state->trtable == NULL))
3271 return false; 3271 return false;
3272 return true; 3272 return true;
@@ -3338,7 +3338,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3338 discern by looking at the character code: allocate a 3338 discern by looking at the character code: allocate a
3339 256-entry transition table. */ 3339 256-entry transition table. */
3340 trtable = state->trtable = 3340 trtable = state->trtable =
3341 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); 3341 (re_dfastate_t **) calloc (SBC_MAX, sizeof (re_dfastate_t *));
3342 if (__glibc_unlikely (trtable == NULL)) 3342 if (__glibc_unlikely (trtable == NULL))
3343 goto out_free; 3343 goto out_free;
3344 3344
@@ -3369,7 +3369,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3369 transition tables, one starting at trtable[0] and one 3369 transition tables, one starting at trtable[0] and one
3370 starting at trtable[SBC_MAX]. */ 3370 starting at trtable[SBC_MAX]. */
3371 trtable = state->word_trtable = 3371 trtable = state->word_trtable =
3372 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX); 3372 (re_dfastate_t **) calloc (2 * SBC_MAX, sizeof (re_dfastate_t *));
3373 if (__glibc_unlikely (trtable == NULL)) 3373 if (__glibc_unlikely (trtable == NULL))
3374 goto out_free; 3374 goto out_free;
3375 3375
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 @@
30# endif 30# endif
31#endif 31#endif
32 32
33/* Haiku stdio implementation. */
34#if defined __HAIKU__
35# include <stdint.h>
36/* This FILE structure was made into an incomplete type in 2025.
37 See <https://cgit.haiku-os.org/haiku/tree/src/system/libroot/posix/glibc/libio/libio.h>. */
38# define fp_ ((struct { int _flags; \
39 char *_IO_read_ptr; \
40 char *_IO_read_end; \
41 char *_IO_read_base; \
42 char *_IO_write_base; \
43 char *_IO_write_ptr; \
44 char *_IO_write_end; \
45 char *_IO_buf_base; \
46 char *_IO_buf_end; \
47 char *_IO_save_base; \
48 char *_IO_backup_base; \
49 char *_IO_save_end; \
50 void *_markers; \
51 void *_chain; \
52 int _fileno; \
53 int _flags2; \
54 off_t _old_offset; \
55 unsigned short _cur_column; \
56 signed char _vtable_offset; \
57 char _shortbuf[1]; \
58 void *_lock; \
59 int64_t _offset; \
60 /* More fields, not relevant here. */ \
61 } *) fp)
62# if !defined _IO_UNBUFFERED
63# define _IO_UNBUFFERED 0x2
64# endif
65# if !defined _IO_EOF_SEEN
66# define _IO_EOF_SEEN 0x10
67# endif
68# if !defined _IO_IN_BACKUP
69# define _IO_IN_BACKUP 0x100
70# endif
71# if !defined _IO_LINE_BUF
72# define _IO_LINE_BUF 0x200
73# endif
74#endif
75
33/* BSD stdio derived implementations. */ 76/* BSD stdio derived implementations. */
34 77
35#if defined __NetBSD__ /* NetBSD */ 78#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 @@
63#include <stddef.h> 63#include <stddef.h>
64 64
65/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. 65/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>.
66 glibc 2.40 defines WCOREDUMP in <sys/wait.h>, not in <stdlib.h>. */ 66 glibc 2.41 defines WCOREDUMP in <sys/wait.h>, not in <stdlib.h>. */
67#if @GNULIB_SYSTEM_POSIX@ && !(defined WEXITSTATUS && defined WCOREDUMP) 67#if @GNULIB_SYSTEM_POSIX@ && !(defined WEXITSTATUS && defined WCOREDUMP)
68# include <sys/wait.h> 68# include <sys/wait.h>
69#endif 69#endif
@@ -120,14 +120,14 @@ struct random_data
120# include <unistd.h> 120# include <unistd.h>
121#endif 121#endif
122 122
123#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 123#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)
124/* When strtol, strtoll, strtoul, or strtoull is going to be defined as a macro 124/* When strtol, strtoll, strtoul, or strtoull is going to be defined as a macro
125 below, this may cause compilation errors later in the libstdc++ header files 125 below, this may cause compilation errors later in the libstdc++ header files
126 (that are part of GCC), such as: 126 (that are part of GCC), such as:
127 error: 'rpl_strtol' is not a member of 'std' 127 error: 'rpl_strtol' is not a member of 'std'
128 To avoid this, include the relevant header files here, before these symbols 128 To avoid this, include the relevant header files here, before these symbols
129 get defined as macros. But do so only on Solaris 11 (where it is needed), 129 get defined as macros. But do so only on Solaris 11 and AIX (where it is
130 not on mingw (where it would cause other compilation errors). */ 130 needed), not on mingw (where it would cause other compilation errors). */
131# include <string> 131# include <string>
132#endif 132#endif
133 133
@@ -1473,11 +1473,17 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
1473# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ 1473# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@
1474# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2 1474# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2
1475# define _GL_INLINE_RPL_REALLOC 1 1475# define _GL_INLINE_RPL_REALLOC 1
1476# ifdef __cplusplus
1477extern "C" {
1478# endif
1476_GL_REALLOC_INLINE void * 1479_GL_REALLOC_INLINE void *
1477rpl_realloc (void *ptr, size_t size) 1480rpl_realloc (void *ptr, size_t size)
1478{ 1481{
1479 return realloc (ptr, size ? size : 1); 1482 return realloc (ptr, size ? size : 1);
1480} 1483}
1484# ifdef __cplusplus
1485}
1486# endif
1481# endif 1487# endif
1482# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ 1488# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
1483 || _GL_USE_STDLIB_ALLOC) 1489 || _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 @@
54/* NetBSD 5.0 mis-defines NULL. */ 54/* NetBSD 5.0 mis-defines NULL. */
55#include <stddef.h> 55#include <stddef.h>
56 56
57#if @GNULIB_STRERROR_L@
58/* Get locale_t. */
59# include <locale.h>
60#endif
61
57/* MirBSD defines mbslen as a macro. */ 62/* MirBSD defines mbslen as a macro. */
58#if @GNULIB_MBSLEN@ && defined __MirBSD__ 63#if @GNULIB_MBSLEN@ && defined __MirBSD__
59# include <wchar.h> 64# include <wchar.h>
@@ -429,7 +434,9 @@ _GL_FUNCDECL_SYS (memset_explicit, void *,
429# endif 434# endif
430_GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n)); 435_GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n));
431# endif 436# endif
437# if __GLIBC__ >= 2
432_GL_CXXALIASWARN (memset_explicit); 438_GL_CXXALIASWARN (memset_explicit);
439# endif
433#elif defined GNULIB_POSIXCHECK 440#elif defined GNULIB_POSIXCHECK
434# undef memset_explicit 441# undef memset_explicit
435# if HAVE_RAW_DECL_MEMSET_EXPLICIT 442# if HAVE_RAW_DECL_MEMSET_EXPLICIT
@@ -1178,6 +1185,33 @@ _GL_CXXALIASWARN (mbsrchr);
1178_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) 1185_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
1179 _GL_ATTRIBUTE_PURE 1186 _GL_ATTRIBUTE_PURE
1180 _GL_ARG_NONNULL ((1, 2)); 1187 _GL_ARG_NONNULL ((1, 2));
1188# ifndef _GL_NO_CONST_GENERICS
1189/* Don't silently convert a 'const char *' to a 'char *'. Programmers want
1190 compiler warnings for 'const' related mistakes. */
1191# ifdef __cplusplus
1192extern "C++" { /* needed for AIX */
1193template <typename T>
1194 T * mbsstr_template (T* haystack, const char *needle);
1195template <>
1196 inline char * mbsstr_template (char *haystack, const char *needle)
1197 { return mbsstr (haystack, needle); }
1198template <>
1199 inline const char * mbsstr_template (const char *haystack, const char *needle)
1200 { return mbsstr (haystack, needle); }
1201}
1202# undef mbsstr
1203# define mbsstr mbsstr_template
1204# elif !defined mbsstr
1205# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
1206 || defined __ICC || defined __TINYC__ \
1207 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
1208# define mbsstr(h,n) \
1209 _Generic ((h), \
1210 char const *: (char const *) mbsstr ((h), (n)), \
1211 default : mbsstr ((h), (n)))
1212# endif
1213# endif
1214# endif
1181#endif 1215#endif
1182 1216
1183#if @GNULIB_MBSCASECMP@ 1217#if @GNULIB_MBSCASECMP@
@@ -1219,6 +1253,33 @@ _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
1219_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) 1253_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1220 _GL_ATTRIBUTE_PURE 1254 _GL_ATTRIBUTE_PURE
1221 _GL_ARG_NONNULL ((1, 2)); 1255 _GL_ARG_NONNULL ((1, 2));
1256# ifndef _GL_NO_CONST_GENERICS
1257/* Don't silently convert a 'const char *' to a 'char *'. Programmers want
1258 compiler warnings for 'const' related mistakes. */
1259# ifdef __cplusplus
1260extern "C++" { /* needed for AIX */
1261template <typename T>
1262 T * mbspcasecmp_template (T* string, const char *prefix);
1263template <>
1264 inline char * mbspcasecmp_template (char *string, const char *prefix)
1265 { return mbspcasecmp (string, prefix); }
1266template <>
1267 inline const char * mbspcasecmp_template (const char *string, const char *prefix)
1268 { return mbspcasecmp (string, prefix); }
1269}
1270# undef mbspcasecmp
1271# define mbspcasecmp mbspcasecmp_template
1272# elif !defined mbspcasecmp
1273# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
1274 || defined __ICC || defined __TINYC__ \
1275 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
1276# define mbspcasecmp(s,p) \
1277 _Generic ((s), \
1278 char const *: (char const *) mbspcasecmp ((s), (p)), \
1279 default : mbspcasecmp ((s), (p)))
1280# endif
1281# endif
1282# endif
1222#endif 1283#endif
1223 1284
1224#if @GNULIB_MBSCASESTR@ 1285#if @GNULIB_MBSCASESTR@
@@ -1230,6 +1291,33 @@ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1230_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) 1291_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
1231 _GL_ATTRIBUTE_PURE 1292 _GL_ATTRIBUTE_PURE
1232 _GL_ARG_NONNULL ((1, 2)); 1293 _GL_ARG_NONNULL ((1, 2));
1294# ifndef _GL_NO_CONST_GENERICS
1295/* Don't silently convert a 'const char *' to a 'char *'. Programmers want
1296 compiler warnings for 'const' related mistakes. */
1297# ifdef __cplusplus
1298extern "C++" { /* needed for AIX */
1299template <typename T>
1300 T * mbscasestr_template (T* haystack, const char *needle);
1301template <>
1302 inline char * mbscasestr_template (char *haystack, const char *needle)
1303 { return mbscasestr (haystack, needle); }
1304template <>
1305 inline const char * mbscasestr_template (const char *haystack, const char *needle)
1306 { return mbscasestr (haystack, needle); }
1307}
1308# undef mbscasestr
1309# define mbscasestr mbscasestr_template
1310# elif !defined mbscasestr
1311# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
1312 || defined __ICC || defined __TINYC__ \
1313 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
1314# define mbscasestr(h,n) \
1315 _Generic ((h), \
1316 char const *: (char const *) mbscasestr ((h), (n)), \
1317 default : mbscasestr ((h), (n)))
1318# endif
1319# endif
1320# endif
1233#endif 1321#endif
1234 1322
1235#if @GNULIB_MBSCSPN@ 1323#if @GNULIB_MBSCSPN@
@@ -1388,6 +1476,44 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1388# endif 1476# endif
1389#endif 1477#endif
1390 1478
1479/* Map any int, typically from errno, into an error message.
1480 With locale_t argument. */
1481#if @GNULIB_STRERROR_L@
1482# if @REPLACE_STRERROR_L@
1483# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1484# undef strerror_l
1485# define strerror_l rpl_strerror_l
1486# endif
1487_GL_FUNCDECL_RPL (strerror_l, char *, (int errnum, locale_t locale),
1488 _GL_ARG_NONNULL ((2)));
1489_GL_CXXALIAS_RPL (strerror_l, char *, (int errnum, locale_t locale));
1490# else
1491# if !@HAVE_STRERROR_L@
1492_GL_FUNCDECL_SYS (strerror_l, char *, (int errnum, locale_t locale),
1493 _GL_ARG_NONNULL ((2)));
1494# endif
1495_GL_CXXALIAS_SYS (strerror_l, char *, (int errnum, locale_t locale));
1496# endif
1497# if __GLIBC__ >= 2
1498_GL_CXXALIASWARN (strerror_l);
1499# endif
1500#elif defined GNULIB_POSIXCHECK
1501# undef strerror_l
1502# if HAVE_RAW_DECL_STRERROR_L
1503_GL_WARN_ON_USE (strerror_l, "strerror_l is unportable - "
1504 "use gnulib module strerror_l for portability");
1505# endif
1506#endif
1507
1508/* Map any int, typically from errno, into an error message. Multithread-safe,
1509 with locale_t argument.
1510 Not portable! Only provided by gnulib. */
1511#if @GNULIB_STRERROR_L@
1512_GL_FUNCDECL_SYS (strerror_l_r, int,
1513 (int errnum, char *buf, size_t buflen, locale_t locale),
1514 _GL_ARG_NONNULL ((2, 4)));
1515#endif
1516
1391/* Return the name of the system error code ERRNUM. */ 1517/* Return the name of the system error code ERRNUM. */
1392#if @GNULIB_STRERRORNAME_NP@ 1518#if @GNULIB_STRERRORNAME_NP@
1393# if @REPLACE_STRERRORNAME_NP@ 1519# if @REPLACE_STRERRORNAME_NP@
@@ -1403,7 +1529,9 @@ _GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum), );
1403# endif 1529# endif
1404_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum)); 1530_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum));
1405# endif 1531# endif
1532# if __GLIBC__ >= 2
1406_GL_CXXALIASWARN (strerrorname_np); 1533_GL_CXXALIASWARN (strerrorname_np);
1534# endif
1407#elif defined GNULIB_POSIXCHECK 1535#elif defined GNULIB_POSIXCHECK
1408# undef strerrorname_np 1536# undef strerrorname_np
1409# if HAVE_RAW_DECL_STRERRORNAME_NP 1537# 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),
186# endif 186# endif
187_GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base)); 187_GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base));
188# endif 188# endif
189# if __GLIBC__ >= 2
189_GL_CXXALIASWARN (timespec_getres); 190_GL_CXXALIASWARN (timespec_getres);
191# endif
190# elif defined GNULIB_POSIXCHECK 192# elif defined GNULIB_POSIXCHECK
191# undef timespec_getres 193# undef timespec_getres
192# if HAVE_RAW_DECL_TIMESPEC_GETRES 194# 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 @@
95# include <stdio.h> 95# include <stdio.h>
96#endif 96#endif
97 97
98/* FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Solaris 11.4, and glibc 2.41
99 do not define O_CLOEXEC in <unistd.h>. */
98/* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in 100/* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
99 <unistd.h>. */ 101 <unistd.h>. */
100/* But avoid namespace pollution on glibc systems. */ 102/* But avoid namespace pollution on glibc systems. */
101#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \ 103#if ! defined O_CLOEXEC \
102 && (defined __CYGWIN__ || defined __ANDROID__) \ 104 || ((@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
103 && ! defined __GLIBC__ 105 && (defined __CYGWIN__ || defined __ANDROID__) \
106 && ! defined __GLIBC__)
104# include <fcntl.h> 107# include <fcntl.h>
105#endif 108#endif
106 109
@@ -463,7 +466,9 @@ _GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
463 int ofd, off_t *opos, 466 int ofd, off_t *opos,
464 size_t len, unsigned flags)); 467 size_t len, unsigned flags));
465# endif 468# endif
469# if __GLIBC__ >= 2
466_GL_CXXALIASWARN (copy_file_range); 470_GL_CXXALIASWARN (copy_file_range);
471# endif
467#elif defined GNULIB_POSIXCHECK 472#elif defined GNULIB_POSIXCHECK
468# undef copy_file_range 473# undef copy_file_range
469# if HAVE_RAW_DECL_COPY_FILE_RANGE 474# if HAVE_RAW_DECL_COPY_FILE_RANGE
@@ -1362,11 +1367,21 @@ _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
1362 ${LOGNAME-$USER} on Unix platforms, 1367 ${LOGNAME-$USER} on Unix platforms,
1363 $USERNAME on native Windows platforms. 1368 $USERNAME on native Windows platforms.
1364 */ 1369 */
1365# if !@HAVE_DECL_GETLOGIN@ 1370# if @REPLACE_GETLOGIN@
1371# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1372# define getlogin rpl_getlogin
1373# endif
1374_GL_FUNCDECL_RPL (getlogin, char *, (void), );
1375_GL_CXXALIAS_RPL (getlogin, char *, (void));
1376# else
1377# if !@HAVE_DECL_GETLOGIN@
1366_GL_FUNCDECL_SYS (getlogin, char *, (void), ); 1378_GL_FUNCDECL_SYS (getlogin, char *, (void), );
1367# endif 1379# endif
1368_GL_CXXALIAS_SYS (getlogin, char *, (void)); 1380_GL_CXXALIAS_SYS (getlogin, char *, (void));
1381# endif
1382# if __GLIBC__ >= 2
1369_GL_CXXALIASWARN (getlogin); 1383_GL_CXXALIASWARN (getlogin);
1384# endif
1370#elif defined GNULIB_POSIXCHECK 1385#elif defined GNULIB_POSIXCHECK
1371# undef getlogin 1386# undef getlogin
1372# if HAVE_RAW_DECL_GETLOGIN 1387# if HAVE_RAW_DECL_GETLOGIN
@@ -2405,7 +2420,7 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
2405#if @GNULIB_USLEEP@ 2420#if @GNULIB_USLEEP@
2406/* Pause the execution of the current thread for N microseconds. 2421/* Pause the execution of the current thread for N microseconds.
2407 Returns 0 on completion, or -1 on range error. 2422 Returns 0 on completion, or -1 on range error.
2408 See the POSIX:2001 specification 2423 See the POSIX.1-2004 specification
2409 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */ 2424 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
2410# if @REPLACE_USLEEP@ 2425# if @REPLACE_USLEEP@
2411# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2426# 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 @@
25#include <time.h> 25#include <time.h>
26 26
27#if HAVE_UTIMENS || HAVE_LUTIMENS 27#if HAVE_UTIMENS || HAVE_LUTIMENS
28# include <sys/time.h> 28# include <sys/stat.h>
29#endif 29#endif
30 30
31#ifdef __cplusplus 31#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],
136 } 136 }
137# endif 137# endif
138# endif 138# endif
139# if defined __APPLE__ && defined __MACH__ 139# if (defined __APPLE__ && defined __MACH__) || defined __gnu_hurd__
140 /* macOS 10.13 does not reject invalid tv_nsec values either. */ 140 /* macOS 10.13 and GNU Hurd do not reject invalid tv_nsec values
141 either. */
141 if (times 142 if (times
142 && ((times[0].tv_nsec != UTIME_OMIT 143 && ((times[0].tv_nsec != UTIME_OMIT
143 && times[0].tv_nsec != UTIME_NOW 144 && times[0].tv_nsec != UTIME_NOW
@@ -151,6 +152,7 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2],
151 errno = EINVAL; 152 errno = EINVAL;
152 return -1; 153 return -1;
153 } 154 }
155# if defined __APPLE__ && defined __MACH__
154 size_t len = strlen (file); 156 size_t len = strlen (file);
155 if (len > 0 && file[len - 1] == '/') 157 if (len > 0 && file[len - 1] == '/')
156 { 158 {
@@ -163,6 +165,7 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2],
163 return -1; 165 return -1;
164 } 166 }
165 } 167 }
168# endif
166# endif 169# endif
167 result = utimensat (fd, file, times, flag); 170 result = utimensat (fd, file, times, flag);
168 /* Linux kernel 2.6.25 has a bug where it returns EINVAL for 171 /* 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 @@
157#define _GL_CONCAT0(x, y) x##y 157#define _GL_CONCAT0(x, y) x##y
158 158
159/* _GL_COUNTER is an integer, preferably one that changes each time we 159/* _GL_COUNTER is an integer, preferably one that changes each time we
160 use it. Use __COUNTER__ if it works, falling back on __LINE__ 160 use it. Use __COUNTER__ if it works (it does so with most compilers,
161 otherwise. __LINE__ isn't perfect, but it's better than a 161 see <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3457.htm>),
162 constant. */ 162 falling back on __LINE__ otherwise. __LINE__ isn't perfect, but it's
163 better than a constant. */
163#if defined __COUNTER__ && __COUNTER__ != __COUNTER__ 164#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
164# define _GL_COUNTER __COUNTER__ 165# define _GL_COUNTER __COUNTER__
165#else 166#else