On 12/19/20 5:53 AM, Bruno Haible wrote:
I'm adding a unit test for the "free() preserves errno" feature.

Thanks. Unfortunately the test fails on Ubuntu 20.10 (and I assume on other GNU/Linux hosts). So I installed the attached patch to port the free-posix module to GNU/Linux (!).

Perhaps someday we can move the test to m4/free.m4 with AC_RUN_IFELSE, but there's no rush if the problem is ubiquitous.
From 2b672a7f406a0925cdbbfda5ad6ce147da00d856 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 19 Dec 2020 08:14:38 -0800
Subject: [PATCH] free-posix: port to GNU/Linux
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* m4/free.m4 (gl_FUNC_FREE): Don’t assume GNU hosts are free of
the bug, as it occurs on Ubuntu 20.10 x86-64 and, I assume, on
other GNU/Linux hosts.
---
 ChangeLog  |  7 +++++++
 m4/free.m4 | 28 +++++++++++-----------------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5a7bb6d59..ef9ec28a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-12-19  Paul Eggert  <egg...@cs.ucla.edu>
+
+	free-posix: port to GNU/Linux
+	* m4/free.m4 (gl_FUNC_FREE): Don’t assume GNU hosts are free of
+	the bug, as it occurs on Ubuntu 20.10 x86-64 and, I assume, on
+	other GNU/Linux hosts.
+
 2020-12-19  Bruno Haible  <br...@clisp.org>
 
 	free-posix: Add tests.
diff --git a/m4/free.m4 b/m4/free.m4
index fb191df1e..e7a72039e 100644
--- a/m4/free.m4
+++ b/m4/free.m4
@@ -1,4 +1,4 @@
-# free.m4 serial 2
+# free.m4 serial 3
 # Copyright (C) 2003-2005, 2009-2020 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,6 @@
 AC_DEFUN([gl_FUNC_FREE],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
-  AC_REQUIRE([AC_CANONICAL_HOST])
 
   dnl In the next release of POSIX, free must preserve errno.
   dnl https://www.austingroupbugs.net/view.php?id=385
@@ -19,21 +18,16 @@ AC_DEFUN([gl_FUNC_FREE],
   dnl whatever that happens to be.
   AC_CACHE_CHECK([whether free is known to preserve errno],
     [gl_cv_func_free_preserves_errno],
-    [case $host_os in
-       *-gnu* | gnu*)
-         gl_cv_func_free_preserves_errno=yes;;
-       *)
-         AC_COMPILE_IFELSE(
-           [AC_LANG_PROGRAM(
-              [[#include <unistd.h>
-              ]],
-              [[#if _POSIX_VERSION <= 200809
-                  #error "'free' is not known to preserve errno"
-                #endif
-              ]])],
-           [gl_cv_func_free_preserves_errno=yes],
-           [gl_cv_func_free_preserves_errno=no]);;
-     esac
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <unistd.h>
+          ]],
+          [[#if _POSIX_VERSION <= 200809
+              #error "'free' is not known to preserve errno"
+            #endif
+          ]])],
+       [gl_cv_func_free_preserves_errno=yes],
+       [gl_cv_func_free_preserves_errno=no])
     ])
 
   case $gl_cv_func_free_preserves_errno in
-- 
2.27.0

Reply via email to