diff options
Diffstat (limited to 'src/util/u_atomic.c')
-rw-r--r-- | src/util/u_atomic.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util/u_atomic.c b/src/util/u_atomic.c index 44b75fb0c00..b32527fe347 100644 --- a/src/util/u_atomic.c +++ b/src/util/u_atomic.c @@ -61,6 +61,20 @@ __sync_sub_and_fetch_8(uint64_t *ptr, uint64_t val) } WEAK uint64_t +__sync_val_compare_and_swap_8(uint64_t *ptr, uint64_t oldval, uint64_t newval) +{ + uint64_t r; + + pthread_mutex_lock(&sync_mutex); + r = *ptr; + if (*ptr == oldval) + *ptr = newval; + pthread_mutex_unlock(&sync_mutex); + + return r; +} + +WEAK uint64_t __atomic_fetch_add_8(uint64_t *ptr, uint64_t val, int memorder) { return __sync_add_and_fetch(ptr, val); |