From b67f12dc70f59d0481988cb560649d10664b1e77 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 15 Oct 2023 23:03:59 +0200 Subject: [PATCH] pthread-spin: Fix warnings on FreeBSD 5.2.1/i386. * lib/pthread.in.h (pthread_spinlock_t): Override if 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 | 6 ++++++ lib/pthread.in.h | 16 +++++++++++++++- m4/pthread-spin.m4 | 5 +++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f8de19c3cd..040e87147a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2023-10-15 Bruno Haible + pthread-spin: Fix warnings on FreeBSD 5.2.1/i386. + * lib/pthread.in.h (pthread_spinlock_t): Override if 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 defines the pthread_spinlock_t type, but also whether the diff --git a/lib/pthread.in.h b/lib/pthread.in.h index 4f206681a9..f8ee18e9da 100644 --- a/lib/pthread.in.h +++ b/lib/pthread.in.h @@ -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@ +/* 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; diff --git a/m4/pthread-spin.m4 b/m4/pthread-spin.m4 index 09bb499682..b89e09681d 100644 --- a/m4/pthread-spin.m4 +++ b/m4/pthread-spin.m4 @@ -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 ], [ : -- 2.39.5