From a075275a0e6782bc12044609893b5c9e37ea631f Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 21 Nov 2019 11:44:05 +0100
Subject: [PATCH] pthread-spin: Fix errors in C++ mode.

* m4/pthread-spin.m4 (gl_PTHREAD_SPIN): Mark the pthread_spin_*
functions as nonexistent when <pthread.h> exists but does not define
the pthread_spinlock_t type.
---
 ChangeLog          | 7 +++++++
 m4/pthread-spin.m4 | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4d99aca6a8..23e8176022 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-11-21  Bruno Haible  <bruno@clisp.org>
+
+	pthread-spin: Fix errors in C++ mode.
+	* m4/pthread-spin.m4 (gl_PTHREAD_SPIN): Mark the pthread_spin_*
+	functions as nonexistent when <pthread.h> exists but does not define
+	the pthread_spinlock_t type.
+
 2019-11-21  Bruno Haible  <bruno@clisp.org>
 
 	pthread-mutex: Fix errors in C++ mode.
diff --git a/m4/pthread-spin.m4 b/m4/pthread-spin.m4
index 9352d5a53a..c546e2f7b0 100644
--- a/m4/pthread-spin.m4
+++ b/m4/pthread-spin.m4
@@ -1,4 +1,4 @@
-# pthread-spin.m4 serial 1
+# pthread-spin.m4 serial 2
 dnl Copyright (C) 2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -19,7 +19,7 @@ AC_DEFUN([gl_PTHREAD_SPIN],
     REPLACE_PTHREAD_SPIN_UNLOCK=1
     REPLACE_PTHREAD_SPIN_DESTROY=1
   else
-    if test $HAVE_PTHREAD_H = 0; then
+    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
-- 
2.39.5