From c08e261c39ef3840b1cb1ae7c04c669c469cd91d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 18 Apr 2021 11:23:24 -0700 Subject: [PATCH 1/2] malloc-gnu, etc.: sync better with Autoconf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * m4/calloc.m4 (_AC_FUNC_CALLOC_IF): * m4/malloc.m4 (_AC_FUNC_MALLOC_IF): * m4/realloc.m4 (_AC_FUNC_REALLOC_IF): Avoid some unnecessary differences from Autoconf’s versions. Separate our platforms into a different line so that it’s easier to diff. Use AS_IF in case the args use AC_REQUIRE. However, don’t bother with omitting the first newline, as omitting the newline is not Gnulib style and the difference doesn’t seem to matter here. --- ChangeLog | 13 +++++++++++++ m4/calloc.m4 | 15 +++++---------- m4/malloc.m4 | 24 ++++++++++-------------- m4/realloc.m4 | 24 ++++++++++-------------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 38311496b..fa630a758 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2021-04-18 Paul Eggert + + malloc-gnu, etc.: sync better with Autoconf + * m4/calloc.m4 (_AC_FUNC_CALLOC_IF): + * m4/malloc.m4 (_AC_FUNC_MALLOC_IF): + * m4/realloc.m4 (_AC_FUNC_REALLOC_IF): + Avoid some unnecessary differences from Autoconf’s versions. + Separate our platforms into a different line so that it’s easier + to diff. Use AS_IF in case the args use AC_REQUIRE. + However, don’t bother with omitting the first newline, as + omitting the newline is not Gnulib style and the difference + doesn’t seem to matter here. + 2021-04-18 Bruno Haible malloc-posix, realloc-posix, calloc-posix: Document affected platforms. diff --git a/m4/calloc.m4 b/m4/calloc.m4 index 143f3bc3f..776979d25 100644 --- a/m4/calloc.m4 +++ b/m4/calloc.m4 @@ -1,4 +1,4 @@ -# calloc.m4 serial 24 +# calloc.m4 serial 25 # Copyright (C) 2004-2021 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -16,7 +16,8 @@ # ------------------------------------- # If calloc is compatible with GNU calloc, run IF-WORKS, otherwise, IF-NOT. AC_DEFUN([_AC_FUNC_CALLOC_IF], -[ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([whether calloc (0, n) and calloc (n, 0) return nonnull], [ac_cv_func_calloc_0_nonnull], [if test $cross_compiling != yes; then @@ -46,14 +47,8 @@ AC_DEFUN([_AC_FUNC_CALLOC_IF], esac fi ]) - case "$ac_cv_func_calloc_0_nonnull" in - *yes) - $1 - ;; - *) - $2 - ;; - esac + AS_IF([case $ac_cv_func_calloc_0_nonnull in *yes) :;; *) false;; esac], + [$1], [$2]) ]) diff --git a/m4/malloc.m4 b/m4/malloc.m4 index 503da2cf8..9734dab05 100644 --- a/m4/malloc.m4 +++ b/m4/malloc.m4 @@ -1,20 +1,21 @@ -# malloc.m4 serial 23 +# malloc.m4 serial 24 dnl Copyright (C) 2007, 2009-2021 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. # This is adapted with modifications from upstream Autoconf here: -# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=04be2b7a29d65d9a08e64e8e56e594c91749598c +# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n949 AC_DEFUN([_AC_FUNC_MALLOC_IF], -[ AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles +[ + AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles AC_CACHE_CHECK([whether malloc (0) returns nonnull], [ac_cv_func_malloc_0_nonnull], [AC_RUN_IFELSE( [AC_LANG_PROGRAM( [[#include ]], - [[char *p = malloc (0); + [[void *p = malloc (0); int result = !p; free (p); return result;]]) @@ -23,22 +24,17 @@ AC_DEFUN([_AC_FUNC_MALLOC_IF], [ac_cv_func_malloc_0_nonnull=no], [case "$host_os" in # Guess yes on platforms where we know the result. - *-gnu* | gnu* | *-musl* | freebsd* | midnightbsd* | netbsd* | openbsd* \ - | hpux* | solaris* | cygwin* | mingw*) + *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ + | gnu* | *-musl* | midnightbsd* \ + | hpux* | solaris* | cygwin* | mingw* | 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" ;; esac ]) ]) - case "$ac_cv_func_malloc_0_nonnull" in - *yes) - $1 - ;; - *) - $2 - ;; - esac + AS_IF([case $ac_cv_func_malloc_0_nonnull in *yes) :;; *) false;; esac], + [$1], [$2]) ])# _AC_FUNC_MALLOC_IF # gl_FUNC_MALLOC_GNU diff --git a/m4/realloc.m4 b/m4/realloc.m4 index 4939516a0..cde906192 100644 --- a/m4/realloc.m4 +++ b/m4/realloc.m4 @@ -1,20 +1,21 @@ -# realloc.m4 serial 21 +# realloc.m4 serial 22 dnl Copyright (C) 2007, 2009-2021 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. # This is adapted with modifications from upstream Autoconf here: -# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=04be2b7a29d65d9a08e64e8e56e594c91749598c +# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n1455 AC_DEFUN([_AC_FUNC_REALLOC_IF], -[ AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles +[ + AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles AC_CACHE_CHECK([whether realloc (0, 0) returns nonnull], [ac_cv_func_realloc_0_nonnull], [AC_RUN_IFELSE( [AC_LANG_PROGRAM( [[#include ]], - [[char *p = realloc (0, 0); + [[void *p = realloc (0, 0); int result = !p; free (p); return result;]]) @@ -23,22 +24,17 @@ AC_DEFUN([_AC_FUNC_REALLOC_IF], [ac_cv_func_realloc_0_nonnull=no], [case "$host_os" in # Guess yes on platforms where we know the result. - *-gnu* | gnu* | *-musl* | freebsd* | midnightbsd* | netbsd* | openbsd* \ - | hpux* | solaris* | cygwin* | mingw*) + *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ + | gnu* | *-musl* | midnightbsd* \ + | hpux* | solaris* | cygwin* | mingw* | 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" ;; esac ]) ]) - case "$ac_cv_func_realloc_0_nonnull" in - *yes) - $1 - ;; - *) - $2 - ;; - esac + AS_IF([case $ac_cv_func_realloc_0_nonnull in *yes) :;; *) false;; esac], + [$1], [$2]) ])# AC_FUNC_REALLOC # gl_FUNC_REALLOC_GNU -- 2.27.0