diff --git a/include/ck_ht.h b/include/ck_ht.h index ddd8f78..33be38c 100644 --- a/include/ck_ht.h +++ b/include/ck_ht.h @@ -188,12 +188,19 @@ ck_ht_entry_set(struct ck_ht_entry *entry, CK_CC_INLINE static void ck_ht_entry_set_direct(struct ck_ht_entry *entry, + ck_ht_hash_t h, uintptr_t key, uintptr_t value) { entry->key = key; entry->value = value; + +#ifndef CK_HT_PP + entry->hash = h.value; +#else + (void)h; +#endif return; } diff --git a/regressions/ck_ht/benchmark/parallel_direct.c b/regressions/ck_ht/benchmark/parallel_direct.c index 0f1b3e9..94e834c 100644 --- a/regressions/ck_ht/benchmark/parallel_direct.c +++ b/regressions/ck_ht/benchmark/parallel_direct.c @@ -162,7 +162,7 @@ table_replace(uintptr_t value) ck_ht_hash_t h; ck_ht_hash_direct(&h, &ht, value); - ck_ht_entry_set_direct(&entry, value, 6605241); + ck_ht_entry_set_direct(&entry, h, value, 6605241); return ck_ht_set_spmc(&ht, h, &entry); } @@ -187,7 +187,7 @@ table_insert(uintptr_t value) ck_ht_hash_t h; ck_ht_hash_direct(&h, &ht, value); - ck_ht_entry_set_direct(&entry, value, value); + ck_ht_entry_set_direct(&entry, h, value, value); return ck_ht_put_spmc(&ht, h, &entry); } diff --git a/regressions/ck_ht/validate/serial.c b/regressions/ck_ht/validate/serial.c index 200dbc3..9278927 100644 --- a/regressions/ck_ht/validate/serial.c +++ b/regressions/ck_ht/validate/serial.c @@ -254,7 +254,7 @@ main(void) l = 0; for (i = 0; i < sizeof(direct) / sizeof(*direct); i++) { ck_ht_hash_direct(&h, &ht, direct[i]); - ck_ht_entry_set_direct(&entry, direct[i], (uintptr_t)test[i]); + ck_ht_entry_set_direct(&entry, h, direct[i], (uintptr_t)test[i]); l += ck_ht_put_spmc(&ht, h, &entry) == false; } @@ -265,7 +265,7 @@ main(void) for (i = 0; i < sizeof(direct) / sizeof(*direct); i++) { ck_ht_hash_direct(&h, &ht, direct[i]); - ck_ht_entry_set_direct(&entry, direct[i], (uintptr_t)"REPLACED"); + ck_ht_entry_set_direct(&entry, h, direct[i], (uintptr_t)"REPLACED"); l += ck_ht_set_spmc(&ht, h, &entry) == false; } diff --git a/src/ck_ht.c b/src/ck_ht.c index 8f71f42..414c9dd 100644 --- a/src/ck_ht.c +++ b/src/ck_ht.c @@ -404,9 +404,17 @@ restart: key = ck_ht_entry_key(previous); key_length = ck_ht_entry_key_length(previous); +#ifndef CK_HT_PP + h.value = previous->hash; +#else table->h(&h, key, key_length, table->seed); +#endif } else { +#ifndef CK_HT_PP + h.value = previous->hash; +#else table->h(&h, &previous->key, sizeof(previous->key), table->seed); +#endif } offset = h.value & update->mask;