Remove glibc < 2.4 compat code for sched_setaffinity
[urcu.git] / tests / benchmark / test_perthreadlock.c
index d76b45655ab13f1a94eb07d6519b870a8f80bda0..6e079274448a899a686ce24b6e64de4b4a2767c4 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>
@@ -35,7 +33,6 @@
 
 #include <urcu/arch.h>
 #include <urcu/tls-compat.h>
-#include "cpuset.h"
 #include "thread-id.h"
 
 /* hardcoded number of CPUs */
@@ -116,11 +113,7 @@ static 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 */
 }
 
@@ -222,7 +215,7 @@ void *thr_writer(void *data)
        cmm_smp_mb();
 
        for (;;) {
-               for (tidx = 0; tidx < nr_readers; tidx++) {
+               for (tidx = 0; tidx < (long)nr_readers; tidx++) {
                        urcu_mutex_lock(&per_thread_lock[tidx].lock);
                }
                test_array.a = 0;
@@ -265,6 +258,7 @@ int main(int argc, char **argv)
        void *tret;
        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 +277,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);
@@ -343,21 +337,21 @@ int main(int argc, char **argv)
        tot_nr_reads = calloc(nr_readers, sizeof(*tot_nr_reads));
        tot_nr_writes = calloc(nr_writers, sizeof(*tot_nr_writes));
        per_thread_lock = calloc(nr_readers, sizeof(*per_thread_lock));
-       for (i = 0; i < nr_readers; i++) {
-               pthread_mutex_init(&per_thread_lock[i].lock, NULL);
+       for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+               pthread_mutex_init(&per_thread_lock[i_thr].lock, NULL);
        }
 
        next_aff = 0;
 
-       for (i = 0; i < nr_readers; i++) {
-               err = pthread_create(&tid_reader[i], NULL, thr_reader,
-                                    (void *)(long)i);
+       for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+               err = pthread_create(&tid_reader[i_thr], NULL, thr_reader,
+                                    (void *)(long)i_thr);
                if (err != 0)
                        exit(1);
        }
-       for (i = 0; i < nr_writers; i++) {
-               err = pthread_create(&tid_writer[i], NULL, thr_writer,
-                                    (void *)(long)i);
+       for (i_thr = 0; i_thr < nr_writers; i_thr++) {
+               err = pthread_create(&tid_writer[i_thr], NULL, thr_writer,
+                                    (void *)(long)i_thr);
                if (err != 0)
                        exit(1);
        }
@@ -370,17 +364,17 @@ 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 += tot_nr_reads[i];
+               tot_reads += tot_nr_reads[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 += tot_nr_writes[i];
+               tot_writes += tot_nr_writes[i_thr];
        }
 
        printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
This page took 0.024984 seconds and 4 git commands to generate.