diff options
author | Matt Turner <[email protected]> | 2017-09-14 11:00:26 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2017-09-15 09:37:30 -0700 |
commit | 1bbe18087312e1b8ccdba6ca6dd8f1c9740a8454 (patch) | |
tree | f6941d04218a97d8821f98d2c563856fb2076566 /src/util/u_atomic.c | |
parent | d075a4089ec62c489c8a3423f82371bf85f2ea6c (diff) |
util/u_atomic: Add implementation of __sync_val_compare_and_swap_8
Needed for 32-bit PowerPC.
Cc: "17.2" <[email protected]>
Fixes: a6a38a038bd ("util/u_atomic: provide 64bit atomics where
they're missing")
Reviewed-by: Emil Velikov <[email protected]>
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); |