Cleanup: enable signed/unsigned compare compiler warning
[urcu.git] / tests / benchmark / test_urcu.c
index e87e235a5b1c7937e993f3a460b468b3455f224d..24758a763d022b6c9eb9cbdfe48767d718ef0347 100644 (file)
@@ -20,8 +20,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
-#include "config.h"
 #include <stdio.h>
 #include <pthread.h>
 #include <stdlib.h>
 #include <urcu/tls-compat.h>
 #include "cpuset.h"
 #include "thread-id.h"
+#include <../common/debug-yield.h>
 
 /* hardcoded number of CPUs */
 #define NR_CPUS 16384
 
 #ifndef DYNAMIC_LINK_TEST
 #define _LGPL_SOURCE
-#else
-#define rcu_debug_yield_read()
 #endif
 #include <urcu.h>
 
@@ -247,9 +244,7 @@ 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("        [-e duration] (writer C.S. duration (in loops))\n");
@@ -266,6 +261,7 @@ int main(int argc, char **argv)
        unsigned long long *count_reader, *count_writer;
        unsigned long long tot_reads = 0, tot_writes = 0;
        int i, a;
+       unsigned int i_thr;
 
        if (argc < 4) {
                show_usage(argc, argv);
@@ -283,7 +279,7 @@ int main(int argc, char **argv)
                show_usage(argc, argv);
                return -1;
        }
-       
+
        err = sscanf(argv[3], "%lu", &duration);
        if (err != 1) {
                show_usage(argc, argv);
@@ -294,14 +290,12 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
                case 'r':
-                       rcu_yield_active |= RCU_YIELD_READ;
+                       rcu_debug_yield_enable(RCU_YIELD_READ);
                        break;
                case 'w':
-                       rcu_yield_active |= RCU_YIELD_WRITE;
+                       rcu_debug_yield_enable(RCU_YIELD_WRITE);
                        break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
@@ -353,15 +347,15 @@ int main(int argc, char **argv)
 
        next_aff = 0;
 
-       for (i = 0; i < nr_readers; i++) {
-               err = pthread_create(&tid_reader[i], NULL, thr_reader,
-                                    &count_reader[i]);
+       for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+               err = pthread_create(&tid_reader[i_thr], NULL, thr_reader,
+                                    &count_reader[i_thr]);
                if (err != 0)
                        exit(1);
        }
-       for (i = 0; i < nr_writers; i++) {
-               err = pthread_create(&tid_writer[i], NULL, thr_writer,
-                                    &count_writer[i]);
+       for (i_thr = 0; i_thr < nr_writers; i_thr++) {
+               err = pthread_create(&tid_writer[i_thr], NULL, thr_writer,
+                                    &count_writer[i_thr]);
                if (err != 0)
                        exit(1);
        }
@@ -374,19 +368,19 @@ int main(int argc, char **argv)
 
        test_stop = 1;
 
-       for (i = 0; i < nr_readers; i++) {
-               err = pthread_join(tid_reader[i], &tret);
+       for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+               err = pthread_join(tid_reader[i_thr], &tret);
                if (err != 0)
                        exit(1);
-               tot_reads += count_reader[i];
+               tot_reads += count_reader[i_thr];
        }
-       for (i = 0; i < nr_writers; i++) {
-               err = pthread_join(tid_writer[i], &tret);
+       for (i_thr = 0; i_thr < nr_writers; i_thr++) {
+               err = pthread_join(tid_writer[i_thr], &tret);
                if (err != 0)
                        exit(1);
-               tot_writes += count_writer[i];
+               tot_writes += count_writer[i_thr];
        }
-       
+
        printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
               tot_writes);
        printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu "
This page took 0.024949 seconds and 4 git commands to generate.