urcu-qsbr: document compiler barrier
[urcu.git] / urcu.c
diff --git a/urcu.c b/urcu.c
index 5e8c6127a8c2f6413d56e95f66eba8c827595c85..b8567555d09ecbb22547aa6f236392d439eea871 100644 (file)
--- a/urcu.c
+++ b/urcu.c
@@ -67,7 +67,7 @@ int gp_futex;
  * Also has a RCU_GP_COUNT of 1, to accelerate the reader fast path.
  * Written to only by writer with mutex taken. Read by both writer and readers.
  */
-long rcu_gp_ctr = RCU_GP_COUNT;
+unsigned long rcu_gp_ctr = RCU_GP_COUNT;
 
 /*
  * Written to only by each individual reader. Read by both the reader and the
@@ -99,9 +99,9 @@ static void mutex_lock(pthread_mutex_t *mutex)
                        perror("Error in pthread mutex lock");
                        exit(-1);
                }
-               if (rcu_reader.need_mb) {
+               if (LOAD_SHARED(rcu_reader.need_mb)) {
                        smp_mb();
-                       rcu_reader.need_mb = 0;
+                       _STORE_SHARED(rcu_reader.need_mb, 0);
                        smp_mb();
                }
                poll(NULL,0,10);
@@ -155,8 +155,7 @@ static void force_mb_all_readers(void)
         * cache flush is enforced.
         */
        list_for_each_entry(index, &registry, head) {
-               index->need_mb = 1;
-               smp_mc();       /* write need_mb before sending the signal */
+               STORE_SHARED(index->need_mb, 1);
                pthread_kill(index->tid, SIGRCU);
        }
        /*
@@ -173,7 +172,7 @@ static void force_mb_all_readers(void)
         * the Linux Test Project (LTP).
         */
        list_for_each_entry(index, &registry, head) {
-               while (index->need_mb) {
+               while (LOAD_SHARED(index->need_mb)) {
                        pthread_kill(index->tid, SIGRCU);
                        poll(NULL, 0, 1);
                }
@@ -234,7 +233,7 @@ void update_counter_and_wait(void)
                }
 
                list_for_each_entry_safe(index, tmp, &registry, head) {
-                       if (!rcu_old_gp_ongoing(&index->ctr))
+                       if (!rcu_gp_ongoing(&index->ctr))
                                list_move(&index->head, &qsreaders);
                }
 
@@ -347,7 +346,7 @@ void rcu_register_thread(void)
 {
        rcu_reader.tid = pthread_self();
        assert(rcu_reader.need_mb == 0);
-       assert(rcu_reader.ctr == 0);
+       assert(!(rcu_reader.ctr & RCU_GP_CTR_NEST_MASK));
 
        mutex_lock(&rcu_gp_lock);
        rcu_init();     /* In case gcc does not support constructor attribute */
@@ -382,7 +381,7 @@ static void sigrcu_handler(int signo, siginfo_t *siginfo, void *context)
         * executed on.
         */
        smp_mb();
-       rcu_reader.need_mb = 0;
+       _STORE_SHARED(rcu_reader.need_mb, 0);
        smp_mb();
 }
 
This page took 0.023461 seconds and 4 git commands to generate.