2024-10-29 Paul Eggert <eggert@cs.ucla.edu>
+ malloc, realloc: sync from Autoconf master
+ * m4/malloc.m4 (_AC_FUNC_MALLOC_IF):
+ * m4/realloc.m4 (_AC_FUNC_REALLOC_IF):
+ Sync from bleeding-edge Autoconf. All uses changed.
+
malloc: fix recent doc bug for AIX 7.3
* doc/posix-functions/malloc.texi: Undo previous change,
as _LINUX_SOURCE_COMPAT no longer affects malloc on AIX 7.3.
# eealloc.m4
-# serial 3
+# serial 4
dnl Copyright (C) 2003, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
[
_AC_FUNC_MALLOC_IF(
[gl_cv_func_malloc_0_nonnull=1],
- [gl_cv_func_malloc_0_nonnull=0])
+ [gl_cv_func_malloc_0_nonnull=0],
+ [$gl_cross_guess_normal])
AC_DEFINE_UNQUOTED([MALLOC_0_IS_NONNULL], [$gl_cv_func_malloc_0_nonnull],
[If malloc(0) is != NULL, define this to 1. Otherwise define this
to 0.])
[
_AC_FUNC_REALLOC_IF(
[gl_cv_func_realloc_0_nonnull=1],
- [gl_cv_func_realloc_0_nonnull=0])
+ [gl_cv_func_realloc_0_nonnull=0],
+ [$gl_cross_guess_normal])
AC_DEFINE_UNQUOTED([REALLOC_0_IS_NONNULL], [$gl_cv_func_realloc_0_nonnull],
[If realloc(NULL,0) is != NULL, define this to 1. Otherwise define this
to 0.])
# malloc.m4
-# serial 35
+# serial 36
dnl Copyright (C) 2007, 2009-2024 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.
dnl This file is offered as-is, without any warranty.
-# This is adapted with modifications from upstream Autoconf here:
-# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n949
+m4_version_prereq([2.73], [], [
+# This is copied from upstream Autoconf here:
+# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=74df3c673320c06481f5c5b18ff7979a3034a9e5#n971
+# _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT, UNKNOWN-ASSUME)
+# ----------------------------------------------------
+# If 'malloc (0, 0)' returns nonnull, run IF-WORKS, otherwise, IF-NOT.
+# If it is not known whether it works, assume the shell word UNKNOWN-ASSUME,
+# which should end in "yes" or in something else.
AC_DEFUN([_AC_FUNC_MALLOC_IF],
[
AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <stdlib.h>
- ]],
- [[void *p = malloc (0);
- void * volatile vp = p;
- int result = !vp;
+ /* Use pmalloc to test; 'volatile' prevents the compiler
+ from optimizing the malloc call away. */
+ void *(*volatile pmalloc) (size_t) = malloc;]],
+ [[void *p = pmalloc (0);
+ int result = !p;
free (p);
return result;]])
],
| gnu* | *-musl* | midipix* | midnightbsd* \
| hpux* | solaris* | cygwin* | mingw* | windows* | msys* )
ac_cv_func_malloc_0_nonnull="guessing yes" ;;
- # If we don't know, obey --enable-cross-guesses.
- *) ac_cv_func_malloc_0_nonnull="$gl_cross_guess_normal" ;;
+ # Guess as follows if we don't know.
+ *) ac_cv_func_malloc_0_nonnull=$3 ;;
esac
])
])
AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2])
])# _AC_FUNC_MALLOC_IF
+])
# gl_FUNC_MALLOC_GNU
# ------------------
REPLACE_MALLOC_FOR_MALLOC_GNU="$REPLACE_MALLOC_FOR_MALLOC_POSIX"
if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 0; then
- _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC_FOR_MALLOC_GNU=1])
+ _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC_FOR_MALLOC_GNU=1],
+ [$gl_cross_guess_normal])
fi
])
# realloc.m4
-# serial 34
+# serial 35
dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
[test -n "$gl_cv_func_realloc_sanitize" || gl_cv_func_realloc_sanitize=no])
])
-# This is adapted with modifications from upstream Autoconf here:
-# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n1455
+m4_version_prereq([2.73], [], [
+# This is copied from upstream Autoconf here:
+# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=74df3c673320c06481f5c5b18ff7979a3034a9e5#n1487
+# _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT, UNKNOWN-ASSUME)
+# -----------------------------------------------------
+# If 'realloc (0, 0)' returns nonnull, run IF-WORKS, otherwise, IF-NOT.
+# If it is not known whether it works, assume the shell word UNKNOWN-ASSUME,
+# which should end in "yes" or in something else.
AC_DEFUN([_AC_FUNC_REALLOC_IF],
[
AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <stdlib.h>
- ]],
- [[void *p = realloc (0, 0);
- void * volatile vp = p;
- int result = !vp;
+ /* Use prealloc to test; 'volatile' prevents the compiler
+ from optimizing the realloc call away. */
+ void *(*volatile prealloc) (void *, size_t) = realloc;]],
+ [[void *p = prealloc (0, 0);
+ int result = !p;
free (p);
return result;]])
],
| gnu* | *-musl* | midipix* | midnightbsd* \
| hpux* | solaris* | cygwin* | mingw* | windows* | msys* )
ac_cv_func_realloc_0_nonnull="guessing yes" ;;
- # If we don't know, obey --enable-cross-guesses.
- *) ac_cv_func_realloc_0_nonnull="$gl_cross_guess_normal" ;;
+ # Guess as follows if we don't know.
+ *) ac_cv_func_realloc_0_nonnull=$3 ;;
esac
])
])
AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2])
-])# AC_FUNC_REALLOC
+])# _AC_FUNC_REALLOC_IF
+])
# gl_FUNC_REALLOC_POSIX
# ---------------------