summaryrefslogtreecommitdiff
path: root/gnulib-m4/realloc.m4
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2026-03-08 17:28:33 +0100
committerJörg Frings-Fürst <debian@jff.email>2026-03-08 17:28:33 +0100
commit5f59a34ab747dde8ede7357f3431bf06bd6002fe (patch)
tree056a4477fd870d454d5be5868cddab829a47f4d2 /gnulib-m4/realloc.m4
parent27dae84ed92f1ef0300263091972338d12e78348 (diff)
New upstream version 1.4.2upstream/1.4.2upstream
Diffstat (limited to 'gnulib-m4/realloc.m4')
-rw-r--r--gnulib-m4/realloc.m449
1 files changed, 45 insertions, 4 deletions
diff --git a/gnulib-m4/realloc.m4 b/gnulib-m4/realloc.m4
index 0242abdc..8938db92 100644
--- a/gnulib-m4/realloc.m4
+++ b/gnulib-m4/realloc.m4
@@ -1,6 +1,6 @@
# realloc.m4
-# serial 39
-dnl Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
+# serial 40
+dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -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
])