diff --git a/examples/insert_bench.cc b/examples/insert_bench.cc index b01b982..41cad80 100644 --- a/examples/insert_bench.cc +++ b/examples/insert_bench.cc @@ -62,7 +62,7 @@ public: uint64_t operator()(uint64_t boundExcluded) noexcept { #ifdef PHMAP_HAS_UMUL128 uint64_t h; - (void)umul128(operator()(), boundExcluded, &h); + (void)phmap::umul128(operator()(), boundExcluded, &h); return h; #else return 0; diff --git a/parallel_hashmap/phmap_bits.h b/parallel_hashmap/phmap_bits.h index 5db8ab9..9025511 100644 --- a/parallel_hashmap/phmap_bits.h +++ b/parallel_hashmap/phmap_bits.h @@ -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; } #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(a) * static_cast(b); - *high = static_cast(result >> 64); - return static_cast(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__) // Cache line alignment #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 { + +#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(a) * static_cast(b); + *high = static_cast(result >> 64); + return static_cast(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 { PHMAP_BASE_INTERNAL_FORCEINLINE uint32_t CountLeadingZeros64Slow(uint64_t n) {