fix: shadowed local variable (-Wshadow)
[urcu.git] / tests / benchmark / test_urcu_hash.c
index f862adbf92c58d827dfaf0fc1601ebe5a1c4b212..d7e09b325f58f5b3641bb2e5354b8b82f58d63d9 100644 (file)
@@ -20,7 +20,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
 #include "test_urcu_hash.h"
 
 enum test_hash {
@@ -57,26 +56,31 @@ struct test_hash_cb test_hash_cb[] = {
 
 static enum test_hash test_choice = TEST_HASH_RW;
 
+static
 void (*get_sigusr1_cb(void))(int)
 {
        return test_hash_cb[test_choice].sigusr1;
 }
 
+static
 void (*get_sigusr2_cb(void))(int)
 {
        return test_hash_cb[test_choice].sigusr2;
 }
 
+static
 void *(*get_thr_reader_cb(void))(void *)
 {
        return test_hash_cb[test_choice].thr_reader;
 }
 
+static
 void *(*get_thr_writer_cb(void))(void *)
 {
        return test_hash_cb[test_choice].thr_writer;
 }
 
+static
 int (*get_populate_hash_cb(void))(void)
 {
        return test_hash_cb[test_choice].populate_hash;
@@ -158,11 +162,7 @@ void set_affinity(void)
        }
        CPU_ZERO(&mask);
        CPU_SET(cpu, &mask);
-#if SCHED_SETAFFINITY_ARGS == 2
-       sched_setaffinity(0, &mask);
-#else
        sched_setaffinity(0, sizeof(mask), &mask);
-#endif
 #endif /* HAVE_SCHED_SETAFFINITY */
 }
 
@@ -199,6 +199,7 @@ unsigned long test_compare(const void *key1, size_t key1_len,
                return 1;
 }
 
+static
 void *thr_count(void *arg)
 {
        printf_verbose("thread_begin %s, tid %lu\n",
@@ -264,14 +265,13 @@ void test_delete_all_nodes(struct cds_lfht *ht)
        printf("deleted %lu nodes.\n", count);
 }
 
+static
 void show_usage(int argc, char **argv)
 {
        printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
                argv[0]);
        printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
        printf("        [-r] [-w] (yield reader and/or writer)\n");
-#endif
        printf("        [-d delay] (writer period (us))\n");
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
        printf("        [-v] (verbose output)\n");
@@ -312,6 +312,7 @@ int main(int argc, char **argv)
        unsigned long count;
        long approx_before, approx_after;
        int i, a, ret, err, mainret = 0;
+       unsigned int i_thr;
        struct sigaction act;
        unsigned int remain;
        unsigned int nr_readers_created = 0, nr_writers_created = 0;
@@ -336,7 +337,7 @@ int main(int argc, char **argv)
                mainret = 1;
                goto end;
        }
-       
+
        err = sscanf(argv[3], "%lu", &duration);
        if (err != 1) {
                show_usage(argc, argv);
@@ -348,14 +349,12 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
                case 'r':
-                       yield_active |= YIELD_READ;
+                       rcu_debug_yield_enable(RCU_YIELD_READ);
                        break;
                case 'w':
-                       yield_active |= YIELD_WRITE;
+                       rcu_debug_yield_enable(RCU_YIELD_WRITE);
                        break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
@@ -623,10 +622,10 @@ int main(int argc, char **argv)
                goto end_close_pipe;
        }
 
-       for (i = 0; i < nr_readers; i++) {
-               err = pthread_create(&tid_reader[i],
+       for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+               err = pthread_create(&tid_reader[i_thr],
                                     NULL, get_thr_reader_cb(),
-                                    &count_reader[i]);
+                                    &count_reader[i_thr]);
                if (err != 0) {
                        errno = err;
                        mainret = 1;
@@ -635,10 +634,10 @@ int main(int argc, char **argv)
                }
                nr_readers_created++;
        }
-       for (i = 0; i < nr_writers; i++) {
-               err = pthread_create(&tid_writer[i],
+       for (i_thr = 0; i_thr < nr_writers; i_thr++) {
+               err = pthread_create(&tid_writer[i_thr],
                                     NULL, get_thr_writer_cb(),
-                                    &count_writer[i]);
+                                    &count_writer[i_thr]);
                if (err != 0) {
                        errno = err;
                        mainret = 1;
@@ -660,26 +659,26 @@ int main(int argc, char **argv)
        test_stop = 1;
 
 end_pthread_join:
-       for (i = 0; i < nr_readers_created; i++) {
-               err = pthread_join(tid_reader[i], &tret);
+       for (i_thr = 0; i_thr < nr_readers_created; i_thr++) {
+               err = pthread_join(tid_reader[i_thr], &tret);
                if (err != 0) {
                        errno = err;
                        mainret = 1;
                        perror("pthread_join");
                }
-               tot_reads += count_reader[i];
+               tot_reads += count_reader[i_thr];
        }
-       for (i = 0; i < nr_writers_created; i++) {
-               err = pthread_join(tid_writer[i], &tret);
+       for (i_thr = 0; i_thr < nr_writers_created; i_thr++) {
+               err = pthread_join(tid_writer[i_thr], &tret);
                if (err != 0) {
                        errno = err;
                        mainret = 1;
                        perror("pthread_join");
                }
-               tot_writes += count_writer[i].update_ops;
-               tot_add += count_writer[i].add;
-               tot_add_exist += count_writer[i].add_exist;
-               tot_remove += count_writer[i].remove;
+               tot_writes += count_writer[i_thr].update_ops;
+               tot_add += count_writer[i_thr].add;
+               tot_add_exist += count_writer[i_thr].add_exist;
+               tot_remove += count_writer[i_thr].remove;
        }
 
        /* teardown counter thread */
@@ -692,11 +691,11 @@ end_pthread_join:
        }
        {
                char msg[1] = { 0x42 };
-               ssize_t ret;
+               ssize_t sret;
 
                do {
-                       ret = write(count_pipe[1], msg, 1);     /* wakeup thread */
-               } while (ret == -1L && errno == EINTR);
+                       sret = write(count_pipe[1], msg, 1);    /* wakeup thread */
+               } while (sret == -1L && errno == EINTR);
        }
        err = pthread_join(tid_count, &tret);
        if (err != 0) {
This page took 0.02519 seconds and 4 git commands to generate.