21typedef volatile char Lock_t;
23inline void unlock(Lock_t * _l) __attribute__((always_inline));
24inline void lock(Lock_t * _l) __attribute__((always_inline));
25inline int tas(
volatile char * lock) __attribute__((always_inline));
31inline void lock(Lock_t * _l) {
33#if defined(__i386__) || defined(__x86_64__)
34 __asm__ __volatile__ (
"pause\n");
40inline void unlock(Lock_t * _l) {
44inline int tas(
volatile char * lock)
47#if __cplusplus >= 201703L
50 register char res = 1;
52#if defined(__i386__) || defined(__x86_64__)
53 __asm__ __volatile__ (
55 :
"+q"(res),
"+m"(*lock)
58#elif defined(__sparc__)
59 __asm__ __volatile__ (
61 :
"=r"(res),
"+m"(*lock)
65#error TAS not defined for this architecture.