21 #ifdef COIL_HAS_ATOMIC_OP 23 #include <bits/atomicity.h> 25 #define COIL_USES_ATOMIC_OP 26 #define atomic_add(x, y) __gnu_cxx::__atomic_add(x, y) 27 #define atomic_incr(x) __gnu_cxx::__atomic_add(x, 1) 28 #define atomic_decr(x) __gnu_cxx::__atomic_add(x, -1) 29 #define atomic_exchange_add(x, y) __gnu_cxx::__exchange_and_add(x, y) 32 #include <coil/Mutex.h> 33 #include <coil/Guard.h> 34 #define COIL_USES_ATOMIC_OP coil::Mutex __mutex; 36 #define atomic_add(x, y) \ 38 coil::Guard<coil::Mutex> guard(__mutex); \ 42 #define atomic_incr(x) \ 44 coil::Guard<coil::Mutex> guard(__mutex); \ 48 #define atomic_decr(x) \ 50 coil::Guard<coil::Mutex> guard(__mutex); \ 62 #define atomic_exchange_add(x, y) \ 63 exchange_add(x, y, &__mutex) 65 #endif // COIL_HAS_ATOMIC_ADD 66 #endif // COIL_ATOMIC_H
int exchange_add(int *x, int y, coil::Mutex *mutex)