25 template<
typename T,
typename D>
34 inline value_type add_and_fetch(
volatile value_type *value, D addend )
36 return __sync_add_and_fetch(value, addend);
39 inline value_type fetch_and_add(
volatile value_type *value, D addend )
41 return __sync_fetch_and_add(value, addend);
44 inline value_type fetch_and_increment(
volatile value_type *value)
46 return __sync_fetch_and_add(value, 1);
49 inline value_type fetch_and_decrement(
volatile value_type *value)
51 return __sync_fetch_and_sub(value, 1);
54 inline value_type fetch_and_store(
volatile value_type *value,
57 return __sync_lock_test_and_set(value, new_value);
60 inline bool compare_and_swap(
volatile value_type *value,
62 value_type comparand )
64 return __sync_bool_compare_and_swap(value, comparand, new_value);
67 inline value_type fetch(
const volatile value_type *value)
const volatile
79 return __sync_fetch_and_add(const_cast<value_type *>(value), 0);
82 inline value_type store_with_release(
volatile value_type *value,