allow command to accept "--" separator
[folly.git] / folly / PicoSpinLock.h
index 5c63583d451ea15a6110308b73900bf2635afe8e..7d4fe2c1fd4cabc46204900d57f6b69bdc917c71 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2015-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@
 #include <glog/logging.h>
 
 #include <folly/Portability.h>
-#include <folly/detail/Sleeper.h>
+#include <folly/synchronization/detail/Sleeper.h>
 
 #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<UIntType>::type;
+    auto const lock = reinterpret_cast<SIntType*>(&lock_);
+    auto const mask = static_cast<SIntType>(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<UIntType>::type;
+    auto const lock = reinterpret_cast<SIntType*>(&lock_);
+    auto const mask = static_cast<SIntType>(kLockBitMask_);
+    __atomic_fetch_and(lock, ~mask, __ATOMIC_RELEASE);
 #elif FOLLY_PPC64
 #define FB_DOBTR(size)                                 \
     asm volatile("\teieio\n"                           \