X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FPicoSpinLock.h;h=eb62bee21b2ef63d412f593f64b8daa0d3994a7e;hb=c60784b8bc21ff4a420da59e29fa0aec3abd0f8a;hp=070f1fbe97838342aed1dea5db4663ef34802997;hpb=aa86aa272abff08c186edee58561ec19abb70f6e;p=folly.git diff --git a/folly/PicoSpinLock.h b/folly/PicoSpinLock.h index 070f1fbe..eb62bee2 100644 --- a/folly/PicoSpinLock.h +++ b/folly/PicoSpinLock.h @@ -48,7 +48,7 @@ #include #include -#include +#include #if !FOLLY_X64 && !FOLLY_AARCH64 && !FOLLY_PPC64 #error "PicoSpinLock.h is currently x64, aarch64 and ppc64 only." @@ -172,9 +172,10 @@ struct PicoSpinLock { #undef FB_DOBTS #elif FOLLY_AARCH64 - ret = - !(__atomic_fetch_or(&lock_, kLockBitMask_, __ATOMIC_SEQ_CST) & - kLockBitMask_); + using SIntType = typename std::make_signed::type; + auto const lock = reinterpret_cast(&lock_); + auto const mask = static_cast(kLockBitMask_); + return !(mask & __atomic_fetch_or(lock, mask, __ATOMIC_ACQUIRE)); #elif FOLLY_PPC64 #define FB_DOBTS(size) \ asm volatile("\teieio\n" \ @@ -255,7 +256,10 @@ struct PicoSpinLock { #undef FB_DOBTR #elif FOLLY_AARCH64 - __atomic_fetch_and(&lock_, ~kLockBitMask_, __ATOMIC_SEQ_CST); + using SIntType = typename std::make_signed::type; + auto const lock = reinterpret_cast(&lock_); + auto const mask = static_cast(kLockBitMask_); + __atomic_fetch_and(lock, ~mask, __ATOMIC_RELEASE); #elif FOLLY_PPC64 #define FB_DOBTR(size) \ asm volatile("\teieio\n" \ @@ -284,4 +288,4 @@ struct PicoSpinLock { } }; -} +} // namespace folly