[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pthread-spin doesn't define HAVE_PTHREAD_H
From: |
Bruno Haible |
Subject: |
Re: pthread-spin doesn't define HAVE_PTHREAD_H |
Date: |
Mon, 08 Apr 2024 12:10:49 +0200 |
Hi Collin,
> When running ./configure in findutils I see this warning:
>
> checking for pthread.h... yes
> ...
> ./configure: line 31218: test: =: unary operator expected
> checking for pthread_spin_init... yes
> checking for pthread_t... yes
> checking for pthread_spinlock_t... yes
>
> Line 31218 is the first line in this block. I believe it is because
> $HAVE_PTHREAD_H expands to nothing:
>
> if test $HAVE_PTHREAD_H = 0 || test $HAVE_PTHREAD_SPINLOCK_T = 0; then
> HAVE_PTHREAD_SPIN_INIT=0
> HAVE_PTHREAD_SPIN_LOCK=0
> HAVE_PTHREAD_SPIN_TRYLOCK=0
> HAVE_PTHREAD_SPIN_UNLOCK=0
> HAVE_PTHREAD_SPIN_DESTROY=0
> else
>
> $ grep -n 'HAVE_PTHREAD_H' configure
> 810:HAVE_PTHREAD_H
> 5111:as_fn_append ac_header_c_list " pthread.h pthread_h HAVE_PTHREAD_H"
> 31218: if test $HAVE_PTHREAD_H = 0 || test $HAVE_PTHREAD_SPINLOCK_T = 0;
> then
> 31368: HAVE_PTHREAD_H=1
> 31373: HAVE_PTHREAD_H=0
> 31377: HAVE_PTHREAD_H=0
> 31382: #if HAVE_PTHREAD_H
> 31394: #if HAVE_PTHREAD_H
> 59474: if test $HAVE_PTHREAD_H = 0; then
Oh, indeed. Thanks for the report. That was a major regression.
> It looks like maybe it is due to this?
>
> commit 4851abd89ce1ed641cc5d601f8764af23f987182
> Author: Bruno Haible <bruno@clisp.org>
> Date: Thu Mar 28 22:05:39 2024 +0100
>
> pthread-h: Fix override of pthread_spinlock_t with non-GNU compilers.
>
> * m4/pthread-spin.m4 (gl_PTHREAD_SPIN): Define through AC_DEFUN_ONCE.
> Require gl_PTHREAD_H_DEFAULTS, not gl_PTHREAD_H.
Yes, this patch was the cause. Fixed like this:
2024-04-08 Bruno Haible <bruno@clisp.org>
pthread-h: Fix configuration (regression 2024-03-28).
Reported by Collin Funk in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00036.html>.
* m4/pthread_h.m4 (gl_PTHREAD_H_PART1): New macro, extracted from
gl_PTHREAD_H.
(gl_PTHREAD_H): Require it. Define using AC_DEFUN.
* m4/pthread-spin.m4 (gl_PTHREAD_SPIN): Require gl_PTHREAD_H_PART1,
not only gl_PTHREAD_H_DEFAULTS.
diff --git a/m4/pthread-spin.m4 b/m4/pthread-spin.m4
index 573b224462..67a50fa4db 100644
--- a/m4/pthread-spin.m4
+++ b/m4/pthread-spin.m4
@@ -1,5 +1,5 @@
# pthread-spin.m4
-# serial 7
+# serial 8
dnl Copyright (C) 2019-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,
@@ -7,7 +7,7 @@
AC_DEFUN_ONCE([gl_PTHREAD_SPIN],
[
- AC_REQUIRE([gl_PTHREAD_H_DEFAULTS])
+ AC_REQUIRE([gl_PTHREAD_H_PART1])
AC_REQUIRE([AC_CANONICAL_HOST])
if { case "$host_os" in mingw* | windows*) true;; *) false;; esac; } \
diff --git a/m4/pthread_h.m4 b/m4/pthread_h.m4
index eba682ab00..42001213d0 100644
--- a/m4/pthread_h.m4
+++ b/m4/pthread_h.m4
@@ -1,11 +1,11 @@
# pthread_h.m4
-# serial 10
+# serial 11
dnl Copyright (C) 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.
-AC_DEFUN_ONCE([gl_PTHREAD_H],
+AC_DEFUN_ONCE([gl_PTHREAD_H_PART1],
[
dnl Ensure to expand the default settings once only, before all statements
dnl that occur in other macros.
@@ -42,6 +42,12 @@ AC_DEFUN_ONCE([gl_PTHREAD_H]
if test $ac_cv_type_pthread_spinlock_t != yes; then
HAVE_PTHREAD_SPINLOCK_T=0
fi
+])
+
+AC_DEFUN([gl_PTHREAD_H],
+[
+ AC_REQUIRE([gl_PTHREAD_H_PART1])
+
dnl Set HAVE_PTHREAD_SPIN_INIT, REPLACE_PTHREAD_SPIN_INIT.
gl_PTHREAD_SPIN