6 #ifndef ABTD_SPINLOCK_H_INCLUDED
7 #define ABTD_SPINLOCK_H_INCLUDED
9 typedef struct ABTD_spinlock {
13 #define ABTD_SPINLOCK_STATIC_INITIALIZER() \
15 ABTD_ATOMIC_BOOL_STATIC_INITIALIZER(0) \
18 static inline ABT_bool ABTD_spinlock_is_locked(
const ABTD_spinlock *p_lock)
20 return ABTD_atomic_acquire_load_bool(&p_lock->val);
23 static inline void ABTD_spinlock_clear(ABTD_spinlock *p_lock)
25 ABTD_atomic_relaxed_clear_bool(&p_lock->val);
28 static inline void ABTD_spinlock_acquire(ABTD_spinlock *p_lock)
30 while (ABTD_atomic_test_and_set_bool(&p_lock->val)) {
31 while (ABTD_spinlock_is_locked(p_lock) !=
ABT_FALSE)
37 static inline ABT_bool ABTD_spinlock_try_acquire(ABTD_spinlock *p_lock)
42 static inline void ABTD_spinlock_release(ABTD_spinlock *p_lock)
44 ABTD_atomic_release_clear_bool(&p_lock->val);