From: Keith Daigle Date: Fri, 15 Dec 2017 22:17:36 +0000 (-0800) Subject: Fix PicoSpinLock on aarch64 X-Git-Tag: v2017.12.18.00~7 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=7a45c3e0f31af33b0cb24e69ac51ba0274d66b31;p=folly.git Fix PicoSpinLock on aarch64 Summary: Found that building folly on aarch64 gave errors with picospinlock. Looked and found that MSVC used casts so I figured I'd try that Reviewed By: yfeldblum Differential Revision: D6504689 fbshipit-source-id: 9565bae5ffab485da407b8609be92ef7db10ab72 --- diff --git a/folly/PicoSpinLock.h b/folly/PicoSpinLock.h index 5c63583d..d9bdf50c 100644 --- a/folly/PicoSpinLock.h +++ b/folly/PicoSpinLock.h @@ -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" \