Fix MSVC warnings with u64 keys
authorJeff Preshing <filter-github@preshing.com>
Wed, 10 Feb 2016 13:59:29 +0000 (08:59 -0500)
committerJeff Preshing <filter-github@preshing.com>
Wed, 10 Feb 2016 13:59:29 +0000 (08:59 -0500)
junction/ConcurrentMap_Grampa.h
junction/ConcurrentMap_LeapFrog.h
junction/ConcurrentMap_Linear.h
junction/details/Grampa.h
junction/details/LeapFrog.h
junction/details/Linear.h

index b0d6cec75b95cde1da4bed6912d2904cd1d37c81..8d67f2219650c9a4b5603617489f3d95b46fc94d 100644 (file)
@@ -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,
index 0a51ad97334668dd56df37a8e1ea6677672b7873..a9dc4a33369f61b15187999daac0802b417e4276 100644 (file)
@@ -37,7 +37,7 @@ private:
     turf::Atomic<typename Details::Table*> 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() {
index 32b2a37e01bfb491dbde83a680ad0a653ab33aed..4cf349d062c1c64eda17a35bf45031206271b4b3 100644 (file)
@@ -37,7 +37,7 @@ private:
     turf::Atomic<typename Details::Table*> 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));
     }
index e6287578e0fc33955a4e00a548126144fffbb08c..9f85df249fba655a458c13ab21708e5a93cf4879 100644 (file)
@@ -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);
index e5af7b8211c7d74991a0a6c682d64db121c7f23d..800d7374e2dcc1470c95e90c03ed090d54f2a7b7 100644 (file)
@@ -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);
index d2ee367dce8a0d0e3ceaa926e04b5b2f1cb1eb61..991f853f708f6e1a528c91ca47e5848fe9d42821 100644 (file)
@@ -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);