use smp_*mb()
[urcu.git] / urcu.h
diff --git a/urcu.h b/urcu.h
index 03764ab33dbe241b643b72ef9cbfd6757662fa3b..92b31df603d157ffa942534af1d5731d912c2342 100644 (file)
--- a/urcu.h
+++ b/urcu.h
 #define rmb()   asm volatile("lfence":::"memory")
 #define wmb()   asm volatile("sfence" ::: "memory")
 
+/* Assume SMP machine, given we don't have this information */
+#define CONFIG_SMP 1
+
+#ifdef CONFIG_SMP
+#define smp_mb()       mb()
+#define smp_rmb()      rmb()
+#define smp_wmb()      wmb()
+#else
+#define smp_mb()       barrier()
+#define smp_rmb()      barrier()
+#define smp_wmb()      barrier()
+#endif
+
 static inline void atomic_inc(int *v)
 {
        asm volatile("lock; incl %0"
@@ -173,7 +186,7 @@ static inline void debug_yield_init(void)
 #ifdef DEBUG_FULL_MB
 static inline void read_barrier()
 {
-       mb();
+       smp_mb();
 }
 #else
 static inline void read_barrier()
@@ -207,10 +220,14 @@ static inline int rcu_old_gp_ongoing(long *value)
        if (value == NULL)
                return 0;
        debug_yield_write();
+       /*
+        * Make sure both tests below are done on the same version of *value
+        * to insure consistency.
+        */
        v = ACCESS_ONCE(*value);
        debug_yield_write();
        return (v & RCU_GP_CTR_NEST_MASK) &&
-                ((v ^ ACCESS_ONCE(urcu_gp_ctr)) & RCU_GP_CTR_BIT);
+                ((v ^ urcu_gp_ctr) & RCU_GP_CTR_BIT);
 }
 
 static inline void rcu_read_lock(void)
This page took 0.022455 seconds and 4 git commands to generate.