Commit 7fd46ef5 authored by Nathan Bronson's avatar Nathan Bronson Committed by Facebook Github Bot

fix F14 MSVC build

Summary:
F14 was missing the MSVC portability shims, and also needs to
use an MSVC-specific intrinsic to get the high word of a 64-bit multiply.

Reviewed By: yfeldblum

Differential Revision: D7263349

fbshipit-source-id: f47ceb2b2370d9bef1409e4790b236752c9f6ac4
parent c391dc14
......@@ -40,6 +40,7 @@
#include <folly/lang/Exception.h>
#include <folly/lang/Launder.h>
#include <folly/lang/SafeAssert.h>
#include <folly/portability/Builtins.h>
#include <folly/portability/TypeTraits.h>
#include <folly/container/detail/F14Memory.h>
......@@ -63,6 +64,10 @@
#include <xmmintrin.h> // _mm_prefetch
#endif
#ifdef _WIN32
#include <intrin.h> // for _mul128
#endif
namespace folly {
struct F14TableStats {
......@@ -778,11 +783,20 @@ class F14Table : public Policy {
static HashPair splitHash(std::size_t hash) {
uint8_t tag;
if (!Policy::isAvalanchingHasher()) {
auto const kMul = 0xc4ceb9fe1a85ec53ULL;
#ifdef _WIN32
__int64 signedHi;
__int64 signedLo = _mul128(
static_cast<__int64>(hash), static_cast<__int64>(kMul), &signedHi);
auto hi = static_cast<uint64_t>(signedHi);
auto lo = static_cast<uint64_t>(signedLo);
#else
auto hi = static_cast<uint64_t>(
(static_cast<unsigned __int128>(hash) * 0xc4ceb9fe1a85ec53ULL) >> 64);
auto lo = hash * 0xc4ceb9fe1a85ec53ULL;
(static_cast<unsigned __int128>(hash) * kMul) >> 64);
auto lo = hash * kMul;
#endif
hash = hi ^ lo;
hash *= 0xc4ceb9fe1a85ec53ULL;
hash *= kMul;
tag = static_cast<uint8_t>(hash >> 15);
hash >>= 22;
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment