Revision 392a4d5b include/qemu/atomic.h
b/include/qemu/atomic.h | ||
---|---|---|
168 | 168 |
#endif |
169 | 169 |
|
170 | 170 |
#ifndef atomic_xchg |
171 |
#ifdef __ATOMIC_SEQ_CST |
|
171 |
#if defined(__clang__) |
|
172 |
#define atomic_xchg(ptr, i) __sync_swap(ptr, i) |
|
173 |
#elif defined(__ATOMIC_SEQ_CST) |
|
172 | 174 |
#define atomic_xchg(ptr, i) ({ \ |
173 | 175 |
typeof(*ptr) _new = (i), _old; \ |
174 | 176 |
__atomic_exchange(ptr, &_new, &_old, __ATOMIC_SEQ_CST); \ |
175 | 177 |
_old; \ |
176 | 178 |
}) |
177 |
#elif defined __clang__ |
|
178 |
#define atomic_xchg(ptr, i) __sync_exchange(ptr, i) |
|
179 | 179 |
#else |
180 | 180 |
/* __sync_lock_test_and_set() is documented to be an acquire barrier only. */ |
181 | 181 |
#define atomic_xchg(ptr, i) (smp_mb(), __sync_lock_test_and_set(ptr, i)) |
Also available in: Unified diff