+struct rcu_reader __thread rcu_reader;
+
+#ifdef DEBUG_YIELD
+unsigned int yield_active;
+unsigned int __thread rand_yield;
+#endif
+
+static CDS_LIST_HEAD(registry);
+
+static void mutex_lock(pthread_mutex_t *mutex)
+{
+ int ret;
+
+#ifndef DISTRUST_SIGNALS_EXTREME
+ ret = pthread_mutex_lock(mutex);
+ if (ret) {
+ perror("Error in pthread mutex lock");
+ exit(-1);
+ }
+#else /* #ifndef DISTRUST_SIGNALS_EXTREME */
+ while ((ret = pthread_mutex_trylock(mutex)) != 0) {
+ if (ret != EBUSY && ret != EINTR) {
+ printf("ret = %d, errno = %d\n", ret, errno);
+ perror("Error in pthread mutex lock");
+ exit(-1);
+ }
+ if (CMM_LOAD_SHARED(rcu_reader.need_mb)) {
+ cmm_smp_mb();
+ _CMM_STORE_SHARED(rcu_reader.need_mb, 0);
+ cmm_smp_mb();
+ }
+ poll(NULL,0,10);
+ }
+#endif /* #else #ifndef DISTRUST_SIGNALS_EXTREME */
+}
+
+static void mutex_unlock(pthread_mutex_t *mutex)
+{
+ int ret;
+
+ ret = pthread_mutex_unlock(mutex);
+ if (ret) {
+ perror("Error in pthread mutex unlock");
+ exit(-1);
+ }
+}
+
+#ifdef RCU_MEMBARRIER
+static void smp_mb_master(int group)
+{
+ if (likely(has_sys_membarrier))
+ membarrier(MEMBARRIER_EXPEDITED);
+ else
+ cmm_smp_mb();
+}
+#endif
+
+#ifdef RCU_MB
+static void smp_mb_master(int group)