Add missing uint32 type to folly::ProgramOptions::gFlagAdders
[folly.git] / folly / Bits.h
index 6c3c30ece1d027a5fd6018dedfbe270ca260b1f5..ade5bbeeb7b39572f47e73e6405a54184d72984b 100644 (file)
@@ -66,7 +66,6 @@
 #include <folly/portability/Builtins.h>
 
 #include <folly/Assume.h>
-#include <folly/detail/BitsDetail.h>
 #include <folly/detail/BitIteratorDetail.h>
 #include <folly/Likely.h>
 
@@ -214,7 +213,7 @@ inline typename std::enable_if<
    sizeof(T) <= sizeof(unsigned int)),
   size_t>::type
   popcount(T x) {
-  return size_t(detail::popcount(x));
+  return size_t(__builtin_popcount(x));
 }
 
 template <class T>
@@ -225,7 +224,7 @@ inline typename std::enable_if<
    sizeof(T) <= sizeof(unsigned long long)),
   size_t>::type
   popcount(T x) {
-  return size_t(detail::popcountll(x));
+  return size_t(__builtin_popcountll(x));
 }
 
 /**
@@ -241,7 +240,7 @@ struct uint_types_by_size;
     return fn(v);                                           \
   }                                                         \
   template <>                                               \
-  struct uint_types_by_size<sz> {                           \
+  struct uint_types_by_size<sz / 8> {                       \
     using type = uint##sz##_t;                              \
   };
 
@@ -268,7 +267,7 @@ struct EndianInt {
     // we implement this with memcpy because that is defined behavior in C++
     // we rely on compilers to optimize away the memcpy calls
     constexpr auto s = sizeof(T);
-    using B = typename uint_types_by_size<8 * s>::type;
+    using B = typename uint_types_by_size<s>::type;
     B b;
     std::memcpy(&b, &x, s);
     b = byteswap_gen(b);