diff options
author | Rich Felker <dalias@aerifal.cx> | 2014-08-25 15:43:40 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2014-08-25 15:43:40 -0400 |
commit | ea818ea8340c13742a4f41e6077f732291aea4bc (patch) | |
tree | f2a97e8f8a25fc3337002aa30bb235575593af86 /arch/sh | |
parent | 5345c9b884e7c4e73eb2c8bb83b8d0df20f95afb (diff) | |
download | musl-ea818ea8340c13742a4f41e6077f732291aea4bc.zip musl-ea818ea8340c13742a4f41e6077f732291aea4bc.tar.gz musl-ea818ea8340c13742a4f41e6077f732291aea4bc.tar.bz2 |
add working a_spin() atomic for non-x86 targets
conceptually, a_spin needs to be at least a compiler barrier, so the
compiler will not optimize out loops (and the load on each iteration)
while spinning. it should also be a memory barrier, or the spinning
thread might keep spinning without noticing stores from other threads,
thus delaying for longer than it should.
ideally, an optimal a_spin implementation that avoids unnecessary
cache/memory contention should be chosen for each arch, but for now,
the easiest thing is to perform a useless a_cas on the calling
thread's stack.
Diffstat (limited to 'arch/sh')
-rw-r--r-- | arch/sh/atomic.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/arch/sh/atomic.h b/arch/sh/atomic.h index 93ab54f..b95bbff 100644 --- a/arch/sh/atomic.h +++ b/arch/sh/atomic.h @@ -53,6 +53,7 @@ static inline void a_dec(volatile int *x) static inline void a_spin() { + a_cas(&(int){0}, 0, 0); } static inline void a_crash() |