2 static inline int a_cas(volatile int *p, int t, int s)
5 "lock ; cmpxchg %3, %1"
6 : "=a"(t), "=m"(*p) : "a"(t), "r"(s) : "memory" );
11 static inline int a_swap(volatile int *p, int v)
15 : "=r"(v), "=m"(*p) : "0"(v) : "memory" );
19 #define a_fetch_add a_fetch_add
20 static inline int a_fetch_add(volatile int *p, int v)
24 : "=r"(v), "=m"(*p) : "0"(v) : "memory" );
29 static inline void a_and(volatile int *p, int v)
33 : "=m"(*p) : "r"(v) : "memory" );
37 static inline void a_or(volatile int *p, int v)
41 : "=m"(*p) : "r"(v) : "memory" );
44 #define a_and_64 a_and_64
45 static inline void a_and_64(volatile uint64_t *p, uint64_t v)
49 : "=m"(*p) : "r"(v) : "memory" );
52 #define a_or_64 a_or_64
53 static inline void a_or_64(volatile uint64_t *p, uint64_t v)
57 : "=m"(*p) : "r"(v) : "memory" );
61 static inline void a_inc(volatile int *p)
65 : "=m"(*p) : "m"(*p) : "memory" );
69 static inline void a_dec(volatile int *p)
73 : "=m"(*p) : "m"(*p) : "memory" );
76 #define a_store a_store
77 static inline void a_store(volatile int *p, int x)
80 "mov %1, %0 ; lock ; orl $0,(%%rsp)"
81 : "=m"(*p) : "r"(x) : "memory" );
84 #define a_barrier a_barrier
85 static inline void a_barrier()
87 __asm__ __volatile__( "" : : : "memory" );
91 static inline void a_spin()
93 __asm__ __volatile__( "pause" : : : "memory" );
96 #define a_crash a_crash
97 static inline void a_crash()
99 __asm__ __volatile__( "hlt" : : : "memory" );
102 #define a_ctz_64 a_ctz_64
103 static inline int a_ctz_64(uint64_t x)
105 __asm__( "bsf %1,%0" : "=r"(x) : "r"(x) );
109 #define a_ctz_l a_ctz_l
110 static inline int a_ctz_l(unsigned long x)
112 __asm__( "bsf %1,%0" : "=r"(x) : "r"(x) );