summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-09-28 00:29:09 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2022-09-28 00:37:12 -0700
commita9b29ee4a0ffa4878d67eaf518dbeed098844b9e (patch)
treebbde8d6eae8b3676bb1d9f74d8ce0f6d7016c834 /lib
parentc1eb13b32676b288a3ab3826501caf7bcd376b7f (diff)
downloademacs-a9b29ee4a0ffa4878d67eaf518dbeed098844b9e.tar.gz
Update from Gnulib by running admin/merge-gnulib
Diffstat (limited to 'lib')
-rw-r--r--lib/acl-internal.h1
-rw-r--r--lib/acl.h1
-rw-r--r--lib/assert.in.h27
-rw-r--r--lib/c-ctype.h2
-rw-r--r--lib/canonicalize-lgpl.c1
-rw-r--r--lib/cloexec.h2
-rw-r--r--lib/close-stream.c1
-rw-r--r--lib/count-leading-zeros.h20
-rw-r--r--lib/count-trailing-zeros.h16
-rw-r--r--lib/diffseq.h1
-rw-r--r--lib/filevercmp.c4
-rw-r--r--lib/fsusage.h1
-rw-r--r--lib/getloadavg.c1
-rw-r--r--lib/getrandom.c1
-rw-r--r--lib/gnulib.mk.in35
-rw-r--r--lib/malloc/dynarray.h1
-rw-r--r--lib/md5.c1
-rw-r--r--lib/mini-gmp.c5
-rw-r--r--lib/nanosleep.c4
-rw-r--r--lib/nstrftime.c1
-rw-r--r--lib/openat.h1
-rw-r--r--lib/pipe2.c3
-rw-r--r--lib/rawmemchr.c4
-rw-r--r--lib/regex_internal.h1
-rw-r--r--lib/sha1.c1
-rw-r--r--lib/sha256.c1
-rw-r--r--lib/sha512.c1
-rw-r--r--lib/signal.in.h14
-rw-r--r--lib/stdalign.in.h24
-rw-r--r--lib/stdckdint.in.h2
-rw-r--r--lib/stdlib.in.h6
-rw-r--r--lib/string.in.h2
-rw-r--r--lib/strtoimax.c6
-rw-r--r--lib/sys_random.in.h2
-rw-r--r--lib/sys_select.in.h9
-rw-r--r--lib/sys_stat.in.h76
-rw-r--r--lib/tempname.c1
-rw-r--r--lib/time.in.h4
-rw-r--r--lib/time_rz.c1
-rw-r--r--lib/unistd.in.h4
-rw-r--r--lib/utimens.c1
-rw-r--r--lib/verify.h39
42 files changed, 217 insertions, 112 deletions
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index 93533762dd0..94553fab254 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -19,7 +19,6 @@
#include "acl.h"
-#include <stdbool.h>
#include <stdlib.h>
/* All systems define the ACL related API in <sys/acl.h>. */
diff --git a/lib/acl.h b/lib/acl.h
index f4d0df80618..0be6ef1cea3 100644
--- a/lib/acl.h
+++ b/lib/acl.h
@@ -20,7 +20,6 @@
#ifndef _GL_ACL_H
#define _GL_ACL_H 1
-#include <stdbool.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lib/assert.in.h b/lib/assert.in.h
new file mode 100644
index 00000000000..2c358ba62e7
--- /dev/null
+++ b/lib/assert.in.h
@@ -0,0 +1,27 @@
+/* Substitute for and wrapper around <assert.h>
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Do not guard the include, since <assert.h> is supposed to define
+ the assert macro each time it is included. */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#@INCLUDE_NEXT@ @NEXT_ASSERT_H@
+
+/* The definition of static_assert is copied here. */
diff --git a/lib/c-ctype.h b/lib/c-ctype.h
index 1a4f603898f..1202ff8a363 100644
--- a/lib/c-ctype.h
+++ b/lib/c-ctype.h
@@ -23,8 +23,6 @@
#ifndef C_CTYPE_H
#define C_CTYPE_H
-#include <stdbool.h>
-
#ifndef _GL_INLINE_HEADER_BEGIN
#error "Please include config.h first."
#endif
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index a7fa7feb62e..8c3d7f7cf80 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -30,7 +30,6 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
-#include <stdbool.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
diff --git a/lib/cloexec.h b/lib/cloexec.h
index 7a22d775327..15d2d5efe20 100644
--- a/lib/cloexec.h
+++ b/lib/cloexec.h
@@ -15,8 +15,6 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
-#include <stdbool.h>
-
/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
or clear the flag if VALUE is false.
Return 0 on success, or -1 on error with 'errno' set.
diff --git a/lib/close-stream.c b/lib/close-stream.c
index 9b0e97b271d..0fdca79bf8e 100644
--- a/lib/close-stream.c
+++ b/lib/close-stream.c
@@ -20,7 +20,6 @@
#include "close-stream.h"
#include <errno.h>
-#include <stdbool.h>
#include "fpending.h"
diff --git a/lib/count-leading-zeros.h b/lib/count-leading-zeros.h
index 354641af0a2..4b4f5d4f9a1 100644
--- a/lib/count-leading-zeros.h
+++ b/lib/count-leading-zeros.h
@@ -43,13 +43,17 @@ extern "C" {
# define COUNT_LEADING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE) \
return x ? BUILTIN (x) : CHAR_BIT * sizeof x;
#elif _MSC_VER
-# pragma intrinsic _BitScanReverse
-# pragma intrinsic _BitScanReverse64
+# pragma intrinsic (_BitScanReverse)
+# if defined _M_X64
+# pragma intrinsic (_BitScanReverse64)
+# endif
# define COUNT_LEADING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE) \
do \
{ \
unsigned long result; \
- return MSC_BUILTIN (&result, x) ? result : CHAR_BIT * sizeof x; \
+ if (MSC_BUILTIN (&result, x)) \
+ return CHAR_BIT * sizeof x - 1 - result; \
+ return CHAR_BIT * sizeof x; \
} \
while (0)
#else
@@ -109,8 +113,18 @@ count_leading_zeros_l (unsigned long int x)
COUNT_LEADING_ZEROS_INLINE int
count_leading_zeros_ll (unsigned long long int x)
{
+#if (defined _MSC_VER && !defined __clang__) && !defined _M_X64
+ /* 32-bit MSVC does not have _BitScanReverse64, only _BitScanReverse. */
+ unsigned long result;
+ if (_BitScanReverse (&result, (unsigned long) (x >> 32)))
+ return CHAR_BIT * sizeof x - 1 - 32 - result;
+ if (_BitScanReverse (&result, (unsigned long) x))
+ return CHAR_BIT * sizeof x - 1 - result;
+ return CHAR_BIT * sizeof x;
+#else
COUNT_LEADING_ZEROS (__builtin_clzll, _BitScanReverse64,
unsigned long long int);
+#endif
}
#ifdef __cplusplus
diff --git a/lib/count-trailing-zeros.h b/lib/count-trailing-zeros.h
index 9a989a43245..61fbdf29801 100644
--- a/lib/count-trailing-zeros.h
+++ b/lib/count-trailing-zeros.h
@@ -43,8 +43,10 @@ extern "C" {
# define COUNT_TRAILING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE) \
return x ? BUILTIN (x) : CHAR_BIT * sizeof x;
#elif _MSC_VER
-# pragma intrinsic _BitScanForward
-# pragma intrinsic _BitScanForward64
+# pragma intrinsic (_BitScanForward)
+# if defined _M_X64
+# pragma intrinsic (_BitScanForward64)
+# endif
# define COUNT_TRAILING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE) \
do \
{ \
@@ -101,8 +103,18 @@ count_trailing_zeros_l (unsigned long int x)
COUNT_TRAILING_ZEROS_INLINE int
count_trailing_zeros_ll (unsigned long long int x)
{
+#if (defined _MSC_VER && !defined __clang__) && !defined _M_X64
+ /* 32-bit MSVC does not have _BitScanForward64, only _BitScanForward. */
+ unsigned long result;
+ if (_BitScanForward (&result, (unsigned long) x))
+ return result;
+ if (_BitScanForward (&result, (unsigned long) (x >> 32)))
+ return result + 32;
+ return CHAR_BIT * sizeof x;
+#else
COUNT_TRAILING_ZEROS (__builtin_ctzll, _BitScanForward64,
unsigned long long int);
+#endif
}
#ifdef __cplusplus
diff --git a/lib/diffseq.h b/lib/diffseq.h
index 0f76ea1d5ad..a8b0e7bd408 100644
--- a/lib/diffseq.h
+++ b/lib/diffseq.h
@@ -70,7 +70,6 @@
Before including this file, you also need to include:
#include <limits.h>
- #include <stdbool.h>
#include "minmax.h"
*/
diff --git a/lib/filevercmp.c b/lib/filevercmp.c
index 7e54793e613..844505a6bf7 100644
--- a/lib/filevercmp.c
+++ b/lib/filevercmp.c
@@ -20,11 +20,9 @@
#include <config.h>
#include "filevercmp.h"
-#include <stdbool.h>
#include <c-ctype.h>
#include <limits.h>
#include <idx.h>
-#include <verify.h>
/* Return the length of a prefix of S that corresponds to the suffix
defined by this extended regular expression in the C locale:
@@ -75,7 +73,7 @@ order (char const *s, idx_t pos, idx_t len)
return -2;
else
{
- verify (UCHAR_MAX <= (INT_MAX - 1 - 2) / 2);
+ static_assert (UCHAR_MAX <= (INT_MAX - 1 - 2) / 2);
return c + UCHAR_MAX + 1;
}
}
diff --git a/lib/fsusage.h b/lib/fsusage.h
index 0443d19f922..27085b7b41e 100644
--- a/lib/fsusage.h
+++ b/lib/fsusage.h
@@ -22,7 +22,6 @@
# define FSUSAGE_H_
# include <stdint.h>
-# include <stdbool.h>
struct fs_usage
{
diff --git a/lib/getloadavg.c b/lib/getloadavg.c
index 37e82808671..1fddee97afd 100644
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -82,7 +82,6 @@
#include <stdlib.h>
#include <errno.h>
-#include <stdbool.h>
#include <stdio.h>
# include <sys/types.h>
diff --git a/lib/getrandom.c b/lib/getrandom.c
index e1468730933..c05a48167ed 100644
--- a/lib/getrandom.c
+++ b/lib/getrandom.c
@@ -23,7 +23,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <stdbool.h>
#include <unistd.h>
#if defined _WIN32 && ! defined __CYGWIN__
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 5bb78740d6a..7eca66a6093 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -180,6 +180,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
AR = @AR@
ARFLAGS = @ARFLAGS@
+ASSERT_H = @ASSERT_H@
AUTO_DEPEND = @AUTO_DEPEND@
AWK = @AWK@
BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
@@ -307,6 +308,7 @@ GL_COND_OBJ_TIME_RZ_CONDITION = @GL_COND_OBJ_TIME_RZ_CONDITION@
GL_COND_OBJ_TIME_R_CONDITION = @GL_COND_OBJ_TIME_R_CONDITION@
GL_COND_OBJ_UTIMENSAT_CONDITION = @GL_COND_OBJ_UTIMENSAT_CONDITION@
GL_GENERATE_ALLOCA_H_CONDITION = @GL_GENERATE_ALLOCA_H_CONDITION@
+GL_GENERATE_ASSERT_H_CONDITION = @GL_GENERATE_ASSERT_H_CONDITION@
GL_GENERATE_BYTESWAP_H_CONDITION = @GL_GENERATE_BYTESWAP_H_CONDITION@
GL_GENERATE_ERRNO_H_CONDITION = @GL_GENERATE_ERRNO_H_CONDITION@
GL_GENERATE_EXECINFO_H_CONDITION = @GL_GENERATE_EXECINFO_H_CONDITION@
@@ -1440,6 +1442,39 @@ EXTRA_DIST += allocator.h
endif
## end gnulib module allocator
+## begin gnulib module assert-h
+ifeq (,$(OMIT_GNULIB_MODULE_assert-h))
+
+BUILT_SOURCES += $(ASSERT_H)
+
+# We need the following in order to create <assert.h> when the system
+# doesn't have one that works with the given compiler.
+ifneq (,$(GL_GENERATE_ASSERT_H_CONDITION))
+assert.h: assert.in.h verify.h $(top_builddir)/config.status
+ $(gl_V_at){ $(SED_HEADER_STDOUT) \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_ASSERT_H''@|$(NEXT_ASSERT_H)|g' \
+ < $(srcdir)/assert.in.h && \
+ sed -e '/@assert.h omit start@/,/@assert.h omit end@/d' \
+ -e 's|_gl_verify|_gl_static_assert|g' \
+ -e 's|_GL_VERIFY|_GL_STATIC_ASSERT|g' \
+ -e 's|_GL\(_STATIC_ASSERT_H\)|_GL\1|g' \
+ < $(srcdir)/verify.h; \
+ } > $@-t
+ $(AM_V_at)mv $@-t $@
+else
+assert.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += assert.h assert.h-t
+
+EXTRA_DIST += assert.in.h verify.h
+
+endif
+## end gnulib module assert-h
+
## begin gnulib module at-internal
ifeq (,$(OMIT_GNULIB_MODULE_at-internal))
diff --git a/lib/malloc/dynarray.h b/lib/malloc/dynarray.h
index f16fd950df6..df1aa4167dd 100644
--- a/lib/malloc/dynarray.h
+++ b/lib/malloc/dynarray.h
@@ -94,7 +94,6 @@
#ifndef _DYNARRAY_H
#define _DYNARRAY_H
-#include <stdbool.h>
#include <stddef.h>
#include <string.h>
diff --git a/lib/md5.c b/lib/md5.c
index 57489ed74c5..c16ac4a93a8 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -27,7 +27,6 @@
#endif
#include "md5.h"
-#include <stdalign.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
diff --git a/lib/mini-gmp.c b/lib/mini-gmp.c
index 95f067f82d6..ea037b801dc 100644
--- a/lib/mini-gmp.c
+++ b/lib/mini-gmp.c
@@ -1,8 +1,9 @@
/* mini-gmp, a minimalistic implementation of a GNU GMP subset.
Contributed to the GNU project by Niels Möller
+ Additional functionalities and improvements by Marco Bodrato.
-Copyright 1991-1997, 1999-2021 Free Software Foundation, Inc.
+Copyright 1991-1997, 1999-2022 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -3098,7 +3099,7 @@ mpz_powm (mpz_t r, const mpz_t b, const mpz_t e, const mpz_t m)
if (en == 0)
{
- mpz_set_ui (r, 1);
+ mpz_set_ui (r, mpz_cmpabs_ui (m, 1));
return;
}
diff --git a/lib/nanosleep.c b/lib/nanosleep.c
index 446794edc0b..55d6fa650e3 100644
--- a/lib/nanosleep.c
+++ b/lib/nanosleep.c
@@ -23,9 +23,7 @@
#include <time.h>
#include "intprops.h"
-#include "verify.h"
-#include <stdbool.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/select.h>
@@ -59,7 +57,7 @@ nanosleep (const struct timespec *requested_delay,
{
/* Verify that time_t is large enough. */
- verify (TYPE_MAXIMUM (time_t) / 24 / 24 / 60 / 60);
+ static_assert (TYPE_MAXIMUM (time_t) / 24 / 24 / 60 / 60);
const time_t limit = 24 * 24 * 60 * 60;
time_t seconds = requested_delay->tv_sec;
struct timespec intermediate;
diff --git a/lib/nstrftime.c b/lib/nstrftime.c
index c1dd5542478..37034eb9fb7 100644
--- a/lib/nstrftime.c
+++ b/lib/nstrftime.c
@@ -65,7 +65,6 @@ extern char *tzname[];
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#include <stdbool.h>
#include "attribute.h"
#include <intprops.h>
diff --git a/lib/openat.h b/lib/openat.h
index 56919ef8dc4..c2f64ff50e2 100644
--- a/lib/openat.h
+++ b/lib/openat.h
@@ -24,7 +24,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <stdbool.h>
#ifndef _GL_INLINE_HEADER_BEGIN
#error "Please include config.h first."
diff --git a/lib/pipe2.c b/lib/pipe2.c
index 400aff001a2..a3cbb7f2611 100644
--- a/lib/pipe2.c
+++ b/lib/pipe2.c
@@ -23,7 +23,6 @@
#include <fcntl.h>
#include "binary-io.h"
-#include "verify.h"
#if GNULIB_defined_O_NONBLOCK
# include "nonblocking.h"
@@ -95,7 +94,7 @@ pipe2 (int fd[2], int flags)
}
# else
{
- verify (O_NONBLOCK == 0);
+ static_assert (O_NONBLOCK == 0);
}
# endif
diff --git a/lib/rawmemchr.c b/lib/rawmemchr.c
index ea68c1bfc6a..bdd7307de4b 100644
--- a/lib/rawmemchr.c
+++ b/lib/rawmemchr.c
@@ -23,10 +23,8 @@
#if !HAVE_RAWMEMCHR
# include <limits.h>
-# include <stdalign.h>
# include <stdint.h>
-# include "verify.h"
/* Find the first occurrence of C in S. */
void *
@@ -36,7 +34,7 @@ rawmemchr (const void *s, int c_in)
typedef uintptr_t longword;
/* If you change the "uintptr_t", you should change UINTPTR_WIDTH to match.
This verifies that the type does not have padding bits. */
- verify (UINTPTR_WIDTH == UCHAR_WIDTH * sizeof (longword));
+ static_assert (UINTPTR_WIDTH == UCHAR_WIDTH * sizeof (longword));
const unsigned char *char_ptr;
unsigned char c = c_in;
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 57a455b1f43..784d2d45866 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -29,7 +29,6 @@
#include <locale.h>
#include <wchar.h>
#include <wctype.h>
-#include <stdbool.h>
#include <stdint.h>
#ifndef _LIBC
diff --git a/lib/sha1.c b/lib/sha1.c
index 79e50ba0b03..5a18213edc1 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -29,7 +29,6 @@
#endif
#include "sha1.h"
-#include <stdalign.h>
#include <stdint.h>
#include <string.h>
diff --git a/lib/sha256.c b/lib/sha256.c
index c9ca618c67e..60cd763612d 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -28,7 +28,6 @@
#endif
#include "sha256.h"
-#include <stdalign.h>
#include <stdint.h>
#include <string.h>
diff --git a/lib/sha512.c b/lib/sha512.c
index 6776bb464d8..fd17a7dc760 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -28,7 +28,6 @@
#endif
#include "sha512.h"
-#include <stdalign.h>
#include <stdint.h>
#include <string.h>
diff --git a/lib/signal.in.h b/lib/signal.in.h
index 640b5022f5f..c0d4848db0a 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -55,13 +55,21 @@
#ifndef _@GUARD_PREFIX@_SIGNAL_H
#define _@GUARD_PREFIX@_SIGNAL_H
-/* Mac OS X 10.3, FreeBSD 6.4, OpenBSD 3.8, OSF/1 4.0, Solaris 2.6, Android,
+/* For testing the OpenBSD version. */
+#if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \
+ && defined __OpenBSD__
+# include <sys/param.h>
+#endif
+
+/* Mac OS X 10.3, FreeBSD < 8.0, OpenBSD < 5.1, OSF/1 4.0, Solaris 2.6, Android,
OS/2 kLIBC declare pthread_sigmask in <pthread.h>, not in <signal.h>.
But avoid namespace pollution on glibc systems.*/
#if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \
&& ((defined __APPLE__ && defined __MACH__) \
- || defined __FreeBSD__ || defined __OpenBSD__ || defined __osf__ \
- || defined __sun || defined __ANDROID__ || defined __KLIBC__) \
+ || (defined __FreeBSD__ && __FreeBSD__ < 8) \
+ || (defined __OpenBSD__ && OpenBSD < 201205) \
+ || defined __osf__ || defined __sun || defined __ANDROID__ \
+ || defined __KLIBC__) \
&& ! defined __GLIBC__
# include <pthread.h>
#endif
diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h
index 3b117df11fe..58fd245c627 100644
--- a/lib/stdalign.in.h
+++ b/lib/stdalign.in.h
@@ -42,10 +42,7 @@
'-malign-double' is used.
The result cannot be used as a value for an 'enum' constant, if you
- want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc.
-
- Include <stddef.h> for offsetof. */
-#include <stddef.h>
+ want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */
/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
standard headers, defines conflicting implementations of _Alignas
@@ -61,17 +58,19 @@
&& !defined __clang__) \
|| (defined __clang__ && __clang_major__ < 8))
# ifdef __cplusplus
-# if 201103 <= __cplusplus
+# if (201103 <= __cplusplus || defined _MSC_VER)
# define _Alignof(type) alignof (type)
# else
template <class __t> struct __alignof_helper { char __a; __t __b; };
# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
+# define _GL_STDALIGN_NEEDS_STDDEF 1
# endif
# else
# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
+# define _GL_STDALIGN_NEEDS_STDDEF 1
# endif
#endif
-#if ! (defined __cplusplus && 201103 <= __cplusplus)
+#if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
# define alignof _Alignof
#endif
#define __alignof_is_defined 1
@@ -102,7 +101,7 @@
*/
#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
-# if defined __cplusplus && 201103 <= __cplusplus
+# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)
# define _Alignas(a) alignas (a)
# elif (!defined __attribute__ \
&& ((defined __APPLE__ && defined __MACH__ \
@@ -116,12 +115,19 @@
# define _Alignas(a) __declspec (align (a))
# endif
#endif
-#if ((defined _Alignas && ! (defined __cplusplus && 201103 <= __cplusplus)) \
+#if ((defined _Alignas \
+ && !(defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \
|| (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
# define alignas _Alignas
#endif
-#if defined alignas || (defined __cplusplus && 201103 <= __cplusplus)
+#if (defined alignas \
+ || (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)))
# define __alignas_is_defined 1
#endif
+/* Include <stddef.h> if needed for offsetof. */
+#if _GL_STDALIGN_NEEDS_STDDEF
+# include <stddef.h>
+#endif
+
#endif /* _GL_STDALIGN_H */
diff --git a/lib/stdckdint.in.h b/lib/stdckdint.in.h
index 90fa62e5966..762d3fdb790 100644
--- a/lib/stdckdint.in.h
+++ b/lib/stdckdint.in.h
@@ -20,8 +20,6 @@
#include "intprops-internal.h"
-#include <stdbool.h>
-
/* Store into *R the low-order bits of A + B, A - B, A * B, respectively.
Return 1 if the result overflows, 0 otherwise.
A, B, and *R can have any integer type other than char, bool, a
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index a86643c3ca3..8e0a609f1f7 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -226,7 +226,7 @@ _GL_FUNCDECL_SYS (aligned_alloc, void *,
_GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
# endif
# endif
-# if @HAVE_ALIGNED_ALLOC@
+# if (__GLIBC__ >= 2) && @HAVE_ALIGNED_ALLOC@
_GL_CXXALIASWARN (aligned_alloc);
# endif
#else
@@ -1363,7 +1363,9 @@ _GL_CXXALIAS_SYS (strtol, long,
(const char *restrict string, char **restrict endptr,
int base));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (strtol);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef strtol
# if HAVE_RAW_DECL_STRTOL
@@ -1444,7 +1446,9 @@ _GL_CXXALIAS_SYS (strtoul, unsigned long,
(const char *restrict string, char **restrict endptr,
int base));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (strtoul);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef strtoul
# if HAVE_RAW_DECL_STRTOUL
diff --git a/lib/string.in.h b/lib/string.in.h
index 3996da9fcb5..e56f6db0c9c 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -943,7 +943,9 @@ _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (mbslen);
+# endif
#endif
#if @GNULIB_MBSNLEN@
diff --git a/lib/strtoimax.c b/lib/strtoimax.c
index cad12d0d9be..29d16d29cef 100644
--- a/lib/strtoimax.c
+++ b/lib/strtoimax.c
@@ -25,8 +25,6 @@
#include <stdlib.h>
-#include "verify.h"
-
#ifdef UNSIGNED
# ifndef HAVE_DECL_STRTOULL
"this configure-time declaration test was not run"
@@ -62,8 +60,8 @@ long long int strtoll (char const *, char **, int);
Int
Strtoimax (char const *ptr, char **endptr, int base)
{
- verify (sizeof (Int) == sizeof (Unsigned long int)
- || sizeof (Int) == sizeof (Unsigned long long int));
+ static_assert (sizeof (Int) == sizeof (Unsigned long int)
+ || sizeof (Int) == sizeof (Unsigned long long int));
if (sizeof (Int) != sizeof (Unsigned long int))
return Strtoll (ptr, endptr, base);
diff --git a/lib/sys_random.in.h b/lib/sys_random.in.h
index e730e6139f8..c91bcd2cd04 100644
--- a/lib/sys_random.in.h
+++ b/lib/sys_random.in.h
@@ -84,7 +84,9 @@ _GL_FUNCDECL_SYS (getrandom, ssize_t,
_GL_CXXALIAS_SYS (getrandom, ssize_t,
(void *buffer, size_t length, unsigned int flags));
# endif
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 25) > 2
_GL_CXXALIASWARN (getrandom);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef getrandom
# if HAVE_RAW_DECL_GETRANDOM
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h
index 2bd0e0f79a8..860e957fe0f 100644
--- a/lib/sys_select.in.h
+++ b/lib/sys_select.in.h
@@ -82,9 +82,10 @@
of 'struct timeval', and no definition of this type.
Also, Mac OS X, AIX, HP-UX, IRIX, Solaris, Interix declare select()
in <sys/time.h>.
- But avoid namespace pollution on glibc systems and "unknown type
- name" problems on Cygwin. */
-# if !(defined __GLIBC__ || defined __CYGWIN__)
+ But avoid namespace pollution on glibc systems, a circular include
+ <sys/select.h> -> <sys/time.h> -> <sys/select.h> on FreeBSD 13.1, and
+ "unknown type name" problems on Cygwin. */
+# if !(defined __GLIBC__ || defined __FreeBSD__ || defined __CYGWIN__)
# include <sys/time.h>
# endif
@@ -287,7 +288,9 @@ _GL_CXXALIAS_SYS_CAST (pselect, int,
struct timespec const *restrict,
const sigset_t *restrict));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (pselect);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef pselect
# if HAVE_RAW_DECL_PSELECT
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 714c3cb189e..0ec320f58c0 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -596,44 +596,6 @@ _GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
#endif
-#if @GNULIB_LSTAT@
-# if ! @HAVE_LSTAT@
-/* mingw does not support symlinks, therefore it does not have lstat. But
- without links, stat does just fine. */
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define lstat stat
-# endif
-_GL_CXXALIAS_RPL_1 (lstat, stat, int,
- (const char *restrict name, struct stat *restrict buf));
-# elif @REPLACE_LSTAT@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef lstat
-# define lstat rpl_lstat
-# endif
-_GL_FUNCDECL_RPL (lstat, int,
- (const char *restrict name, struct stat *restrict buf)
- _GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_RPL (lstat, int,
- (const char *restrict name, struct stat *restrict buf));
-# else
-_GL_CXXALIAS_SYS (lstat, int,
- (const char *restrict name, struct stat *restrict buf));
-# endif
-# if @HAVE_LSTAT@
-_GL_CXXALIASWARN (lstat);
-# endif
-#elif @GNULIB_OVERRIDES_STRUCT_STAT@
-# undef lstat
-# define lstat lstat_used_without_requesting_gnulib_module_lstat
-#elif defined GNULIB_POSIXCHECK
-# undef lstat
-# if HAVE_RAW_DECL_LSTAT
-_GL_WARN_ON_USE (lstat, "lstat is unportable - "
- "use gnulib module lstat for portability");
-# endif
-#endif
-
-
#if @GNULIB_MKDIR@
# if @REPLACE_MKDIR@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -895,6 +857,44 @@ _GL_WARN_ON_USE (stat, "stat is unportable - "
#endif
+#if @GNULIB_LSTAT@
+# if ! @HAVE_LSTAT@
+/* mingw does not support symlinks, therefore it does not have lstat. But
+ without links, stat does just fine. */
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define lstat stat
+# endif
+_GL_CXXALIAS_RPL_1 (lstat, stat, int,
+ (const char *restrict name, struct stat *restrict buf));
+# elif @REPLACE_LSTAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef lstat
+# define lstat rpl_lstat
+# endif
+_GL_FUNCDECL_RPL (lstat, int,
+ (const char *restrict name, struct stat *restrict buf)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (lstat, int,
+ (const char *restrict name, struct stat *restrict buf));
+# else
+_GL_CXXALIAS_SYS (lstat, int,
+ (const char *restrict name, struct stat *restrict buf));
+# endif
+# if @HAVE_LSTAT@
+_GL_CXXALIASWARN (lstat);
+# endif
+#elif @GNULIB_OVERRIDES_STRUCT_STAT@
+# undef lstat
+# define lstat lstat_used_without_requesting_gnulib_module_lstat
+#elif defined GNULIB_POSIXCHECK
+# undef lstat
+# if HAVE_RAW_DECL_LSTAT
+_GL_WARN_ON_USE (lstat, "lstat is unportable - "
+ "use gnulib module lstat for portability");
+# endif
+#endif
+
+
#if @GNULIB_MDA_UMASK@
/* On native Windows, map 'umask' to '_umask', so that -loldnames is not
required. In C++ with GNULIB_NAMESPACE, avoid differences between
diff --git a/lib/tempname.c b/lib/tempname.c
index 11b4796b34b..dbff638f701 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -20,7 +20,6 @@
# include "tempname.h"
#endif
-#include <stdbool.h>
#include <errno.h>
#include <stdio.h>
diff --git a/lib/time.in.h b/lib/time.in.h
index 6d4c7719636..6aa67498f57 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -435,8 +435,10 @@ _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
# endif
# if defined GNULIB_POSIXCHECK
# undef asctime_r
+# if HAVE_RAW_DECL_ASCTIME_R
_GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - "
"better use strftime (or even sprintf) instead");
+# endif
# endif
# if defined GNULIB_POSIXCHECK
# undef ctime
@@ -445,8 +447,10 @@ _GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - "
# endif
# if defined GNULIB_POSIXCHECK
# undef ctime_r
+# if HAVE_RAW_DECL_CTIME_R
_GL_WARN_ON_USE (ctime_r, "ctime_r can overrun buffers in some cases - "
"better use strftime (or even sprintf) instead");
+# endif
# endif
#endif
diff --git a/lib/time_rz.c b/lib/time_rz.c
index 1a91d3778e7..601ce5950e8 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -27,7 +27,6 @@
#include <time.h>
#include <errno.h>
-#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 57df09ecdf4..50f6e56550e 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1143,7 +1143,9 @@ _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
# endif
_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (getdomainname);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef getdomainname
# if HAVE_RAW_DECL_GETDOMAINNAME
@@ -2055,7 +2057,7 @@ _GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
# else
# if defined __hpux /* HP-UX */
_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
-# elif defined __sun && !defined _XPG4 /* Solaris */
+# elif defined __sun && (defined __SunOS_5_10 || defined __XOPEN_OR_POSIX) && !defined _XPG4 /* Solaris */
_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
# else
_GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
diff --git a/lib/utimens.c b/lib/utimens.c
index 2fa12518507..23b91809354 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -26,7 +26,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <stdbool.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
diff --git a/lib/verify.h b/lib/verify.h
index 47b6ee661b3..99af802993e 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -25,19 +25,19 @@
works as per C11. This is supported by GCC 4.6.0+ and by clang 4+.
Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as
- per C2x. This is supported by GCC 9.1+.
+ per C23. This is supported by GCC 9.1+.
Support compilers claiming conformance to the relevant standard,
and also support GCC when not pedantic. If we were willing to slow
'configure' down we could also use it with other compilers, but
since this affects only the quality of diagnostics, why bother? */
#ifndef __cplusplus
-# if (201112L <= __STDC_VERSION__ \
+# if (201112 <= __STDC_VERSION__ \
|| (!defined __STRICT_ANSI__ \
&& (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 5 <= __clang_major__)))
# define _GL_HAVE__STATIC_ASSERT 1
# endif
-# if (202000L <= __STDC_VERSION__ \
+# if (202000 <= __STDC_VERSION__ \
|| (!defined __STRICT_ANSI__ && 9 <= __GNUC__))
# define _GL_HAVE__STATIC_ASSERT1 1
# endif
@@ -202,12 +202,12 @@ template <int w>
This macro requires three or more arguments but uses at most the first
two, so that the _Static_assert macro optionally defined below supports
- both the C11 two-argument syntax and the C2x one-argument syntax.
+ both the C11 two-argument syntax and the C23 one-argument syntax.
Unfortunately, unlike C11, this implementation must appear as an
ordinary declaration, and cannot appear inside struct { ... }. */
-#if 200410 <= __cpp_static_assert
+#if 202311 <= __STDC_VERSION__ || 200410 <= __cpp_static_assert
# define _GL_VERIFY(R, DIAGNOSTIC, ...) static_assert (R, DIAGNOSTIC)
#elif defined _GL_HAVE__STATIC_ASSERT
# define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC)
@@ -223,11 +223,30 @@ template <int w>
/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
#ifdef _GL_STATIC_ASSERT_H
# if !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert
-# define _Static_assert(...) \
- _GL_VERIFY (__VA_ARGS__, "static assertion failed", -)
+# define _Static_assert(R, ...) \
+ _GL_VERIFY ((R), "static assertion failed", -)
# endif
-# if __cpp_static_assert < 201411 && !defined static_assert
-# define static_assert _Static_assert /* C11 requires this #define. */
+# if (!defined static_assert \
+ && __STDC_VERSION__ < 202311 \
+ && (!defined __cplusplus \
+ || (__cpp_static_assert < 201411 \
+ && __GNUG__ < 6 && __clang_major__ < 6)))
+# if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__
+/* MSVC 14 in C++ mode supports the two-arguments static_assert but not
+ the one-argument static_assert, and it does not support _Static_assert.
+ We have to play preprocessor tricks to distinguish the two cases.
+ Since the MSVC preprocessor is not ISO C compliant (cf.
+ <https://stackoverflow.com/questions/5134523/>), the solution is specific
+ to MSVC. */
+# define _GL_EXPAND(x) x
+# define _GL_SA1(a1) static_assert ((a1), "static assertion failed")
+# define _GL_SA2 static_assert
+# define _GL_SA3 static_assert
+# define _GL_SA_PICK(x1,x2,x3,x4,...) x4
+# define static_assert(...) _GL_EXPAND(_GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1)) (__VA_ARGS__)
+# else
+# define static_assert _Static_assert /* C11 requires this #define. */
+# endif
# endif
#endif
@@ -303,7 +322,7 @@ template <int w>
# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
#elif 1200 <= _MSC_VER
# define assume(R) __assume (R)
-#elif 202311L <= __STDC_VERSION__
+#elif 202311 <= __STDC_VERSION__
# include <stddef.h>
# define assume(R) ((R) ? (void) 0 : unreachable ())
#elif (defined GCC_LINT || defined lint) && _GL_HAS_BUILTIN_TRAP