Add `urcu_posix_assert()` as `assert()` replacement
[urcu.git] / tests / benchmark / test_urcu_lfq.c
index 45a6bb9eafc0ee9dfbbdd9a293245b0bf51ee377..490e8b0527154f3f55edcf9beb0c44e0a1080aa5 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 
@@ -78,7 +78,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static void set_affinity(void)
 {
-#if HAVE_SCHED_SETAFFINITY
+#ifdef HAVE_SCHED_SETAFFINITY
        cpu_set_t mask;
        int cpu, ret;
 #endif /* HAVE_SCHED_SETAFFINITY */
@@ -86,7 +86,7 @@ static void set_affinity(void)
        if (!use_affinity)
                return;
 
-#if HAVE_SCHED_SETAFFINITY
+#ifdef HAVE_SCHED_SETAFFINITY
        ret = pthread_mutex_lock(&affinity_mutex);
        if (ret) {
                perror("Error in pthread mutex lock");
@@ -134,6 +134,7 @@ struct test {
 
 static struct cds_lfq_queue_rcu q;
 
+static
 void *thr_enqueuer(void *_count)
 {
        unsigned long long *count = _count;
@@ -189,6 +190,7 @@ void free_node_cb(struct rcu_head *head)
        free(node);
 }
 
+static
 void *thr_dequeuer(void *_count)
 {
        unsigned long long *count = _count;
@@ -238,23 +240,25 @@ void *thr_dequeuer(void *_count)
        return ((void*)2);
 }
 
-void test_end(struct cds_lfq_queue_rcu *q, unsigned long long *nr_dequeues)
+static
+void test_end(unsigned long long *nr_dequeues_l)
 {
        struct cds_lfq_node_rcu *snode;
 
        do {
-               snode = cds_lfq_dequeue_rcu(q);
+               snode = cds_lfq_dequeue_rcu(&q);
                if (snode) {
                        struct test *node;
 
                        node = caa_container_of(snode, struct test, list);
                        free(node);     /* no more concurrent access */
-                       (*nr_dequeues)++;
+                       (*nr_dequeues_l)++;
                }
        } while (snode);
 }
 
-void show_usage(int argc, char **argv)
+static
+void show_usage(char **argv)
 {
        printf("Usage : %s nr_dequeuers nr_enqueuers duration (s) <OPTIONS>\n",
                argv[0]);
@@ -280,25 +284,25 @@ int main(int argc, char **argv)
        unsigned int i_thr;
 
        if (argc < 4) {
-               show_usage(argc, argv);
+               show_usage(argv);
                return -1;
        }
 
        err = sscanf(argv[1], "%u", &nr_dequeuers);
        if (err != 1) {
-               show_usage(argc, argv);
+               show_usage(argv);
                return -1;
        }
 
        err = sscanf(argv[2], "%u", &nr_enqueuers);
        if (err != 1) {
-               show_usage(argc, argv);
+               show_usage(argv);
                return -1;
        }
 
        err = sscanf(argv[3], "%lu", &duration);
        if (err != 1) {
-               show_usage(argc, argv);
+               show_usage(argv);
                return -1;
        }
 
@@ -308,7 +312,7 @@ int main(int argc, char **argv)
                switch (argv[i][1]) {
                case 'a':
                        if (argc < i + 2) {
-                               show_usage(argc, argv);
+                               show_usage(argv);
                                return -1;
                        }
                        a = atoi(argv[++i]);
@@ -318,14 +322,14 @@ int main(int argc, char **argv)
                        break;
                case 'c':
                        if (argc < i + 2) {
-                               show_usage(argc, argv);
+                               show_usage(argv);
                                return -1;
                        }
                        rduration = atol(argv[++i]);
                        break;
                case 'd':
                        if (argc < i + 2) {
-                               show_usage(argc, argv);
+                               show_usage(argv);
                                return -1;
                        }
                        wdelay = atol(argv[++i]);
@@ -398,9 +402,9 @@ int main(int argc, char **argv)
                tot_successful_dequeues += count_dequeuer[2 * i_thr + 1];
        }
 
-       test_end(&q, &end_dequeues);
+       test_end(&end_dequeues);
        err = cds_lfq_destroy_rcu(&q);
-       assert(!err);
+       urcu_posix_assert(!err);
 
        printf_verbose("total number of enqueues : %llu, dequeues %llu\n",
                       tot_enqueues, tot_dequeues);
This page took 0.024971 seconds and 4 git commands to generate.