]> pd.if.org Git - nbds/blobdiff - map/list.c
Mac OS fix
[nbds] / map / list.c
index 0d9c11f24f275254c238e9a538f5e8332b3b2729..3b1787327984481cb9228a8150f3d7d69c900b97 100644 (file)
@@ -34,13 +34,14 @@ struct ll {
 };
 
 // Marking the <next> field of a node logically removes it from the list
-#define  MARK_NODE(x) TAG_VALUE((markable_t)(x), TAG1)
-#define   HAS_MARK(x) (IS_TAGGED((x), TAG1) == TAG1)
+#define  MARK_NODE(x) TAG_VALUE((markable_t)(x), 0x1)
+#define   HAS_MARK(x) (IS_TAGGED((x), 0x1) == 0x1)
 #define   GET_NODE(x) ((node_t *)(x))
-#define STRIP_MARK(x) ((node_t *)STRIP_TAG((x), TAG1))
+#define STRIP_MARK(x) ((node_t *)STRIP_TAG((x), 0x1))
 
 static node_t *node_alloc (map_key_t key, map_val_t val) {
     node_t *item = (node_t *)nbd_malloc(sizeof(node_t));
+    assert(!HAS_MARK((size_t)item));
     item->key = key;
     item->val = val;
     return item;
@@ -297,7 +298,7 @@ map_val_t ll_remove (list_t *ll, map_key_t key) {
         }
     } while (next != old_next);
     TRACE("l2", "ll_remove: logically removed item %p", item, 0);
-    ASSERT(HAS_MARK(((volatile node_t *)item)->next));
+    ASSERT(HAS_MARK(VOLATILE_DEREF(item).next));
 
     // Atomically swap out the item's value in case another thread is updating the item while we are 
     // removing it. This establishes which operation occurs first logically, the update or the remove. 
@@ -376,7 +377,7 @@ map_val_t ll_iter_next (ll_iter_t *iter, map_key_t *key_ptr) {
         do {
             item = iter->pred->next;
             haz_set(hp0, STRIP_MARK(item));
-        } while (item != ((volatile node_t *)iter->pred)->next);
+        } while (item != VOLATILE_DEREF(iter->pred).next);
 #endif//LIST_USE_HAZARD_POINTER
         iter->pred = STRIP_MARK(item);
         if (iter->pred == NULL)