X-Git-Url: https://pd.if.org/git/?p=nbds;a=blobdiff_plain;f=map%2Fskiplist.c;h=e9c9b55d55a46e14d066a1d7209e6fdb65d23771;hp=5366d91adae9bcef2c5caa6f91cd95f6c61c8b47;hb=c7c053b290f15b7c8ba4f7327ead5a6fe836ec80;hpb=4ae7c1069667d8f067258d89676126f9b44226d6 diff --git a/map/skiplist.c b/map/skiplist.c index 5366d91..e9c9b55 100644 --- a/map/skiplist.c +++ b/map/skiplist.c @@ -275,13 +275,11 @@ map_val_t sl_cas (skiplist_t *sl, map_key_t key, map_val_t expectation, map_val_ if (old_item == NULL) { // There was not an item in the skiplist that matches the key. - if (EXPECT_FALSE((int64_t)expectation > 0 || expectation == CAS_EXPECT_EXISTS)) { + if (EXPECT_FALSE(expectation != CAS_EXPECT_DOES_NOT_EXIST && expectation != CAS_EXPECT_WHATEVER)) { TRACE("l1", "sl_cas: the expectation was not met, the skiplist was not changed", 0, 0); return DOES_NOT_EXIST; // failure } - ASSERT(expectation == CAS_EXPECT_DOES_NOT_EXIST || expectation == CAS_EXPECT_WHATEVER); - // First insert into the bottom level. TRACE("s3", "sl_cas: attempting to insert item between %p and %p", preds[0], nexts[0]); map_key_t new_key = sl->key_type == NULL ? key : (map_key_t)sl->key_type->clone((void *)key); @@ -470,7 +468,7 @@ void sl_print (skiplist_t *sl) { int i = 0; while (item) { int is_marked = HAS_MARK(item->next[0]); - printf("%s%p:0x%llx ", is_marked ? "*" : "", item, (map_key_t)item->key); + printf("%s%p:0x%llx ", is_marked ? "*" : "", item, (uint64_t)item->key); if (item != sl->head) { printf("[%d]", item->top_level); } else { @@ -495,7 +493,11 @@ void sl_print (skiplist_t *sl) { sl_iter_t *sl_iter_begin (skiplist_t *sl, map_key_t key) { sl_iter_t *iter = (sl_iter_t *)nbd_malloc(sizeof(sl_iter_t)); - find_preds(NULL, &iter->next, 0, sl, key, FALSE); + if (key != DOES_NOT_EXIST) { + find_preds(NULL, &iter->next, 0, sl, key, FALSE); + } else { + iter->next = GET_NODE(sl->head->next[0]); + } return iter; }