Go to the documentation of this file. 1 #undef GCC_SYNC_FUNCTIONS
2 #undef GCC_ATOMIC_FUNCTIONS
5 #error Please edit abstract_atomic.h and implement support for \
8 #define ATOMIC_GCC_VERSION (__GNUC__ * 10000 \
9 + __GNUC_MINOR__ * 100 \
10 + __GNUC_PATCHLEVEL__)
12 #if ((ATOMIC_GCC_VERSION) >= 40700)
13 #define GCC_ATOMIC_FUNCTIONS 1
14 #elif ((ATOMIC_GCC_VERSION) >= 40100)
15 #define GCC_SYNC_FUNCTIONS 1
17 #error This verison of GCC does not support atomics.
22 #define atomic_postinc(x) __sync_fetch_and_add(&x, 1)
23 #define atomic_postdec(x) __sync_fetch_and_sub(&x, 1)
24 #define atomic_postadd(x,i) __sync_fetch_and_add(&x, i)
25 #define atomic_postsub(x,i) __sync_fetch_and_sub(&x, i)
26 #define atomic_postmask(x,i) __sync_fetch_and_and(&x, i)
27 #define atomic_inc(x) __sync_add_and_fetch(&x, 1)
28 #define atomic_dec(x) __sync_sub_and_fetch(&x, 1)
29 #define atomic_add(x,i) __sync_add_and_fetch(&x, i)
30 #define atomic_sub(x,i) __sync_sub_and_fetch(&x, i)
31 #define atomic_mask(x,i) __sync_and_and_fetch(&x, i)
32 #define atomic_bool_compare_and_swap __sync_bool_compare_and_swap
34 #ifdef GCC_ATOMIC_FUNCTIONS
35 #define atomic_store(x, n) __atomic_store_n(x, n, __ATOMIC_RELEASE)
36 #elif defined(GCC_SYNC_FUNCTIONS)
37 #define atomic_store(x, n) do { *(x) = n; __sync_synchronize(); } while (0)