From: Mathieu Desnoyers Date: Sat, 11 Jun 2011 00:16:28 +0000 (-0400) Subject: Futex: turn "int" into "int32_t" for portability X-Git-Tag: v0.6.0~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6d841bc23fc94345fe76651d73c1a3f821a85aa7;p=userspace-rcu.git Futex: turn "int" into "int32_t" for portability Even though int is 32-bit on all architectures supported by liburcu so far, make it future-proof by uint a int32_t, which enforces the same type width used by the system call in the kernel. Using int32_t and not uint32_t to make comparison with 0 more straightforward. Reported-by: Darren Hart Signed-off-by: Mathieu Desnoyers --- diff --git a/compat_futex.c b/compat_futex.c index 28089cc..3f1d1ef 100644 --- a/compat_futex.c +++ b/compat_futex.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -39,8 +40,8 @@ static pthread_cond_t compat_futex_cond = PTHREAD_COND_INITIALIZER; * Waiter will relinquish the CPU until woken up. */ -int compat_futex_noasync(int *uaddr, int op, int val, - const struct timespec *timeout, int *uaddr2, int val3) +int compat_futex_noasync(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) { int ret, i, gret = 0; @@ -84,8 +85,8 @@ end: * Waiter will busy-loop trying to read the condition. */ -int compat_futex_async(int *uaddr, int op, int val, - const struct timespec *timeout, int *uaddr2, int val3) +int compat_futex_async(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) { int ret, i; diff --git a/urcu-call-rcu-impl.h b/urcu-call-rcu-impl.h index 4d01c1b..8a89295 100644 --- a/urcu-call-rcu-impl.h +++ b/urcu-call-rcu-impl.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -46,7 +47,7 @@ struct call_rcu_data { struct cds_wfq_queue cbs; unsigned long flags; - int futex; + int32_t futex; unsigned long qlen; /* maintained for debugging. */ pthread_t tid; int cpu_affinity; diff --git a/urcu-defer-impl.h b/urcu-defer-impl.h index f8dfa4c..d9c1c3a 100644 --- a/urcu-defer-impl.h +++ b/urcu-defer-impl.h @@ -40,6 +40,7 @@ #include #include #include +#include #include "urcu/futex.h" @@ -121,7 +122,7 @@ extern void synchronize_rcu(void); static pthread_mutex_t rcu_defer_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t defer_thread_mutex = PTHREAD_MUTEX_INITIALIZER; -static int defer_thread_futex; +static int32_t defer_thread_futex; /* * Written to only by each individual deferer. Read by both the deferer and diff --git a/urcu-qsbr.c b/urcu-qsbr.c index 5eda71d..87cf41d 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,7 @@ void __attribute__((destructor)) rcu_exit(void); static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; -int gp_futex; +int32_t gp_futex; /* * Global grace period counter. diff --git a/urcu.c b/urcu.c index ccaf3e9..2339bc6 100644 --- a/urcu.c +++ b/urcu.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,7 @@ void __attribute__((destructor)) rcu_exit(void); static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; -int gp_futex; +int32_t gp_futex; /* * Global grace period counter. diff --git a/urcu/futex.h b/urcu/futex.h index 69f8961..98acc12 100644 --- a/urcu/futex.h +++ b/urcu/futex.h @@ -22,6 +22,7 @@ */ #include +#include #ifdef __cplusplus extern "C" { @@ -49,12 +50,12 @@ extern "C" { #define futex_async(uaddr, op, val, timeout, uaddr2, val3) \ futex(uaddr, op, val, timeout, uaddr2, val3) #else -extern int compat_futex_noasync(int *uaddr, int op, int val, - const struct timespec *timeout, int *uaddr2, int val3); +extern int compat_futex_noasync(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3); #define futex_noasync(uaddr, op, val, timeout, uaddr2, val3) \ compat_futex_noasync(uaddr, op, val, timeout, uaddr2, val3) -extern int compat_futex_async(int *uaddr, int op, int val, - const struct timespec *timeout, int *uaddr2, int val3); +extern int compat_futex_async(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3); #define futex_async(uaddr, op, val, timeout, uaddr2, val3) \ compat_futex_async(uaddr, op, val, timeout, uaddr2, val3) #endif diff --git a/urcu/static/urcu-qsbr.h b/urcu/static/urcu-qsbr.h index d544bb2..a9f4d8b 100644 --- a/urcu/static/urcu-qsbr.h +++ b/urcu/static/urcu-qsbr.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -141,7 +142,7 @@ struct rcu_reader { extern struct rcu_reader __thread rcu_reader; -extern int gp_futex; +extern int32_t gp_futex; /* * Wake-up waiting synchronize_rcu(). Called from many concurrent threads. diff --git a/urcu/static/urcu.h b/urcu/static/urcu.h index 3161a40..777fa4c 100644 --- a/urcu/static/urcu.h +++ b/urcu/static/urcu.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -228,7 +229,7 @@ struct rcu_reader { extern struct rcu_reader __thread rcu_reader; -extern int gp_futex; +extern int32_t gp_futex; /* * Wake-up waiting synchronize_rcu(). Called from many concurrent threads.