summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2025-12-07 15:34:42 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2025-12-07 15:45:20 -0800
commitb211e5489b95f39f07baa769fc581b05b393c4a3 (patch)
tree34f59c09f3779fdf25f32bccbe8aa48491ee5b4f /m4
parent0d43f2a562c84ff440da978a9275fc44e6f5d9da (diff)
Update from Gnulib by running admin/merge-gnulib
* admin/merge-gnulib (AVOIDED_MODULES): Add strncpy, as Emacs is not likely to exercise the FreeBSD 15 strncpy bug that this module fixes. * lib/issymlinkat.h: New file, taken from Gnulib.
Diffstat (limited to 'm4')
-rw-r--r--m4/extern-inline.m42
-rw-r--r--m4/gnulib-common.m48
-rw-r--r--m4/gnulib-comp.m41
-rw-r--r--m4/malloc.m463
-rw-r--r--m4/realloc.m447
-rw-r--r--m4/stdalign.m44
-rw-r--r--m4/string_h.m46
7 files changed, 90 insertions, 41 deletions
diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4
index 820fbda5ddb..7a63df0340e 100644
--- a/m4/extern-inline.m4
+++ b/m4/extern-inline.m4
@@ -44,7 +44,7 @@ AC_DEFUN([gl_EXTERN_INLINE],
if isdigit is mistakenly implemented via a static inline function,
a program containing an extern inline function that calls isdigit
may not work since C99 through C23 prohibit extern inline functions
- from calling static functions (ISO C 23 section 6.7.5.(2)).
+ from calling static functions (ISO C 23 § 6.7.5 ¶ 3)).
Although a future C standard will likely relax this restriction
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3622.txt>,
respect it for now. This bug is known to occur on:
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 73f56f57fc9..5bb06bed4d3 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -768,7 +768,7 @@ AC_DEFUN([gl_COMMON_BODY], [
addressed by its arguments is the same and is updated in time for
the rest of the program.
This attribute is safe for a function that is effectless and idempotent; see
- ISO C 23 § 6.7.12.7 for a definition of these terms.
+ ISO C 23 § 6.7.13.8 for a definition of these terms.
(This attribute is looser than _GL_ATTRIBUTE_UNSEQUENCED because
the function need not be stateless and idempotent. It is looser
than _GL_ATTRIBUTE_PURE because the function need not return
@@ -776,7 +776,7 @@ AC_DEFUN([gl_COMMON_BODY], [
See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
<https://stackoverflow.com/questions/76847905/>.
ATTENTION! Efforts are underway to change the meaning of this attribute.
- See <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3424.htm>. */
+ See <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3494.htm>. */
/* Applies to: functions, pointer to functions, function types. */
#ifndef _GL_ATTRIBUTE_REPRODUCIBLE
/* This may be revisited when gcc and clang support [[reproducible]] or possibly
@@ -820,7 +820,7 @@ AC_DEFUN([gl_COMMON_BODY], [
calls to the function with the same arguments, so long as the state
addressed by its arguments is the same.
This attribute is safe for a function that is effectless, idempotent,
- stateless, and independent; see ISO C 23 § 6.7.12.7 for a definition of
+ stateless, and independent; see ISO C 23 § 6.7.13.8 for a definition of
these terms.
(This attribute is stricter than _GL_ATTRIBUTE_REPRODUCIBLE because
the function must be stateless and independent. It is looser than
@@ -829,7 +829,7 @@ AC_DEFUN([gl_COMMON_BODY], [
See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
<https://stackoverflow.com/questions/76847905/>.
ATTENTION! Efforts are underway to change the meaning of this attribute.
- See <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3424.htm>. */
+ See <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3494.htm>. */
/* Applies to: functions, pointer to functions, function types. */
#ifndef _GL_ATTRIBUTE_UNSEQUENCED
/* This may be revisited when gcc and clang support [[unsequenced]] or possibly
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 56f1a603ebc..47391071a7c 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -1383,6 +1383,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/issymlink.c
lib/issymlink.h
lib/issymlinkat.c
+ lib/issymlinkat.h
lib/lchmod.c
lib/libc-config.h
lib/limits.in.h
diff --git a/m4/malloc.m4 b/m4/malloc.m4
index 688594fe661..c49c91e0404 100644
--- a/m4/malloc.m4
+++ b/m4/malloc.m4
@@ -1,5 +1,5 @@
# malloc.m4
-# serial 44
+# serial 46
dnl Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -99,7 +99,7 @@ AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF],
[REPLACE_MALLOC_FOR_MALLOC_POSIX=1])
])
-# Test whether malloc, realloc, calloc refuse to create objects
+# Test whether malloc, calloc refuse to create objects
# larger than what can be expressed in ptrdiff_t.
# Set gl_cv_func_malloc_gnu.
AC_DEFUN([gl_CHECK_MALLOC_PTRDIFF],
@@ -148,7 +148,7 @@ AC_DEFUN([gl_FUNC_MALLOC_POSIX],
case "$gl_cv_func_malloc_posix" in
*yes)
AC_DEFINE([HAVE_MALLOC_POSIX], [1],
- [Define if malloc, realloc, and calloc set errno on allocation failure.])
+ [Define if malloc and calloc set errno on allocation failure.])
;;
*)
REPLACE_MALLOC_FOR_MALLOC_POSIX=1
@@ -156,19 +156,20 @@ AC_DEFUN([gl_FUNC_MALLOC_POSIX],
esac
])
-# Test whether malloc, realloc, calloc set errno to ENOMEM on failure.
+# Test whether malloc, calloc set errno to ENOMEM on failure.
# Set gl_cv_func_malloc_posix to *yes or *no accordingly.
AC_DEFUN([gl_CHECK_MALLOC_POSIX],
[
AC_REQUIRE([AC_CANONICAL_HOST])
- AC_CACHE_CHECK([whether malloc, realloc, calloc set errno on failure],
+ AC_CACHE_CHECK([whether malloc, calloc set errno on failure],
[gl_cv_func_malloc_posix],
[
dnl It is too dangerous to try to allocate a large amount of memory:
dnl some systems go to their knees when you do that. So assume that
dnl all Unix implementations of the function set errno on failure,
dnl except on those platforms where we have seen 'test-malloc-gnu',
- dnl 'test-realloc-posix', 'test-calloc-gnu' fail.
+ dnl 'test-realloc-posix', 'test-calloc-gnu' fail. For platforms
+ dnl where only 'test-realloc-posix', see realloc.m4.
case "$host_os" in
mingw* | windows*)
dnl Old MSVCRT from 2001 did not set errno=ENOMEM when malloc failed.
@@ -187,37 +188,41 @@ AC_DEFUN([gl_CHECK_MALLOC_POSIX],
[gl_cv_func_malloc_posix="guessing no"])
;;
solaris*)
- dnl On Solaris 11.3, the three functions return NULL with errno set
+ dnl On Solaris 11.3, the three functions might fail with errno set
dnl to EAGAIN, not ENOMEM, when the argument is larger than
- dnl PTRDIFF_MAX.
+ dnl PTRDIFF_MAX. See:
+ dnl https://lists.gnu.org/r/bug-gnulib/2021-05/msg00052.html
dnl Here is a test program:
+
m4_divert_push([KILL])
#include <errno.h>
+#include <stddef.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
-#define ptrdiff_t long
-#ifndef PTRDIFF_MAX
-# define PTRDIFF_MAX ((ptrdiff_t) ((1UL << (8 * sizeof (ptrdiff_t) - 1)) - 1))
-#endif
-
-int main ()
-{
- void *p;
-
- fprintf (stderr, "PTRDIFF_MAX = %lu\n", (unsigned long) PTRDIFF_MAX);
- errno = 0;
- p = malloc ((unsigned long) PTRDIFF_MAX + 1);
- fprintf (stderr, "p=%p errno=%d\n", p, errno);
-
- errno = 0;
- p = calloc (PTRDIFF_MAX / 2 + 1, 2);
- fprintf (stderr, "p=%p errno=%d\n", p, errno);
-
- errno = 0;
- p = realloc (NULL, (unsigned long) PTRDIFF_MAX + 1);
- fprintf (stderr, "p=%p errno=%d\n", p, errno);
+#define TEST_CALL(call) \
+ do { \
+ void *p = call; \
+ if (p) \
+ fprintf (stderr, "returned %p (incorrect success)\n", p); \
+ else if (errno == ENOMEM) \
+ perror ("correct failure"); \
+ else \
+ perror ("incorrect failure (wrong errno)"); \
+ free (p); \
+ } while (0)
+int
+main ()
+{
+ size_t big = PTRDIFF_MAX;
+ TEST_CALL (malloc (big + 1));
+ TEST_CALL (calloc (big / 2 + 1, 2));
+ TEST_CALL (realloc (NULL, big + 1));
+ void *small = malloc (1);
+ TEST_CALL (realloc (small, big + 1));
+ free (small);
return 0;
}
m4_divert_pop([KILL])
diff --git a/m4/realloc.m4 b/m4/realloc.m4
index 0242abdc8cc..a6c2ec4c33b 100644
--- a/m4/realloc.m4
+++ b/m4/realloc.m4
@@ -1,5 +1,5 @@
# realloc.m4
-# serial 39
+# serial 40
dnl Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -27,13 +27,54 @@ AC_DEFUN([gl_FUNC_REALLOC_POSIX],
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_CACHE_CHECK([whether realloc sets errno on failure],
+ [gl_cv_func_realloc_posix],
+ [
+ dnl FreeBSD 15.0 realloc() does not set errno when asked for more than
+ dnl 0x7000000000000000 bytes.
+ case "$host_os" in
+ darwin* | freebsd* | dragonfly* | midnightbsd* | netbsd* | openbsd*)
+ AC_RUN_IFELSE(
+ [AC_LANG_SOURCE(
+ [[#include <errno.h>
+ #include <stdlib.h>
+ int main (int argc, char **argv)
+ {
+ void *p;
+ errno = 1729;
+ p = realloc (malloc (1), (size_t)(-1) / 100 * 49);
+ return (!p && errno == 1729);
+ }
+ ]])
+ ],
+ [gl_cv_func_realloc_posix=yes],
+ [gl_cv_func_realloc_posix=no],
+ [case "$host_os" in
+ freebsd*) gl_cv_func_realloc_posix="guessing no" ;;
+ *) gl_cv_func_realloc_posix="guessing yes" ;;
+ esac
+ ])
+ ;;
+ *)
+ gl_cv_func_realloc_posix="$gl_cv_func_malloc_posix"
+ ;;
+ esac
+ ])
+ case "$gl_cv_func_realloc_posix" in
+ *yes)
+ AC_DEFINE([HAVE_REALLOC_POSIX], [1],
+ [Define if realloc sets errno on allocation failure.])
+ ;;
+ *)
+ REPLACE_REALLOC_FOR_REALLOC_POSIX=1
+ ;;
+ esac
AC_REQUIRE([gl_FUNC_REALLOC_SANITIZED])
if test "$gl_cv_func_realloc_sanitize" != no; then
REPLACE_REALLOC_FOR_REALLOC_POSIX=1
AC_DEFINE([NEED_SANITIZED_REALLOC], [1],
[Define to 1 if realloc should abort upon undefined behaviour.])
- else
- REPLACE_REALLOC_FOR_REALLOC_POSIX=$REPLACE_MALLOC_FOR_MALLOC_POSIX
fi
])
diff --git a/m4/stdalign.m4 b/m4/stdalign.m4
index d22360e1075..d4a7d92961c 100644
--- a/m4/stdalign.m4
+++ b/m4/stdalign.m4
@@ -82,8 +82,8 @@ AC_DEFUN([gl_ALIGNASOF],
References:
ISO C23 (latest free draft
- <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf>)
- sections 6.5.3.4, 6.7.5, 7.15.
+ <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf>)
+ sections 6.2.8, 6.7.6.
C++11 (latest free draft
<https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>)
section 18.10. */
diff --git a/m4/string_h.m4 b/m4/string_h.m4
index b5324e3a37e..860440123ae 100644
--- a/m4/string_h.m4
+++ b/m4/string_h.m4
@@ -1,5 +1,5 @@
# string_h.m4
-# serial 45
+# serial 46
dnl Copyright (C) 2007-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -24,7 +24,7 @@ AC_DEFUN_ONCE([gl_STRING_H],
]],
[explicit_bzero ffsl ffsll memmem mempcpy memrchr memset_explicit
rawmemchr stpcpy stpncpy strchrnul
- strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r
+ strdup strncat strncpy strndup strnlen strpbrk strsep strcasestr strtok_r
strerror_l strerror_r strerrorname_np
sigabbrev_np sigdescr_np strsignal strverscmp])
@@ -65,6 +65,7 @@ AC_DEFUN([gl_STRING_H_REQUIRE_DEFAULTS],
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRDUP])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRINGEQ])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCAT])
+ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCPY])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNDUP])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNLEN])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPBRK])
@@ -149,6 +150,7 @@ AC_DEFUN([gl_STRING_H_DEFAULTS],
REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL])
REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
+ REPLACE_STRNCPY=0; AC_SUBST([REPLACE_STRNCPY])
REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])