#if (CAA_BITS_PER_LONG == 32)
static
-unsigned long test_hash(void *_key, size_t length, unsigned long seed)
+unsigned long test_hash(const void *_key, size_t length, unsigned long seed)
{
unsigned int key = (unsigned int) _key;
}
#else
static
-unsigned long test_hash(void *_key, size_t length, unsigned long seed)
+unsigned long test_hash(const void *_key, size_t length, unsigned long seed)
{
union {
uint64_t v64;
#endif
static
-unsigned long test_compare(void *key1, size_t key1_len,
- void *key2, size_t key2_len)
+unsigned long test_compare(const void *key1, size_t key1_len,
+ const void *key2, size_t key2_len)
{
if (caa_unlikely(key1_len != key2_len))
return -1;
}
static
-int test_match(struct cds_lfht_node *node, void *key)
+int test_match(struct cds_lfht_node *node, const void *key)
{
struct lfht_test_node *test_node = to_test_node(node);
{
assert(key_len == sizeof(unsigned long));
- cds_lfht_lookup(ht, test_match,
- test_hash(key, key_len, TEST_HASH_SEED),
- key, iter);
+ cds_lfht_lookup(ht, test_hash(key, key_len, TEST_HASH_SEED),
+ test_match, key, iter);
}
void *thr_count(void *arg)
sizeof(void *));
rcu_read_lock();
if (add_unique) {
- ret_node = cds_lfht_add_unique(test_ht, test_match, node->key,
+ ret_node = cds_lfht_add_unique(test_ht,
test_hash(node->key, node->key_len, TEST_HASH_SEED),
- &node->node);
+ test_match, node->key, &node->node);
} else {
if (add_replace)
- ret_node = cds_lfht_add_replace(test_ht, test_match, node->key,
+ ret_node = cds_lfht_add_replace(test_ht,
test_hash(node->key, node->key_len, TEST_HASH_SEED),
- &node->node);
+ test_match, node->key, &node->node);
else
cds_lfht_add(test_ht,
test_hash(node->key, node->key_len, TEST_HASH_SEED),
sizeof(void *));
rcu_read_lock();
if (add_unique) {
- ret_node = cds_lfht_add_unique(test_ht, test_match, node->key,
+ ret_node = cds_lfht_add_unique(test_ht,
test_hash(node->key, node->key_len, TEST_HASH_SEED),
- &node->node);
+ test_match, node->key, &node->node);
} else {
if (add_replace)
- ret_node = cds_lfht_add_replace(test_ht, test_match, node->key,
+ ret_node = cds_lfht_add_replace(test_ht,
test_hash(node->key, node->key_len, TEST_HASH_SEED),
- &node->node);
+ test_match, node->key, &node->node);
else
cds_lfht_add(test_ht,
test_hash(node->key, node->key_len, TEST_HASH_SEED),
return -1;
}
- if (min_hash_alloc_size && min_hash_alloc_size * (min_hash_alloc_size - 1)) {
+ if (min_hash_alloc_size && min_hash_alloc_size & (min_hash_alloc_size - 1)) {
printf("Error: Min hash alloc size %lu is not a power of 2.\n",
min_hash_alloc_size);
return -1;
* thread from the point of view of resize.
*/
rcu_register_thread();
- test_ht = cds_lfht_new(init_hash_size, min_hash_alloc_size,
+ test_ht = cds_lfht_new(init_hash_size, min_hash_alloc_size, (1UL << 18),
(opt_auto_resize ? CDS_LFHT_AUTO_RESIZE : 0) |
CDS_LFHT_ACCOUNTING, NULL);
ret = populate_hash();