Commit 7f20dea0 for xz

commit 7f20dea02e81c7d1825b8dfbbfc0defbcd50db24
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   Thu Dec 3 17:48:32 2026 +0200

    Build: Update m4/ax_pthread.m4 from Autoconf Archive

diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4
index 3f26da62..8c8e02fb 100644
--- a/m4/ax_pthread.m4
+++ b/m4/ax_pthread.m4
@@ -89,7 +89,7 @@ dnl SPDX-License-Identifier: GPL-3.0-or-later WITH Autoconf-exception-macro
 #   modified version of the Autoconf Macro, you may extend this special
 #   exception to the GPL to apply to your modified version as well.

-#serial 31
+#serial 38

 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
 AC_DEFUN([AX_PTHREAD], [
@@ -108,6 +108,7 @@ ax_pthread_ok=no
 # them:
 if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
         ax_pthread_save_CC="$CC"
+        ax_pthread_save_CXX="$CXX"
         ax_pthread_save_CFLAGS="$CFLAGS"
         ax_pthread_save_LIBS="$LIBS"
         AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
@@ -122,6 +123,7 @@ if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
                 PTHREAD_CFLAGS=""
         fi
         CC="$ax_pthread_save_CC"
+        CXX="$ax_pthread_save_CXX"
         CFLAGS="$ax_pthread_save_CFLAGS"
         LIBS="$ax_pthread_save_LIBS"
 fi
@@ -251,7 +253,22 @@ AS_IF([test "x$ax_pthread_clang" = "xyes"],
 # correctly enabled

 case $host_os in
-        darwin* | hpux* | linux* | osf* | solaris*)
+        solaris*)
+        # Solaris 11.4 introduced XPG7 support and did away with the need for
+        # _REENTRANT.
+
+        AC_EGREP_CPP([AX_PTHREAD_SOLARIS__REENTRANT],
+            [
+#            undef _XOPEN_SOURCE
+#            include <sys/feature_tests.h>
+#            if _XOPEN_VERSION < 700
+             AX_PTHREAD_SOLARIS__REENTRANT
+#            endif
+            ],
+            [ax_pthread_check_macro="_REENTRANT"],
+            [ax_pthread_check_macro="--"])
+        ;;
+        darwin* | hpux* | linux* | osf*)
         ax_pthread_check_macro="_REENTRANT"
         ;;

@@ -290,6 +307,7 @@ for ax_pthread_try_flag in $ax_pthread_flags; do
                 pthread-config)
                 AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
                 AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
+                AC_MSG_CHECKING([whether pthreads work with pthread-config])
                 PTHREAD_CFLAGS="`pthread-config --cflags`"
                 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
                 ;;
@@ -349,9 +367,10 @@ fi


 # Clang needs special handling, because older versions handle the -pthread
-# option in a rather... idiosyncratic way
+# option in a rather... idiosyncratic way. Do this only if pthreads work.
+# If they do not work, PTHREAD_CFLAGS must stay empty.

-if test "x$ax_pthread_clang" = "xyes"; then
+if test "x$ax_pthread_clang" = "xyes" && test "x$ax_pthread_ok" = "xyes"; then

         # Clang takes -pthread; it has never supported any other flag

@@ -412,12 +431,17 @@ if test "x$ax_pthread_clang" = "xyes"; then
              ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
             ])

+        # If the macro is called again, PTHREAD_CFLAGS can already contain
+        # the flag. Do not add it again.
         case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
                 no | unknown) ;;
-                *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
+                *) case " $PTHREAD_CFLAGS " in
+                        *" $ax_cv_PTHREAD_CLANG_NO_WARN_FLAG "*) ;;
+                        *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
+                   esac ;;
         esac

-fi # $ax_pthread_clang = yes
+fi # $ax_pthread_clang = yes && $ax_pthread_ok = yes