mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-29 16:40:39 +08:00
Define umul128 in phmap namespace. (#273)
This commit is contained in:
committed by
GitHub
parent
40780b29bd
commit
896f1a03e4
@@ -62,7 +62,7 @@ public:
|
|||||||
uint64_t operator()(uint64_t boundExcluded) noexcept {
|
uint64_t operator()(uint64_t boundExcluded) noexcept {
|
||||||
#ifdef PHMAP_HAS_UMUL128
|
#ifdef PHMAP_HAS_UMUL128
|
||||||
uint64_t h;
|
uint64_t h;
|
||||||
(void)umul128(operator()(), boundExcluded, &h);
|
(void)phmap::umul128(operator()(), boundExcluded, &h);
|
||||||
return h;
|
return h;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Vendored
+30
-29
@@ -176,35 +176,6 @@ inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); }
|
|||||||
#define PHMAP_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; }
|
#define PHMAP_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PHMAP_HAVE_INTRINSIC_INT128
|
|
||||||
__extension__ typedef unsigned __int128 phmap_uint128;
|
|
||||||
inline uint64_t umul128(uint64_t a, uint64_t b, uint64_t* high)
|
|
||||||
{
|
|
||||||
auto result = static_cast<phmap_uint128>(a) * static_cast<phmap_uint128>(b);
|
|
||||||
*high = static_cast<uint64_t>(result >> 64);
|
|
||||||
return static_cast<uint64_t>(result);
|
|
||||||
}
|
|
||||||
#define PHMAP_HAS_UMUL128 1
|
|
||||||
#elif (defined(_MSC_VER))
|
|
||||||
#if defined(_M_X64)
|
|
||||||
#pragma intrinsic(_umul128)
|
|
||||||
inline uint64_t umul128(uint64_t a, uint64_t b, uint64_t* high)
|
|
||||||
{
|
|
||||||
return _umul128(a, b, high);
|
|
||||||
}
|
|
||||||
#define PHMAP_HAS_UMUL128 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
// Cache line alignment
|
// Cache line alignment
|
||||||
#if defined(__i386__) || defined(__x86_64__)
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
@@ -268,6 +239,36 @@ inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); }
|
|||||||
|
|
||||||
|
|
||||||
namespace phmap {
|
namespace phmap {
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PHMAP_HAVE_INTRINSIC_INT128
|
||||||
|
__extension__ typedef unsigned __int128 phmap_uint128;
|
||||||
|
inline uint64_t umul128(uint64_t a, uint64_t b, uint64_t* high)
|
||||||
|
{
|
||||||
|
auto result = static_cast<phmap_uint128>(a) * static_cast<phmap_uint128>(b);
|
||||||
|
*high = static_cast<uint64_t>(result >> 64);
|
||||||
|
return static_cast<uint64_t>(result);
|
||||||
|
}
|
||||||
|
#define PHMAP_HAS_UMUL128 1
|
||||||
|
#elif (defined(_MSC_VER))
|
||||||
|
#if defined(_M_X64)
|
||||||
|
#pragma intrinsic(_umul128)
|
||||||
|
inline uint64_t umul128(uint64_t a, uint64_t b, uint64_t* high)
|
||||||
|
{
|
||||||
|
return _umul128(a, b, high);
|
||||||
|
}
|
||||||
|
#define PHMAP_HAS_UMUL128 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace base_internal {
|
namespace base_internal {
|
||||||
|
|
||||||
PHMAP_BASE_INTERNAL_FORCEINLINE uint32_t CountLeadingZeros64Slow(uint64_t n) {
|
PHMAP_BASE_INTERNAL_FORCEINLINE uint32_t CountLeadingZeros64Slow(uint64_t n) {
|
||||||
|
|||||||
Reference in New Issue
Block a user