Use urcu/tls-compat.h
[urcu.git] / tests / test_urcu_hash.c
index accf3c1ab1ff76a0e37b876da268ba690122e916..5710de08135f8e0f58be45bfec59cca94636031e 100644 (file)
@@ -82,13 +82,13 @@ int (*get_populate_hash_cb(void))(void)
        return test_hash_cb[test_choice].populate_hash;
 }
 
-unsigned int __thread rand_lookup;
-unsigned long __thread nr_add;
-unsigned long __thread nr_addexist;
-unsigned long __thread nr_del;
-unsigned long __thread nr_delnoent;
-unsigned long __thread lookup_fail;
-unsigned long __thread lookup_ok;
+DEFINE_URCU_TLS(unsigned int, rand_lookup);
+DEFINE_URCU_TLS(unsigned long, nr_add);
+DEFINE_URCU_TLS(unsigned long, nr_addexist);
+DEFINE_URCU_TLS(unsigned long, nr_del);
+DEFINE_URCU_TLS(unsigned long, nr_delnoent);
+DEFINE_URCU_TLS(unsigned long, lookup_fail);
+DEFINE_URCU_TLS(unsigned long, lookup_ok);
 
 struct cds_lfht *test_ht;
 
@@ -126,8 +126,8 @@ int use_affinity = 0;
 
 pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER;
 
-unsigned long long __thread nr_writes;
-unsigned long long __thread nr_reads;
+DEFINE_URCU_TLS(unsigned long long, nr_writes);
+DEFINE_URCU_TLS(unsigned long long, nr_reads);
 
 unsigned int nr_readers;
 unsigned int nr_writers;
@@ -560,6 +560,10 @@ int main(int argc, char **argv)
                                (opt_auto_resize ? CDS_LFHT_AUTO_RESIZE : 0) |
                                CDS_LFHT_ACCOUNTING, NULL);
        }
+       if (!test_ht) {
+               printf("Error allocating hash table.\n");
+               return -1;
+       }
 
        /*
         * Hash Population needs to be seen as a RCU reader
This page took 0.023154 seconds and 4 git commands to generate.