1 #pragma once
2 
3 #include <stdatomic.h>
4 
5 // TODO(kulakowski) This is a temporary shim to separate the
6 // bespoke=>C11 atomic conversion from the rewrite of the two
7 // different CAS styles (return bool and pointer out vs. return old
8 // value).
a_cas_shim(_Atomic (int)* p,int t,int s)9 static inline int a_cas_shim(_Atomic(int)* p, int t, int s) {
10     atomic_compare_exchange_strong(p, &t, s);
11     return t;
12 }
13 
14 #if defined(__x86_64__)
a_spin(void)15 static inline void a_spin(void) {
16     __asm__ __volatile__("pause"
17                          :
18                          :
19                          : "memory");
20 }
21 #else
22 #define a_spin() atomic_thread_fence(memory_order_seq_cst)
23 #endif
24