>From bed51ff8cc7bb755b32fa83c589436d8221380c6 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 16 Aug 2020 18:42:02 +0200 Subject: [PATCH 2/2] pthread-spin: Use GCC built-ins also on clang. * lib/pthread-spin.c (pthread_spin_init, pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock): Use the newer GCC built-ins also on clang. --- ChangeLog | 7 +++++++ lib/pthread-spin.c | 14 +++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f7ca8e..b97fcf7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2020-08-16 Bruno Haible + pthread-spin: Use GCC built-ins also on clang. + * lib/pthread-spin.c (pthread_spin_init, pthread_spin_lock, + pthread_spin_trylock, pthread_spin_unlock): Use the newer GCC built-ins + also on clang. + +2020-08-16 Bruno Haible + asyncsafe-spin tests: Update. * tests/test-asyncsafe-spin2.c: Update to match the change in lib/asyncsafe-spin.c from 2020-08-11. diff --git a/lib/pthread-spin.c b/lib/pthread-spin.c index c131050..c343f9d 100644 --- a/lib/pthread-spin.c +++ b/lib/pthread-spin.c @@ -68,9 +68,11 @@ pthread_spin_destroy (pthread_spinlock_t *lock) /* We don't use the C11 (available in GCC >= 4.9) because it would require to link with -latomic. */ -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) -/* Use GCC built-ins (available in GCC >= 4.7) that operate on the first 32-bit - word of the lock. +# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) \ + || __clang_major > 3 || (__clang_major__ == 3 && __clang_minor__ >= 1)) \ + && !defined __ibmxl__ +/* Use GCC built-ins (available in GCC >= 4.7 and clang >= 3.1) that operate on + the first byte of the lock. Documentation: */ @@ -162,8 +164,10 @@ pthread_spin_destroy (pthread_spinlock_t *lock) return 0; } -# elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) -/* Use GCC built-ins (available in GCC >= 4.1). +# elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) \ + || __clang_major__ >= 3) \ + && !defined __ibmxl__ +/* Use GCC built-ins (available in GCC >= 4.1 and clang >= 3.0). Documentation: */ -- 2.7.4