Kill a couple of PThread includes
[folly.git] / folly / PicoSpinLock.h
index 9f52a7a9a86e5af27b9c94a7730a65f6afa8ed1c..683858805e069fa6544511689ae0ef2fc8ed75d6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -44,7 +44,6 @@
 #include <cstdlib>
 #include <folly/Portability.h>
 #include <mutex>
-#include <pthread.h>
 #include <type_traits>
 
 #include <glog/logging.h>
@@ -94,7 +93,7 @@ struct PicoSpinLock {
    */
   void init(IntType initialValue = 0) {
     CHECK(!(initialValue & kLockBitMask_));
-    lock_ = initialValue;
+    lock_ = UIntType(initialValue);
   }
 
   /*
@@ -118,7 +117,7 @@ struct PicoSpinLock {
    */
   void setData(IntType w) {
     CHECK(!(w & kLockBitMask_));
-    lock_ = (lock_ & kLockBitMask_) | w;
+    lock_ = UIntType((lock_ & kLockBitMask_) | w);
   }
 
   /*
@@ -132,7 +131,8 @@ struct PicoSpinLock {
     switch (sizeof(IntType)) {
       case 2:
         // There is no _interlockedbittestandset16 for some reason :(
-        ret = _InterlockedOr16((volatile short*)&lock, 1 << Bit) & (1 << Bit);
+        ret = _InterlockedOr16(
+            (volatile short*)&lock_, (short)kLockBitMask_) & kLockBitMask_;
         break;
       case 4:
         ret = _interlockedbittestandset((volatile long*)&lock_, Bit);
@@ -210,7 +210,7 @@ struct PicoSpinLock {
     switch (sizeof(IntType)) {
       case 2:
         // There is no _interlockedbittestandreset16 for some reason :(
-        _InterlockedAnd16((volatile short*)&lock, ~(1 << Bit));
+        _InterlockedAnd16((volatile short*)&lock_, (short)~kLockBitMask_);
         break;
       case 4:
         _interlockedbittestandreset((volatile long*)&lock_, Bit);