diff --git a/include/ck_ht.h b/include/ck_ht.h index bf5ff9a..7664ab7 100644 --- a/include/ck_ht.h +++ b/include/ck_ht.h @@ -49,8 +49,10 @@ enum ck_ht_mode { CK_HT_MODE_BYTESTRING }; -#if defined(__x86_64__) && defined(CK_MD_POINTER_PACK_ENABLE) +#if defined(CK_MD_POINTER_PACK_ENABLE) && defined(CK_MD_VMA_BITS) #define CK_HT_PP +#define CK_HT_KEY_LENGTH ((sizeof(void *) * 8) - CK_MD_VMA_BITS) +#define CK_HT_KEY_MASK ((1U << CK_HT_KEY_LENGTH) - 1) #endif struct ck_ht_entry { @@ -132,7 +134,7 @@ ck_ht_entry_key_set(ck_ht_entry_t *entry, const void *key, uint16_t key_length) { #ifdef CK_HT_PP - entry->key = (uintptr_t)key | ((uintptr_t)key_length << 48); + entry->key = (uintptr_t)key | ((uintptr_t)key_length << CK_MD_VMA_BITS); #else entry->key = (uintptr_t)key; entry->key_length = key_length; @@ -146,7 +148,7 @@ ck_ht_entry_key(ck_ht_entry_t *entry) { #ifdef CK_HT_PP - return (void *)(entry->key & (((uintptr_t)1 << 48) - 1)); + return (void *)(entry->key & (((uintptr_t)1 << CK_MD_VMA_BITS) - 1)); #else return (void *)entry->key; #endif @@ -157,7 +159,7 @@ ck_ht_entry_key_length(ck_ht_entry_t *entry) { #ifdef CK_HT_PP - return entry->key >> 48; + return entry->key >> CK_MD_VMA_BITS; #else return entry->key_length; #endif @@ -168,7 +170,7 @@ ck_ht_entry_value(ck_ht_entry_t *entry) { #ifdef CK_HT_PP - return (void *)(entry->value & (((uintptr_t)1 << 48) - 1)); + return (void *)(entry->value & (((uintptr_t)1 << CK_MD_VMA_BITS) - 1)); #else return (void *)entry->value; #endif @@ -183,8 +185,8 @@ ck_ht_entry_set(struct ck_ht_entry *entry, { #ifdef CK_HT_PP - entry->key = (uintptr_t)key | ((uintptr_t)key_length << 48); - entry->value = (uintptr_t)value | ((uintptr_t)(h.value >> 32) << 48); + entry->key = (uintptr_t)key | ((uintptr_t)key_length << CK_MD_VMA_BITS); + entry->value = (uintptr_t)value | ((uintptr_t)(h.value >> 32) << CK_MD_VMA_BITS); #else entry->key = (uintptr_t)key; entry->value = (uintptr_t)value; diff --git a/src/Makefile b/src/Makefile index 355484f..6b6a001 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,7 +8,8 @@ OBJECTS=ck_barrier_centralized.o \ ck_epoch.o \ ck_ht.o \ ck_hp.o \ - ck_bag.o + ck_bag.o \ + ck_hs.o all: libck.so libck.a @@ -24,6 +25,9 @@ ck_bag.o: ../include/ck_bag.h ck_bag.c ck_epoch.o: ../include/ck_epoch.h ck_epoch.c $(CC) $(CFLAGS) -c -o ck_epoch.o ck_epoch.c +ck_hs.o: ../include/ck_hs.h ck_hs.c + $(CC) $(CFLAGS) -c -o ck_hs.o ck_hs.c + ck_ht.o: ../include/ck_ht.h ck_ht.c $(CC) $(CFLAGS) -c -o ck_ht.o ck_ht.c diff --git a/src/ck_ht.c b/src/ck_ht.c index bb55c64..30d4f2e 100644 --- a/src/ck_ht.c +++ b/src/ck_ht.c @@ -258,7 +258,7 @@ retry: continue; #ifdef CK_HT_PP - if (cursor->value >> 48 != ((h.value >> 32) & 0xFFFF)) + if ((cursor->value >> CK_MD_VMA_BITS) != ((h.value >> 32) & CK_HT_KEY_MASK)) continue; #else if (cursor->hash != h.value) @@ -369,7 +369,7 @@ retry: if (k != key_length) continue; #ifdef CK_HT_PP - if (snapshot->value >> 48 != ((h.value >> 32) & 0xFFFF)) + if ((snapshot->value >> CK_MD_VMA_BITS) != ((h.value >> 32) & CK_HT_KEY_MASK)) continue; #else if (snapshot->hash != h.value)