13 #include <stdatomic.h>
17 #if defined(__x86_64__) || defined(__i386__)
18 #include <immintrin.h>
28 #define spin_init(lck_p) spin_unlock(lck_p)
34 #if defined(__x86_64__) || defined(__i386__)
35 #define spin_pause() _mm_pause()
44 #define spin_lock(lck_p) \
46 while(atomic_flag_test_and_set_explicit((lck_p), memory_order_acquire)) \
55 #define spin_trylock(lck_p) !atomic_flag_test_and_set_explicit((lck_p), memory_order_acquire)
61 #define spin_unlock(lck_p) atomic_flag_clear_explicit((lck_p), memory_order_release)
bool sync_thread_barrier(void)
Synchronizes threads on a barrier.
Definition: sync.c:19
atomic_flag spinlock_t
The type of a spinlock, an efficient lock primitive in contended scenarios.
Definition: sync.h:22