These two patches improve the cross-compilation guessing regarding malloc(0).


2024-11-01  Bruno Haible  <br...@clisp.org>

        eealloc: Use the same cross-compilation guess as malloc-posix.
        * m4/eealloc.m4 (gl_EEMALLOC): Invoke gl_CHECK_MALLOC_POSIX, not
        _AC_FUNC_MALLOC_IF.
        * modules/malloca (Files): Add m4/malloc.m4.
        * modules/regex (Files): Likewise.

2024-11-01  Bruno Haible  <br...@clisp.org>

        Improve log output of an Autoconf test.
        * m4/malloc.m4 (gl_CHECK_MALLOC_POSIX): On native Windows, report
        "guessing yes/no".
        (gl_FUNC_MALLOC_POSIX): Update.
        * m4/strdup.m4 (gl_FUNC_STRDUP_POSIX): Likewise.

>From 69e170a84c2f0e722f85b88285b0d4bedcd20063 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Fri, 1 Nov 2024 12:25:22 +0100
Subject: [PATCH 1/2] Improve log output of an Autoconf test.

* m4/malloc.m4 (gl_CHECK_MALLOC_POSIX): On native Windows, report
"guessing yes/no".
(gl_FUNC_MALLOC_POSIX): Update.
* m4/strdup.m4 (gl_FUNC_STRDUP_POSIX): Likewise.
---
 ChangeLog    |  8 ++++++++
 m4/malloc.m4 | 23 +++++++++++++----------
 m4/strdup.m4 |  9 +++++----
 3 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fcf057ebfe..36e34b048d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-11-01  Bruno Haible  <br...@clisp.org>
+
+	Improve log output of an Autoconf test.
+	* m4/malloc.m4 (gl_CHECK_MALLOC_POSIX): On native Windows, report
+	"guessing yes/no".
+	(gl_FUNC_MALLOC_POSIX): Update.
+	* m4/strdup.m4 (gl_FUNC_STRDUP_POSIX): Likewise.
+
 2024-10-31  Paul Eggert  <egg...@cs.ucla.edu>
 
 	malloc, realloc: fix $3 bug
diff --git a/m4/malloc.m4 b/m4/malloc.m4
index 0d4014de44..657eed779c 100644
--- a/m4/malloc.m4
+++ b/m4/malloc.m4
@@ -1,5 +1,5 @@
 # malloc.m4
-# serial 39
+# serial 40
 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,
@@ -119,16 +119,19 @@ AC_DEFUN([gl_FUNC_MALLOC_POSIX]
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MALLOC_PTRDIFF])
   AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
-  if test "$gl_cv_func_malloc_posix" = yes; then
-    AC_DEFINE([HAVE_MALLOC_POSIX], [1],
-      [Define if malloc, realloc, and calloc set errno on allocation failure.])
-  else
-    REPLACE_MALLOC_FOR_MALLOC_POSIX=1
-  fi
+  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.])
+      ;;
+    *)
+      REPLACE_MALLOC_FOR_MALLOC_POSIX=1
+      ;;
+  esac
 ])
 
 # Test whether malloc, realloc, calloc set errno to ENOMEM on failure.
-# Set gl_cv_func_malloc_posix to yes or no accordingly.
+# Set gl_cv_func_malloc_posix to *yes or *no accordingly.
 AC_DEFUN([gl_CHECK_MALLOC_POSIX],
 [
   AC_REQUIRE([AC_CANONICAL_HOST])
@@ -154,8 +157,8 @@ AC_DEFUN([gl_CHECK_MALLOC_POSIX]
               ]],
               [[]])
             ],
-            [gl_cv_func_malloc_posix=yes],
-            [gl_cv_func_malloc_posix=no])
+            [gl_cv_func_malloc_posix="guessing yes"],
+            [gl_cv_func_malloc_posix="guessing no"])
           ;;
         irix* | solaris*)
           dnl On IRIX 6.5, the three functions return NULL with errno unset
diff --git a/m4/strdup.m4 b/m4/strdup.m4
index 33452dca47..d6989b52d4 100644
--- a/m4/strdup.m4
+++ b/m4/strdup.m4
@@ -1,5 +1,5 @@
 # strdup.m4
-# serial 15
+# serial 16
 
 dnl Copyright (C) 2002-2024 Free Software Foundation, Inc.
 
@@ -21,9 +21,10 @@ AC_DEFUN([gl_FUNC_STRDUP_POSIX]
 [
   AC_REQUIRE([gl_STRING_H_DEFAULTS])
   AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
-  if test $gl_cv_func_malloc_posix != yes; then
-    REPLACE_STRDUP=1
-  fi
+  case "$gl_cv_func_malloc_posix" in
+    *yes) ;;
+    *)    REPLACE_STRDUP=1 ;;
+  esac
   AC_CHECK_DECLS_ONCE([strdup])
   if test $ac_cv_have_decl_strdup = no; then
     HAVE_DECL_STRDUP=0
-- 
2.34.1

>From 23d89b19eeb7d4de36a393ba34aa8c1b6573afa2 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Fri, 1 Nov 2024 12:28:05 +0100
Subject: [PATCH 2/2] eealloc: Use the same cross-compilation guess as
 malloc-posix.

* m4/eealloc.m4 (gl_EEMALLOC): Invoke gl_CHECK_MALLOC_POSIX, not
_AC_FUNC_MALLOC_IF.
* modules/malloca (Files): Add m4/malloc.m4.
* modules/regex (Files): Likewise.
---
 ChangeLog       |  8 ++++++++
 m4/eealloc.m4   | 11 ++++++-----
 modules/malloca |  1 +
 modules/regex   |  1 +
 4 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 36e34b048d..87ffe5d70c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-11-01  Bruno Haible  <br...@clisp.org>
+
+	eealloc: Use the same cross-compilation guess as malloc-posix.
+	* m4/eealloc.m4 (gl_EEMALLOC): Invoke gl_CHECK_MALLOC_POSIX, not
+	_AC_FUNC_MALLOC_IF.
+	* modules/malloca (Files): Add m4/malloc.m4.
+	* modules/regex (Files): Likewise.
+
 2024-11-01  Bruno Haible  <br...@clisp.org>
 
 	Improve log output of an Autoconf test.
diff --git a/m4/eealloc.m4 b/m4/eealloc.m4
index 0ad90c687b..ee56f81faa 100644
--- a/m4/eealloc.m4
+++ b/m4/eealloc.m4
@@ -1,5 +1,5 @@
 # eealloc.m4
-# serial 5
+# serial 6
 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,
@@ -14,10 +14,11 @@ AC_DEFUN([gl_EEALLOC]
 
 AC_DEFUN([gl_EEMALLOC],
 [
-  _AC_FUNC_MALLOC_IF(
-    [gl_cv_func_malloc_0_nonnull=1],
-    [gl_cv_func_malloc_0_nonnull=0],
-    ["$gl_cross_guess_normal"])
+  gl_CHECK_MALLOC_POSIX
+  case "$gl_cv_func_malloc_posix" in
+    *yes) gl_cv_func_malloc_0_nonnull=1 ;;
+    *)    gl_cv_func_malloc_0_nonnull=0 ;;
+  esac
   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.])
diff --git a/modules/malloca b/modules/malloca
index 6e5fc8d566..ffa5306a0b 100644
--- a/modules/malloca
+++ b/modules/malloca
@@ -6,6 +6,7 @@ lib/malloca.h
 lib/malloca.c
 m4/malloca.m4
 m4/eealloc.m4
+m4/malloc.m4
 
 Depends-on:
 alloca-opt
diff --git a/modules/regex b/modules/regex
index 1fa0722963..ecbfaf4156 100644
--- a/modules/regex
+++ b/modules/regex
@@ -12,6 +12,7 @@ lib/regex_internal.h
 lib/regexec.c
 lib/regcomp.c
 m4/eealloc.m4
+m4/malloc.m4
 m4/regex.m4
 m4/mbstate_t.m4
 
-- 
2.34.1

Reply via email to