fix race between StaticMetaBase::destroy() and StaticMetaBase::onThreadExit()
[folly.git] / folly / detail / BitsDetail.h
index df3acd77eeb7f985685d36f7d79aad3d26639513..d89a25ef608601076b161c183cccbe5a4f37369c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  */
 
-#ifndef FOLLY_DETAIL_BITSDETAIL_H_
-#define FOLLY_DETAIL_BITSDETAIL_H_
+#pragma once
 
 namespace folly {
 namespace detail {
 
 // If we're targeting an architecture with popcnt support, use
 // __builtin_popcount directly, as it's presumably inlined.
-// If not, use runtime detection using __attribute__((ifunc))
+// If not, use runtime detection using __attribute__((__ifunc__))
 // (see Bits.cpp)
-#ifdef __POPCNT__
+#ifdef _MSC_VER
+inline int popcount(unsigned int x) {
+  return __popcnt(x);
+}
+inline int popcountll(unsigned long long x) {
+  return __popcnt64(x);
+}
+#elif defined(__POPCNT__)
 
 inline int popcount(unsigned int x) {
   return __builtin_popcount(x);
@@ -42,6 +48,3 @@ int popcountll(unsigned long long x);
 
 }  // namespace detail
 }  // namespace folly
-
-#endif /* FOLLY_DETAIL_BITSDETAIL_H_ */
-