+ uint32_t a, b, c;
+
+ /* Set up the internal state */
+ a = b = c = 0xdeadbeef + ((uint32_t) (length << 2)) + *pc;
+ c += *pb;
+
+ /*----------------------------------------- handle most of the key */
+ while (length > 3) {
+ a += k[0];
+ b += k[1];
+ c += k[2];
+ mix(a, b, c);
+ length -= 3;
+ k += 3;
+ }
+
+ /*----------------------------------- handle the last 3 uint32_t's */
+ switch (length) { /* all the case statements fall through */
+ case 3: c += k[2];
+ case 2: b += k[1];
+ case 1: a += k[0];
+ final(a, b, c);
+ case 0: /* case 0: nothing left to add */
+ break;
+ }
+ /*---------------------------------------------- report the result */
+ *pc = c;
+ *pb = b;
+}
+
+#if (CAA_BITS_PER_LONG == 32)
+static
+unsigned long test_hash(const void *_key, size_t length, unsigned long seed)
+{
+ unsigned int key = (unsigned int) _key;
+
+ assert(length == sizeof(unsigned int));
+ return hash_u32(&key, 1, seed);
+}
+#else
+static
+unsigned long test_hash(const void *_key, size_t length, unsigned long seed)
+{
+ union {
+ uint64_t v64;
+ uint32_t v32[2];
+ } v;
+ union {
+ uint64_t v64;
+ uint32_t v32[2];
+ } key;
+
+ assert(length == sizeof(unsigned long));
+ v.v64 = (uint64_t) seed;
+ key.v64 = (uint64_t) _key;
+ hashword2(key.v32, 2, &v.v32[0], &v.v32[1]);
+ return v.v64;
+}
+#endif
+
+static
+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;
+ assert(key1_len == sizeof(unsigned long));
+ if (key1 == key2)
+ return 0;
+ else
+ return 1;
+}
+
+static
+int test_match(struct cds_lfht_node *node, const void *key)
+{
+ struct lfht_test_node *test_node = to_test_node(node);
+
+ return !test_compare(test_node->key, test_node->key_len,
+ key, sizeof(unsigned long));
+}
+
+static inline
+void cds_lfht_test_lookup(struct cds_lfht *ht, void *key, size_t key_len,
+ struct cds_lfht_iter *iter)
+{
+ assert(key_len == sizeof(unsigned long));
+
+ cds_lfht_lookup(ht, test_hash(key, key_len, TEST_HASH_SEED),
+ test_match, key, iter);
+}
+
+void *thr_count(void *arg)
+{
+ printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
+ "counter", pthread_self(), (unsigned long)gettid());
+
+ rcu_register_thread();
+
+ for (;;) {
+ unsigned long count;
+ long approx_before, approx_after;
+ ssize_t len;
+ char buf[1];
+
+ rcu_thread_offline();
+ len = read(count_pipe[0], buf, 1);
+ rcu_thread_online();
+ if (caa_unlikely(!test_duration_read()))
+ break;
+ if (len != 1)
+ continue;
+ /* Accounting */
+ printf("Counting nodes... ");
+ fflush(stdout);
+ rcu_read_lock();
+ cds_lfht_count_nodes(test_ht, &approx_before, &count,
+ &approx_after);
+ rcu_read_unlock();
+ printf("done.\n");
+ printf("Approximation before node accounting: %ld nodes.\n",
+ approx_before);
+ printf("Accounting of nodes in the hash table: "
+ "%lu nodes.\n",
+ count);
+ printf("Approximation after node accounting: %ld nodes.\n",
+ approx_after);
+ }
+ rcu_unregister_thread();
+ return NULL;