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" );
45 static inline void a_inc(volatile int *p)
49 : "=m"(*p) : "m"(*p) : "memory" );
53 static inline void a_dec(volatile int *p)
57 : "=m"(*p) : "m"(*p) : "memory" );
60 #define a_store a_store
61 static inline void a_store(volatile int *p, int x)
64 "mov %1, %0 ; lock ; orl $0,(%%esp)"
65 : "=m"(*p) : "r"(x) : "memory" );
68 #define a_barrier a_barrier
69 static inline void a_barrier()
71 __asm__ __volatile__( "" : : : "memory" );
75 static inline void a_spin()
77 __asm__ __volatile__( "pause" : : : "memory" );
80 #define a_crash a_crash
81 static inline void a_crash()
83 __asm__ __volatile__( "hlt" : : : "memory" );
86 #define a_ctz_64 a_ctz_64
87 static inline int a_ctz_64(uint64_t x)
90 __asm__( "bsf %1,%0 ; jnz 1f ; bsf %2,%0 ; add $32,%0\n1:"
91 : "=&r"(r) : "r"((unsigned)x), "r"((unsigned)(x>>32)) );
95 #define a_ctz_l a_ctz_l
96 static inline int a_ctz_l(unsigned long x)
99 __asm__( "bsf %1,%0" : "=r"(r) : "r"(x) );
103 #define a_clz_32 a_clz_32
104 static inline int a_clz_32(uint32_t x)
106 __asm__( "bsr %1,%0 ; xor $31,%0" : "=r"(x) : "r"(x) );