diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-11-22 03:08:23 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-11-22 03:08:23 +0000 |
commit | dbe89b15879a8360ed3cb80b4a6fcde4e5fb9cd7 (patch) | |
tree | 553f311fe5371eafc57138ad475de1bd1fd4d916 /lib/mesa | |
parent | f724284ad86d1a7b4cff01ce2df2a3869492bb49 (diff) |
provide an unlocked atomic fallback path
sparc < v9, hppa, sh, arm < v6 don't provide these builtins
and we don't have kernel assistance to fake them currently.
Diffstat (limited to 'lib/mesa')
-rw-r--r-- | lib/mesa/src/util/u_atomic.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/mesa/src/util/u_atomic.h b/lib/mesa/src/util/u_atomic.h index e38395ac6..bb6f3c30e 100644 --- a/lib/mesa/src/util/u_atomic.h +++ b/lib/mesa/src/util/u_atomic.h @@ -23,6 +23,9 @@ #define PIPE_ATOMIC_OS_SOLARIS #elif defined(_MSC_VER) #define PIPE_ATOMIC_MSVC_INTRINSIC +#elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_5__) || \ + defined(__hppa__) || defined(__sparc__) || defined(__sh__) +#define PIPE_ATOMIC_UNLOCKED #elif defined(__GNUC__) #define PIPE_ATOMIC_GCC_INTRINSIC #else @@ -49,7 +52,25 @@ #endif +#if defined(PIPE_ATOMIC_UNLOCKED) +#define PIPE_ATOMIC "Unlocked" + +#define p_atomic_set(_v, _i) (*(_v) = (_i)) +#define p_atomic_read(_v) (*(_v)) +#define p_atomic_dec_zero(_v) ((*(_v) -= 1) == 0) +#define p_atomic_inc(_v) (*(_v) += 1) +#define p_atomic_dec(_v) (*(_v) -= 1) +#define p_atomic_add(_v, _i) (*(_v) += (_i)) +#define p_atomic_inc_return(_v) (*(_v) += 1) +#define p_atomic_dec_return(_v) (*(_v) -= 1) +#define p_atomic_cmpxchg(_v, old, _new) ({ \ + __typeof(*_v) _r = *(_v); \ + if (*(_v) == old) \ + *(_v) = (_new); \ + _r; \ +}) +#endif /* Unlocked version for single threaded environments, such as some * windows kernel modules. |