From: Mathieu Desnoyers Date: Fri, 18 Sep 2015 21:53:11 +0000 (-0400) Subject: x86: allocate membarrier system call number X-Git-Tag: v0.9.0~33 X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=commitdiff_plain;h=999991c6e4600c410181baea65bda9f406464872;hp=f541831e757bc5e0143550f5d686bed0de7d41b7 x86: allocate membarrier system call number 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 --- diff --git a/urcu-bp.c b/urcu-bp.c index 6b78af8..20684cc 100644 --- a/urcu-bp.c +++ b/urcu-bp.c @@ -36,6 +36,7 @@ #include #include +#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 -#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 1aa00fe..a620b76 100644 --- a/urcu.c +++ b/urcu.c @@ -37,6 +37,7 @@ #include #include +#include "urcu/arch.h" #include "urcu/wfcqueue.h" #include "urcu/map/urcu.h" #include "urcu/static/urcu.h" @@ -63,16 +64,9 @@ */ #define RCU_QS_ACTIVE_ATTEMPTS 100 -/* - * RCU_MEMBARRIER is only possibly available on Linux. - */ -#if defined(RCU_MEMBARRIER) && defined(__linux__) -#include -#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 diff --git a/urcu/arch/alpha.h b/urcu/arch/alpha.h index 9c81f0d..f4ef3d7 100644 --- a/urcu/arch/alpha.h +++ b/urcu/arch/alpha.h @@ -23,6 +23,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/urcu/arch/arm.h b/urcu/arch/arm.h index e20695e..2d766cd 100644 --- a/urcu/arch/arm.h +++ b/urcu/arch/arm.h @@ -24,6 +24,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/urcu/arch/gcc.h b/urcu/arch/gcc.h index 0c83c23..5638f36 100644 --- a/urcu/arch/gcc.h +++ b/urcu/arch/gcc.h @@ -24,6 +24,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/urcu/arch/generic.h b/urcu/arch/generic.h index 5ec3a11..3f7521e 100644 --- a/urcu/arch/generic.h +++ b/urcu/arch/generic.h @@ -23,6 +23,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/urcu/arch/hppa.h b/urcu/arch/hppa.h index b9b9494..61e8283 100644 --- a/urcu/arch/hppa.h +++ b/urcu/arch/hppa.h @@ -3,6 +3,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/urcu/arch/mips.h b/urcu/arch/mips.h index 54c3c52..4ecdc37 100644 --- a/urcu/arch/mips.h +++ b/urcu/arch/mips.h @@ -24,6 +24,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/urcu/arch/ppc.h b/urcu/arch/ppc.h index 1068b28..8a96dd9 100644 --- a/urcu/arch/ppc.h +++ b/urcu/arch/ppc.h @@ -24,6 +24,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/urcu/arch/s390.h b/urcu/arch/s390.h index 5985b20..b1474d8 100644 --- a/urcu/arch/s390.h +++ b/urcu/arch/s390.h @@ -30,6 +30,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/urcu/arch/sparc64.h b/urcu/arch/sparc64.h index 46e2665..2ccb86f 100644 --- a/urcu/arch/sparc64.h +++ b/urcu/arch/sparc64.h @@ -24,6 +24,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/urcu/arch/x86.h b/urcu/arch/x86.h index ccc4ce8..ecc4b2d 100644 --- a/urcu/arch/x86.h +++ b/urcu/arch/x86.h @@ -24,6 +24,7 @@ #include #include +#include #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 diff --git a/urcu/futex.h b/urcu/futex.h index 13d2b1a..4beb54a 100644 --- a/urcu/futex.h +++ b/urcu/futex.h @@ -57,7 +57,7 @@ extern int compat_futex_async(int32_t *uaddr, int op, int32_t val, #include #include #include -#include +#include static inline int futex(int32_t *uaddr, int op, int32_t val, const struct timespec *timeout, int32_t *uaddr2, int32_t val3)