CDS API: removal of rcu_read lock/unlock dep, removal of call_rcu argument from init
[urcu.git] / tests / test_urcu_lfq.c
index 5fd0ff38cb0ecd15a462072394a18ac7598a3ae1..82a90b0cdecc23f05c3572cf6b6819f00ac72531 100644 (file)
 #include <unistd.h>
 #include <stdio.h>
 #include <assert.h>
-#include <sys/syscall.h>
 #include <sched.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
 
+#ifdef __linux__
+#include <syscall.h>
+#endif
+
 /* hardcoded number of CPUs */
 #define NR_CPUS 16384
 
@@ -62,7 +65,7 @@ static inline pid_t gettid(void)
 #define _LGPL_SOURCE
 #endif
 #include <urcu.h>
-#include <urcu/rculfqueue.h>
+#include <urcu/cds.h>
 #include <urcu-defer.h>
 
 static volatile int test_go, test_stop;
@@ -200,17 +203,10 @@ fail:
 
 }
 
-static void rcu_release_node(struct urcu_ref *ref)
-{
-       struct cds_lfq_node_rcu *node = caa_container_of(ref, struct cds_lfq_node_rcu, ref);
-       defer_rcu(free, node);
-       //synchronize_rcu();
-       //free(node);
-}
-
 void *thr_dequeuer(void *_count)
 {
        unsigned long long *count = _count;
+       int ret;
 
        printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
                        "dequeuer", pthread_self(), (unsigned long)gettid());
@@ -230,11 +226,11 @@ void *thr_dequeuer(void *_count)
        cmm_smp_mb();
 
        for (;;) {
-               struct cds_lfq_node_rcu *node = cds_lfq_dequeue_rcu(&q,
-                                                           rcu_release_node);
+               struct cds_lfq_node_rcu *node;
 
+               node = cds_lfq_dequeue_rcu(&q);
                if (node) {
-                       urcu_ref_put(&node->ref, rcu_release_node);
+                       defer_rcu(free, node);
                        nr_successful_dequeues++;
                }
 
@@ -247,7 +243,6 @@ void *thr_dequeuer(void *_count)
 
        rcu_unregister_thread();
        rcu_defer_unregister_thread();
-
        printf_verbose("dequeuer thread_end, thread id : %lx, tid %lu, "
                       "dequeues %llu, successful_dequeues %llu\n",
                       pthread_self(), (unsigned long)gettid(), nr_dequeues,
@@ -257,20 +252,14 @@ void *thr_dequeuer(void *_count)
        return ((void*)2);
 }
 
-static void release_node(struct urcu_ref *ref)
-{
-       struct cds_lfq_node_rcu *node = caa_container_of(ref, struct cds_lfq_node_rcu, ref);
-       free(node);
-}
-
 void test_end(struct cds_lfq_queue_rcu *q, unsigned long long *nr_dequeues)
 {
        struct cds_lfq_node_rcu *node;
 
        do {
-               node = cds_lfq_dequeue_rcu(q, release_node);
+               node = cds_lfq_dequeue_rcu(q);
                if (node) {
-                       urcu_ref_put(&node->ref, release_node);
+                       free(node);     /* no more concurrent access */
                        (*nr_dequeues)++;
                }
        } while (node);
@@ -412,6 +401,8 @@ int main(int argc, char **argv)
        }
        
        test_end(&q, &end_dequeues);
+       err = cds_lfq_destroy_rcu(&q);
+       assert(!err);
 
        printf_verbose("total number of enqueues : %llu, dequeues %llu\n",
                       tot_enqueues, tot_dequeues);
This page took 0.023986 seconds and 4 git commands to generate.