1 #define a_ctz_64 a_ctz_64
2 static inline int a_ctz_64(uint64_t x)
4 __asm__( "bsf %1,%0" : "=r"(x) : "r"(x) );
8 #define a_and_64 a_and_64
9 static inline void a_and_64(volatile uint64_t *p, uint64_t v)
11 __asm__( "lock ; and %1, %0"
12 : "=m"(*p) : "r"(v) : "memory" );
15 #define a_or_64 a_or_64
16 static inline void a_or_64(volatile uint64_t *p, uint64_t v)
18 __asm__( "lock ; or %1, %0"
19 : "=m"(*p) : "r"(v) : "memory" );
23 static inline void a_or_l(volatile void *p, long v)
25 __asm__( "lock ; or %1, %0"
26 : "=m"(*(long *)p) : "r"(v) : "memory" );
29 #define a_cas_p a_cas_p
30 static inline void *a_cas_p(volatile void *p, void *t, void *s)
32 __asm__( "lock ; cmpxchg %3, %1"
33 : "=a"(t), "=m"(*(long *)p) : "a"(t), "r"(s) : "memory" );
38 static inline int a_cas(volatile int *p, int t, int s)
40 __asm__( "lock ; cmpxchg %3, %1"
41 : "=a"(t), "=m"(*p) : "a"(t), "r"(s) : "memory" );
46 static inline void a_or(volatile int *p, int v)
48 __asm__( "lock ; or %1, %0"
49 : "=m"(*p) : "r"(v) : "memory" );
53 static inline void a_and(volatile int *p, int v)
55 __asm__( "lock ; and %1, %0"
56 : "=m"(*p) : "r"(v) : "memory" );
60 static inline int a_swap(volatile int *x, int v)
62 __asm__( "xchg %0, %1" : "=r"(v), "=m"(*x) : "0"(v) : "memory" );
66 #define a_fetch_add a_fetch_add
67 static inline int a_fetch_add(volatile int *x, int v)
69 __asm__( "lock ; xadd %0, %1" : "=r"(v), "=m"(*x) : "0"(v) : "memory" );
74 static inline void a_inc(volatile int *x)
76 __asm__( "lock ; incl %0" : "=m"(*x) : "m"(*x) : "memory" );
80 static inline void a_dec(volatile int *x)
82 __asm__( "lock ; decl %0" : "=m"(*x) : "m"(*x) : "memory" );
85 #define a_store a_store
86 static inline void a_store(volatile int *p, int x)
88 __asm__( "mov %1, %0 ; lock ; orl $0,(%%rsp)" : "=m"(*p) : "r"(x) : "memory" );
92 static inline void a_spin()
94 __asm__ __volatile__( "pause" : : : "memory" );
97 #define a_barrier a_barrier
98 static inline void a_barrier()
100 __asm__ __volatile__( "" : : : "memory" );
103 #define a_crash a_crash
104 static inline void a_crash()
106 __asm__ __volatile__( "hlt" : : : "memory" );