8 #ifndef CVMFS_UTIL_ATOMIC_H_
9 #define CVMFS_UTIL_ATOMIC_H_
13 #ifdef CVMFS_NAMESPACE_GUARD
14 namespace CVMFS_NAMESPACE_GUARD {
29 return __sync_fetch_and_add(a, 0);
33 return __sync_fetch_and_add(a, 0);
38 while (!__sync_bool_compare_and_swap(a, atomic_read32(a), value)) {
44 while (!__sync_bool_compare_and_swap(a, atomic_read64(a), value)) {
49 (void)__sync_fetch_and_add(a, 1);
53 (void)__sync_fetch_and_add(a, 1);
57 (void)__sync_fetch_and_sub(a, 1);
61 (void)__sync_fetch_and_sub(a, 1);
66 if (offset < 0)
return __sync_fetch_and_sub(a, -offset);
67 return __sync_fetch_and_add(a, offset);
72 if (offset < 0)
return __sync_fetch_and_sub(a, -offset);
73 return __sync_fetch_and_add(a, offset);
77 atomic_cas32(
atomic_int32 *a, int32_t cmp, int32_t newval) {
78 return __sync_bool_compare_and_swap(a, cmp, newval);
82 atomic_cas64(
atomic_int64 *a, int64_t cmp, int64_t newval) {
85 return __sync_bool_compare_and_swap(a, cmp, newval);
89 asm __volatile__(
"" : : :
"memory");
92 #ifdef CVMFS_NAMESPACE_GUARD
96 #endif // CVMFS_UTIL_ATOMIC_H_
struct cvmcache_object_info __attribute__