Skip to content

Commit

Permalink
Fix more warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
greg7mdp committed Dec 9, 2023
1 parent 97e2d45 commit 592ef98
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion parallel_hashmap/phmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ inline size_t H1(size_t hashval, const ctrl_t* ) {
#endif


inline h2_t H2(size_t hashval) { return (ctrl_t)(hashval & 0x7F); }
inline ctrl_t H2(size_t hashval) { return (ctrl_t)(hashval & 0x7F); }

inline bool IsEmpty(ctrl_t c) { return c == kEmpty; }
inline bool IsFull(ctrl_t c) { return c >= static_cast<ctrl_t>(0); }
Expand Down
10 changes: 5 additions & 5 deletions parallel_hashmap/phmap_bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,25 +276,25 @@ PHMAP_BASE_INTERNAL_FORCEINLINE uint32_t CountLeadingZeros64Slow(uint64_t n) {
if (n >> 16) zeroes -= 16, n >>= 16;
if (n >> 8) zeroes -= 8, n >>= 8;
if (n >> 4) zeroes -= 4, n >>= 4;
return "\4\3\2\2\1\1\1\1\0\0\0\0\0\0\0"[n] + zeroes;
return (uint32_t)("\4\3\2\2\1\1\1\1\0\0\0\0\0\0\0"[n] + zeroes);
}

PHMAP_BASE_INTERNAL_FORCEINLINE uint32_t CountLeadingZeros64(uint64_t n) {
#if defined(_MSC_VER) && defined(_M_X64)
// MSVC does not have __buitin_clzll. Use _BitScanReverse64.
unsigned long result = 0; // NOLINT(runtime/int)
if (_BitScanReverse64(&result, n)) {
return (int)(63 - result);
return (uint32_t)(63 - result);
}
return 64;
#elif defined(_MSC_VER) && !defined(__clang__)
// MSVC does not have __buitin_clzll. Compose two calls to _BitScanReverse
unsigned long result = 0; // NOLINT(runtime/int)
if ((n >> 32) && _BitScanReverse(&result, (unsigned long)(n >> 32))) {
return 31 - result;
return (uint32_t)(31 - result);
}
if (_BitScanReverse(&result, (unsigned long)n)) {
return 63 - result;
return (uint32_t)(63 - result);
}
return 64;
#elif defined(__GNUC__) || defined(__clang__)
Expand All @@ -309,7 +309,7 @@ PHMAP_BASE_INTERNAL_FORCEINLINE uint32_t CountLeadingZeros64(uint64_t n) {
if (n == 0) {
return 64;
}
return __builtin_clzll(n);
return (uint32_t)__builtin_clzll(n);
#else
return CountLeadingZeros64Slow(n);
#endif
Expand Down
12 changes: 10 additions & 2 deletions parallel_hashmap/phmap_dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,12 @@ class BinaryOutputArchive {
ofs_.open(file_path, std::ofstream::out | std::ofstream::trunc | std::ofstream::binary);
}

~BinaryOutputArchive() = default;
BinaryOutputArchive(const BinaryOutputArchive&) = delete;
BinaryOutputArchive& operator=(const BinaryOutputArchive&) = delete;

bool saveBinary(const void *p, size_t sz) {
ofs_.write(reinterpret_cast<const char*>(p), sz);
ofs_.write(reinterpret_cast<const char*>(p), (std::streamsize)sz);
return true;
}

Expand All @@ -197,9 +201,13 @@ class BinaryInputArchive {
BinaryInputArchive(const char * file_path) {
ifs_.open(file_path, std::ofstream::in | std::ofstream::binary);
}

~BinaryInputArchive() = default;
BinaryInputArchive(const BinaryInputArchive&) = delete;
BinaryInputArchive& operator=(const BinaryInputArchive&) = delete;

bool loadBinary(void* p, size_t sz) {
ifs_.read(reinterpret_cast<char*>(p), sz);
ifs_.read(reinterpret_cast<char*>(p), (std::streamsize)sz);
return true;
}

Expand Down

0 comments on commit 592ef98

Please sign in to comment.