Android: add a compat layer for 'syscall.h'
[urcu.git] / urcu.c
diff --git a/urcu.c b/urcu.c
index da6839f0c25b88b4262e9a615bd197220789c185..69ebcaa9cb0fbfa07a264ab94fa5261513c72424 100644 (file)
--- a/urcu.c
+++ b/urcu.c
  */
 #define RCU_QS_ACTIVE_ATTEMPTS 100
 
+/*
+ * RCU_MEMBARRIER is only possibly available on Linux.
+ */
+#if defined(RCU_MEMBARRIER) && defined(__linux__)
+#include <urcu/syscall-compat.h>
+#endif
+
+/* If the headers do not support SYS_membarrier, fall back on RCU_MB */
+#ifdef SYS_membarrier
+# define membarrier(...)               syscall(SYS_membarrier, __VA_ARGS__)
+#else
+# define membarrier(...)               -ENOSYS
+#endif
+
+#define MEMBARRIER_EXPEDITED           (1 << 0)
+#define MEMBARRIER_DELAYED             (1 << 1)
+#define MEMBARRIER_QUERY               (1 << 16)
+
 #ifdef RCU_MEMBARRIER
 static int init_done;
 int rcu_has_sys_membarrier;
@@ -83,7 +101,7 @@ void __attribute__((destructor)) rcu_exit(void);
 #endif
 
 static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER;
-struct urcu_gp rcu_gp = { .ctr = RCU_GP_COUNT };
+struct rcu_gp rcu_gp = { .ctr = RCU_GP_COUNT };
 
 /*
  * Written to only by each individual reader. Read by both the reader and the
@@ -139,7 +157,7 @@ static void mutex_unlock(pthread_mutex_t *mutex)
 static void smp_mb_master(int group)
 {
        if (caa_likely(rcu_has_sys_membarrier))
-               membarrier(MEMBARRIER_EXPEDITED);
+               (void) membarrier(MEMBARRIER_EXPEDITED);
        else
                cmm_smp_mb();
 }
@@ -495,14 +513,14 @@ void rcu_init(void)
 
 void rcu_exit(void)
 {
-       struct sigaction act;
-       int ret;
-
-       ret = sigaction(SIGRCU, NULL, &act);
-       if (ret)
-               urcu_die(errno);
-       assert(act.sa_sigaction == sigrcu_handler);
-       assert(cds_list_empty(&registry));
+       /*
+        * Don't unregister the SIGRCU signal handler anymore, because
+        * call_rcu threads could still be using it shortly before the
+        * application exits.
+        * Assertion disabled because call_rcu threads are now rcu
+        * readers, and left running at exit.
+        * assert(cds_list_empty(&registry));
+        */
 }
 
 #endif /* #ifdef RCU_SIGNAL */
This page took 0.0228 seconds and 4 git commands to generate.