]> Savannah Git Hosting - gnulib.git/commitdiff
pthread-spin: Fix warnings on FreeBSD 5.2.1/i386.
authorBruno Haible <bruno@clisp.org>
Sun, 15 Oct 2023 21:03:59 +0000 (23:03 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 5 Nov 2023 19:18:34 +0000 (20:18 +0100)
* lib/pthread.in.h (pthread_spinlock_t): Override if <pthread.h> defines
pthread_spinlock_t but we need to approximate spinlocks with mutexes.
* m4/pthread-spin.m4 (gl_PTHREAD_SPIN): When the pthread_spin_*
functions are declared but don't exist, mark them as REPLACEd.

ChangeLog
lib/pthread.in.h
m4/pthread-spin.m4

index f8de19c3cd74a61c1e83ba804800ac45859857eb..040e87147ae98c71ab1978a4316866a0e0119542 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2023-10-15  Bruno Haible  <bruno@clisp.org>
 
+       pthread-spin: Fix warnings on FreeBSD 5.2.1/i386.
+       * lib/pthread.in.h (pthread_spinlock_t): Override if <pthread.h> defines
+       pthread_spinlock_t but we need to approximate spinlocks with mutexes.
+       * m4/pthread-spin.m4 (gl_PTHREAD_SPIN): When the pthread_spin_*
+       functions are declared but don't exist, mark them as REPLACEd.
+
        pthread-spin: Fix link errors on FreeBSD 5.2.1/i386.
        * m4/pthread-spin.m4 (gl_PTHREAD_SPIN): Test not only whether
        <pthread.h> defines the pthread_spinlock_t type, but also whether the
index 4f206681a9907640e2781977f82eecec90a98e40..f8ee18e9daf54aaf95a752de24ecc60cbb3b44c0 100644 (file)
@@ -409,7 +409,21 @@ typedef pthread_mutex_t pthread_spinlock_t;
 # define PTHREAD_PROCESS_PRIVATE 0
 # define PTHREAD_PROCESS_SHARED 1
 #else
-# if !@HAVE_PTHREAD_SPINLOCK_T@
+# if @HAVE_PTHREAD_SPINLOCK_T@
+/* <pthread.h> exists and defines pthread_spinlock_t.  */
+#  if !(((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) \
+          || __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 1)) \
+         || (((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) \
+              && !defined __ANDROID__) \
+             || __clang_major__ >= 3)) \
+        && !defined __ibmxl__)
+/* We can't use GCC built-ins.  Approximate spinlocks with mutexes.  */
+#   if !GNULIB_defined_pthread_spin_types
+#    define pthread_spinlock_t pthread_mutex_t
+#    define GNULIB_defined_pthread_spin_types 1
+#   endif
+#  endif
+# else
 /* Approximate spinlocks with mutexes.  */
 #  if !GNULIB_defined_pthread_spin_types
 typedef pthread_mutex_t pthread_spinlock_t;
index 09bb4996823a8bf12b54fd5d48c47e22b0a5d5de..b89e09681de0ca2986ffb1156ad07696cca3831b 100644 (file)
@@ -52,10 +52,15 @@ AC_DEFUN([gl_PTHREAD_SPIN],
           ])
         if test $gl_cv_func_pthread_spin_init_in_LIBMULTITHREAD != yes; then
           HAVE_PTHREAD_SPIN_INIT=0
+          REPLACE_PTHREAD_SPIN_INIT=1
           HAVE_PTHREAD_SPIN_LOCK=0
+          REPLACE_PTHREAD_SPIN_LOCK=1
           HAVE_PTHREAD_SPIN_TRYLOCK=0
+          REPLACE_PTHREAD_SPIN_TRYLOCK=1
           HAVE_PTHREAD_SPIN_UNLOCK=0
+          REPLACE_PTHREAD_SPIN_UNLOCK=1
           HAVE_PTHREAD_SPIN_DESTROY=0
+          REPLACE_PTHREAD_SPIN_DESTROY=1
         fi
       ], [
         :