From 4af425ee79bfe02bc353d87c7cc49bdb9b6a2907 Mon Sep 17 00:00:00 2001 From: Yafei Wu Date: Wed, 2 Nov 2022 13:47:52 +0800 Subject: [PATCH] spinlock support on loongarch64 --- src/include/storage/s_lock.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index 4225d9b7fc..74aa1af80c 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -618,6 +618,27 @@ tas(volatile slock_t *lock) #endif /* __hppa || __hppa__ */ +/* + * On loongarch64, we use __sync_lock_test_and_set(int *, int) if available. + */ +#if defined(__loongarch64) +#ifdef HAVE_GCC__SYNC_INT32_TAS +#define HAS_TEST_AND_SET + +#define TAS(lock) tas(lock) + +typedef int slock_t; + +static __inline__ int +tas(volatile slock_t *lock) +{ + return __sync_lock_test_and_set(lock, 1); +} + +#define S_UNLOCK(lock) __sync_lock_release(lock) + +#endif /* HAVE_GCC__SYNC_INT32_TAS */ +#endif /* __loongarch64 */ /* * Default implementation of S_UNLOCK() for gcc/icc. -- 2.34.1