From: Matt Turner Date: Thu, 14 Sep 2017 18:00:26 +0000 (-0700) Subject: util/u_atomic: Add implementation of __sync_val_compare_and_swap_8 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1bbe18087312e1b8ccdba6ca6dd8f1c9740a8454;p=mesa.git util/u_atomic: Add implementation of __sync_val_compare_and_swap_8 Needed for 32-bit PowerPC. Cc: "17.2" Fixes: a6a38a038bd ("util/u_atomic: provide 64bit atomics where they're missing") Reviewed-by: Emil Velikov --- 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 @@ -60,6 +60,20 @@ __sync_sub_and_fetch_8(uint64_t *ptr, uint64_t val) return r; } +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) {