util/u_atomic: add p_atomic_xchg
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 3 Nov 2017 14:19:57 +0000 (15:19 +0100)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 9 Nov 2017 10:37:30 +0000 (11:37 +0100)
commit0a7f17cf5b591330a257ed0485f759d4e600972c
tree70fb2f459b7a55ad711e303463d2218a6ba75cdd
parentb4b2a951c8b4c1315c06cb4d58dbc787949daa4c
util/u_atomic: add p_atomic_xchg

The closest to it in the old-style gcc builtins is __sync_lock_test_and_set,
however, that is only guaranteed to work with values 0 and 1 and only
provides an acquire barrier. I also don't know about other OSes, so we
provide a simple & stupid emulation via p_atomic_cmpxchg.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/util/u_atomic.h