From: Jeff Preshing Date: Wed, 10 Feb 2016 13:59:29 +0000 (-0500) Subject: Fix MSVC warnings with u64 keys X-Git-Url: http://plrg.eecs.uci.edu/git/?p=junction.git;a=commitdiff_plain;h=6a7fe65045a50f9830aa674fcacf16f4e580eaa2 Fix MSVC warnings with u64 keys --- diff --git a/junction/ConcurrentMap_Grampa.h b/junction/ConcurrentMap_Grampa.h index b0d6cec..8d67f22 100644 --- a/junction/ConcurrentMap_Grampa.h +++ b/junction/ConcurrentMap_Grampa.h @@ -41,7 +41,7 @@ private: if (root & 1) { typename Details::FlatTree* flatTree = (typename Details::FlatTree*) (root & ~ureg(1)); for (;;) { - ureg leafIdx = (hash >> flatTree->safeShift); + ureg leafIdx = ureg(hash >> flatTree->safeShift); table = flatTree->getTables()[leafIdx].load(turf::Relaxed); if (ureg(table) != Details::RedirectFlatTree) { sizeMask = (Details::LeafSize - 1); @@ -189,7 +189,7 @@ public: // Retry the loop. } else { ureg repeat = ureg(1) << (migration->m_safeShift - flatTree->safeShift); - ureg dstStartIndex = migration->m_baseHash >> flatTree->safeShift; + ureg dstStartIndex = ureg(migration->m_baseHash >> flatTree->safeShift); // The subtree we're about to publish fits inside the flattree. TURF_ASSERT(dstStartIndex + migration->m_numDestinations * repeat - 1 <= Hash(-1) >> flatTree->safeShift); // If a previous attempt to publish got redirected, resume publishing into the new flattree, diff --git a/junction/ConcurrentMap_LeapFrog.h b/junction/ConcurrentMap_LeapFrog.h index 0a51ad9..a9dc4a3 100644 --- a/junction/ConcurrentMap_LeapFrog.h +++ b/junction/ConcurrentMap_LeapFrog.h @@ -37,7 +37,7 @@ private: turf::Atomic m_root; public: - ConcurrentMap_LeapFrog(ureg capacity) : m_root(Details::Table::create(capacity)) { + ConcurrentMap_LeapFrog(ureg capacity = Details::InitialSize) : m_root(Details::Table::create(capacity)) { } ~ConcurrentMap_LeapFrog() { diff --git a/junction/ConcurrentMap_Linear.h b/junction/ConcurrentMap_Linear.h index 32b2a37..4cf349d 100644 --- a/junction/ConcurrentMap_Linear.h +++ b/junction/ConcurrentMap_Linear.h @@ -37,7 +37,7 @@ private: turf::Atomic m_root; public: - ConcurrentMap_Linear(ureg capacity) { + ConcurrentMap_Linear(ureg capacity = Details::InitialSize) { ureg limitNumValues = capacity * 3 / 4; m_root.storeNonatomic(Details::Table::create(capacity, limitNumValues)); } diff --git a/junction/details/Grampa.h b/junction/details/Grampa.h index e628757..9f85df2 100644 --- a/junction/details/Grampa.h +++ b/junction/details/Grampa.h @@ -110,7 +110,7 @@ struct Grampa { : sizeMask(sizeMask), baseHash(baseHash), unsafeRangeShift(unsafeRangeShift) { } - static Table* create(ureg tableSize, ureg baseHash, ureg unsafeShift) { + static Table* create(ureg tableSize, Hash baseHash, ureg unsafeShift) { TURF_ASSERT(turf::util::isPowerOf2(tableSize)); TURF_ASSERT(unsafeShift > 0 && unsafeShift <= sizeof(Hash) * 8); TURF_ASSERT(tableSize >= 4); @@ -362,7 +362,7 @@ struct Grampa { TURF_TRACE(Grampa, 3, "[insert] called", uptr(table), hash); TURF_ASSERT(table); TURF_ASSERT(hash != KeyTraits::NullHash); - ureg idx = hash; + ureg idx = ureg(hash); // Check hashed cell first, though it may not even belong to the bucket. CellGroup* group = table->getCellGroups() + ((idx & sizeMask) >> 2); diff --git a/junction/details/LeapFrog.h b/junction/details/LeapFrog.h index e5af7b8..800d737 100644 --- a/junction/details/LeapFrog.h +++ b/junction/details/LeapFrog.h @@ -191,7 +191,7 @@ struct LeapFrog { TURF_ASSERT(table); TURF_ASSERT(hash != KeyTraits::NullHash); ureg sizeMask = table->sizeMask; - ureg idx = hash; + ureg idx = ureg(hash); // Check hashed cell first, though it may not even belong to the bucket. CellGroup* group = table->getCellGroups() + ((idx & sizeMask) >> 2); diff --git a/junction/details/Linear.h b/junction/details/Linear.h index d2ee367..991f853 100644 --- a/junction/details/Linear.h +++ b/junction/details/Linear.h @@ -117,11 +117,11 @@ struct Linear { TURF_ASSERT(table); TURF_ASSERT(hash != KeyTraits::NullHash); ureg sizeMask = table->sizeMask; - for (ureg idx = hash;; idx++) { + for (ureg idx = ureg(hash);; idx++) { idx &= sizeMask; Cell* cell = table->getCells() + idx; // Load the hash that was there. - uptr probeHash = cell->hash.load(turf::Relaxed); + Hash probeHash = cell->hash.load(turf::Relaxed); if (probeHash == hash) { TURF_TRACE(Linear, 1, "[find] found existing cell", uptr(table), idx); return cell; @@ -139,11 +139,11 @@ struct Linear { TURF_ASSERT(hash != KeyTraits::NullHash); ureg sizeMask = table->sizeMask; - for (ureg idx = hash;; idx++) { + for (ureg idx = ureg(hash);; idx++) { idx &= sizeMask; cell = table->getCells() + idx; // Load the existing hash. - uptr probeHash = cell->hash.load(turf::Relaxed); + Hash probeHash = cell->hash.load(turf::Relaxed); if (probeHash == hash) { TURF_TRACE(Linear, 3, "[insert] found existing cell", uptr(table), idx); return InsertResult_AlreadyFound; // Key found in table. Return the existing cell. @@ -159,7 +159,7 @@ struct Linear { return InsertResult_Overflow; } // Try to reserve this cell. - uptr prevHash = cell->hash.compareExchange(KeyTraits::NullHash, hash, turf::Relaxed); + Hash prevHash = cell->hash.compareExchange(KeyTraits::NullHash, hash, turf::Relaxed); if (prevHash == KeyTraits::NullHash) { // Success. We reserved a new cell. TURF_TRACE(Linear, 5, "[insert] reserved cell", prevCellsRemaining, idx);