Fix dynamic MPMCQueue tryObtainPromisedPushTicket() to prevent tryWriteUntil() and...
[folly.git] / folly / Bits.h
index 9742a06665fb6db6ef4394ccfb1f451b6bab76c9..e4b1b5ea0c38e4d660c2e1af443d07942174da9f 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.
@@ -263,8 +263,11 @@ our_bswap16(Int16 x) {
 
 #endif
 
-#define FB_GEN(t, fn) \
-template<> inline t EndianIntBase<t>::swap(t x) { return fn(x); }
+#define FB_GEN(t, fn)                             \
+  template <>                                     \
+  inline t EndianIntBase<t>::swap(t x) {          \
+    return t(fn(std::make_unsigned<t>::type(x))); \
+  }
 
 // fn(x) expands to (x) if the second argument is empty, which is exactly
 // what we want for [u]int8_t. Also, gcc 4.7 on Intel doesn't have
@@ -459,7 +462,7 @@ class BitIterator
       other.bitOffset_ - bitOffset_;
   }
 
-  unsigned int bitOffset_;
+  size_t bitOffset_;
 };
 
 /**