x86: allocate membarrier system call number
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 18 Sep 2015 21:53:11 +0000 (17:53 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 18 Sep 2015 21:53:11 +0000 (17:53 -0400)
Now that the membarrier system call is allocated on x86 32/64, allocate
its number in our architecture header if the system headers don't
allocate it. This allows using the membarrier system call as soon as
implemented in the kernel, even if the distribution has old kernel
headers.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
13 files changed:
urcu-bp.c
urcu.c
urcu/arch/alpha.h
urcu/arch/arm.h
urcu/arch/gcc.h
urcu/arch/generic.h
urcu/arch/hppa.h
urcu/arch/mips.h
urcu/arch/ppc.h
urcu/arch/s390.h
urcu/arch/sparc64.h
urcu/arch/x86.h
urcu/futex.h

index 6b78af8bd8dfc77545a8a11adcfec997434e57bd..20684cc4d0972a61427f8ecae0e5fd7eb5072189 100644 (file)
--- a/urcu-bp.c
+++ b/urcu-bp.c
@@ -36,6 +36,7 @@
 #include <unistd.h>
 #include <sys/mman.h>
 
+#include "urcu/arch.h"
 #include "urcu/wfcqueue.h"
 #include "urcu/map/urcu-bp.h"
 #include "urcu/static/urcu-bp.h"
@@ -94,16 +95,9 @@ void *mremap_wrapper(void *old_address, size_t old_size,
 static
 int rcu_bp_refcount;
 
-/*
- * RCU_MEMBARRIER is only possibly available on Linux.
- */
-#ifdef __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__)
+/* If the headers do not support membarrier system call, fall back smp_mb. */
+#ifdef __NR_membarrier
+# define membarrier(...)               syscall(__NR_membarrier, __VA_ARGS__)
 #else
 # define membarrier(...)               -ENOSYS
 #endif
diff --git a/urcu.c b/urcu.c
index 1aa00fec9278929996fed4183ebe2acf40d5b61f..a620b762b4796712bd05efb862de8cb6c53c41fd 100644 (file)
--- a/urcu.c
+++ b/urcu.c
@@ -37,6 +37,7 @@
 #include <errno.h>
 #include <poll.h>
 
+#include "urcu/arch.h"
 #include "urcu/wfcqueue.h"
 #include "urcu/map/urcu.h"
 #include "urcu/static/urcu.h"
  */
 #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__)
+/* If the headers do not support membarrier system call, fall back on RCU_MB */
+#ifdef __NR_membarrier
+# define membarrier(...)               syscall(__NR_membarrier, __VA_ARGS__)
 #else
 # define membarrier(...)               -ENOSYS
 #endif
index 9c81f0dfb989646b2551ba866c9d9267582338f0..f4ef3d7d7fed66578011bc4e3700dfca0c0f219c 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <urcu/compiler.h>
 #include <urcu/config.h>
+#include <urcu/syscall-compat.h>
 
 #ifdef __cplusplus
 extern "C" {
index e20695ecf3cf6acb142a1830fe5d527c0f4d0cf6..2d766cd61059684ac30f3cb2989d2a52d07571e1 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <urcu/compiler.h>
 #include <urcu/config.h>
+#include <urcu/syscall-compat.h>
 
 #ifdef __cplusplus
 extern "C" {
index 0c83c238e0e062dfcb386ee310c16bf7b7c9ad36..5638f3667a69b50ceb38d4ecbb19214d21879642 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <urcu/compiler.h>
 #include <urcu/config.h>
+#include <urcu/syscall-compat.h>
 
 #ifdef __cplusplus
 extern "C" {
index 5ec3a114763e458869a62d2518a1cf9dc2ce7050..3f7521ebdd820261b7b2b43b328692a6186319f7 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <urcu/compiler.h>
 #include <urcu/config.h>
+#include <urcu/syscall-compat.h>
 
 #ifdef __cplusplus
 extern "C" {
index b9b9494364a622b98c344419f3f4de01f888a63e..61e8283886db941a9d0f48965ece1f25a0efc3c9 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <urcu/compiler.h>
 #include <urcu/config.h>
+#include <urcu/syscall-compat.h>
 
 #ifdef __cplusplus
 extern "C" {
index 54c3c529d8d1546ab1b56ead2cd06d3d6ccf44c2..4ecdc37c52439799c666810598d475db670ab6a1 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <urcu/compiler.h>
 #include <urcu/config.h>
+#include <urcu/syscall-compat.h>
 
 #ifdef __cplusplus
 extern "C" {
index 1068b288027bda8a5c1f47ce0229e484de827fc6..8a96dd9deb50626efe6a9a8b75e6cbab7c0dc628 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <urcu/compiler.h>
 #include <urcu/config.h>
+#include <urcu/syscall-compat.h>
 
 #ifdef __cplusplus
 extern "C" {
index 5985b2014d78513d1eb010fa33edf93f70df1b36..b1474d8c32f524b1309f2068754c1e0040ff296e 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <urcu/compiler.h>
 #include <urcu/config.h>
+#include <urcu/syscall-compat.h>
 
 #ifdef __cplusplus
 extern "C" {
index 46e26658af3cd2c71f45dde5a9a9b0b1fe415d92..2ccb86fc357c27f9dcda255088bd4336b42f21a5 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <urcu/compiler.h>
 #include <urcu/config.h>
+#include <urcu/syscall-compat.h>
 
 #ifdef __cplusplus
 extern "C" {
index ccc4ce8aab5235a9c6209867d3e99c15f62c1fc0..ecc4b2d39b4133cb026fbe98be6cace2c5c3e223 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <urcu/compiler.h>
 #include <urcu/config.h>
+#include <urcu/syscall-compat.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -86,6 +87,20 @@ static inline cycles_t caa_get_cycles(void)
         return ret;
 }
 
+/*
+ * Define the membarrier system call number if not yet available in the
+ * system headers.
+ */
+#if (CAA_BITS_PER_LONG == 32)
+#ifndef __NR_membarrier
+#define __NR_membarrier                375
+#endif
+#else
+#ifndef __NR_membarrier
+#define __NR_membarrier                324
+#endif
+#endif
+
 #ifdef __cplusplus 
 }
 #endif
index 13d2b1a0a9c73904563e2b9b46d40d19e3316686..4beb54a3d206f2d68e905dd25233f7e6819a529f 100644 (file)
@@ -57,7 +57,7 @@ extern int compat_futex_async(int32_t *uaddr, int op, int32_t val,
 #include <unistd.h>
 #include <errno.h>
 #include <urcu/compiler.h>
-#include <urcu/syscall-compat.h>
+#include <urcu/arch.h>
 
 static inline int futex(int32_t *uaddr, int op, int32_t val,
                const struct timespec *timeout, int32_t *uaddr2, int32_t val3)
This page took 0.031586 seconds and 4 git commands to generate.