+
+ /*
+ * Adding a smp_mb() which is _not_ formally required, but makes the
+ * model easier to understand. It does not have a big performance impact
+ * anyway, given this is the write-side.
+ */
+ smp_mb();
+
+ switch_next_urcu_qparity(); /* 1 -> 0 */
+
+ /*
+ * Must commit qparity update to memory before waiting for parity
+ * 1 quiescent state. Failure to do so could result in the writer
+ * waiting forever while new readers are always accessing data (no
+ * progress).
+ * Ensured by STORE_SHARED and LOAD_SHARED.
+ */
+
+ /*
+ * Adding a smp_mb() which is _not_ formally required, but makes the
+ * model easier to understand. It does not have a big performance impact
+ * anyway, given this is the write-side.
+ */
+ smp_mb();
+
+ /*
+ * Wait for previous parity to be empty of readers.
+ */
+ wait_for_quiescent_state(); /* Wait readers in parity 1 */
+
+ /* Finish waiting for reader threads before letting the old ptr being
+ * freed. Must be done within internal_urcu_lock because it iterates on
+ * reader threads. */
+ force_mb_all_threads();
+
+ internal_urcu_unlock();
+}
+
+/*
+ * library wrappers to be used by non-LGPL compatible source code.
+ */
+
+void rcu_read_lock(void)
+{
+ _rcu_read_lock();
+}
+
+void rcu_read_unlock(void)
+{
+ _rcu_read_unlock();
+}
+
+void *rcu_dereference(void *p)
+{
+ return _rcu_dereference(p);
+}
+
+void *rcu_assign_pointer_sym(void **p, void *v)
+{
+ wmb();
+ return STORE_SHARED(p, v);
+}
+
+void *rcu_xchg_pointer_sym(void **p, void *v)
+{
+ wmb();
+ return xchg(p, v);
+}
+
+void *rcu_cmpxchg_pointer_sym(void **p, void *old, void *_new)
+{
+ wmb();
+ return cmpxchg(p, old, _new);
+}
+
+void *rcu_publish_content_sym(void **p, void *v)
+{
+ void *oldptr;
+
+ oldptr = _rcu_xchg_pointer(p, v);
+ synchronize_rcu();