Futex: turn "int" into "int32_t" for portability
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 11 Jun 2011 00:16:28 +0000 (20:16 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 11 Jun 2011 00:16:28 +0000 (20:16 -0400)
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 <dvhart@linux.intel.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
compat_futex.c
urcu-call-rcu-impl.h
urcu-defer-impl.h
urcu-qsbr.c
urcu.c
urcu/futex.h
urcu/static/urcu-qsbr.h
urcu/static/urcu.h

index 28089cc838e0bccf2cb00768f67dbab967c4c653..3f1d1ef3410a91d4ae432080debcba4c6a17e387 100644 (file)
@@ -26,6 +26,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <poll.h>
+#include <stdint.h>
 
 #include <urcu/arch.h>
 #include <urcu/futex.h>
@@ -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;
 
index 4d01c1b6b5a21533f08a8e049318799cb0cdbb38..8a89295fa44bcc6dc18b84e671ec42705128ff06 100644 (file)
@@ -26,6 +26,7 @@
 #include <signal.h>
 #include <assert.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <string.h>
 #include <errno.h>
 #include <poll.h>
@@ -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;
index f8dfa4c87f5155ac0bc73f9ac22a105cb7c7f1fc..d9c1c3a37cbe4fadce55ac08ad9edf562d8323e6 100644 (file)
@@ -40,6 +40,7 @@
 #include <sys/time.h>
 #include <syscall.h>
 #include <unistd.h>
+#include <stdint.h>
 
 #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
index 5eda71dbf3c1ee454f9b29e19c752ff946f7c9b3..87cf41d7ee70f274dc6676af06e3c122dd986222 100644 (file)
@@ -29,6 +29,7 @@
 #include <signal.h>
 #include <assert.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <string.h>
 #include <errno.h>
 #include <poll.h>
@@ -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 ccaf3e95a2d5ad6f7428625b399429cd843344b6..2339bc63c872c6a4826d7a52e8d064d85130c0df 100644 (file)
--- a/urcu.c
+++ b/urcu.c
@@ -30,6 +30,7 @@
 #include <signal.h>
 #include <assert.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <string.h>
 #include <errno.h>
 #include <poll.h>
@@ -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.
index 69f8961dafca35ad3d67f514600c4f9600074b07..98acc12855515e7ca0c5bf9ca42fd3fb988e0f30 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <urcu/config.h>
+#include <stdint.h>
 
 #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
index d544bb2257468d5d59b0570cb9a9dddf29eb813f..a9f4d8b264835afab0442a7f304bc91e11f077b4 100644 (file)
@@ -35,6 +35,7 @@
 #include <limits.h>
 #include <syscall.h>
 #include <unistd.h>
+#include <stdint.h>
 
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
@@ -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.
index 3161a40088836c92a65edbdc8445385913afe0bb..777fa4c593b17ee2625c23c143e6ee668e8f9e40 100644 (file)
@@ -33,6 +33,7 @@
 #include <pthread.h>
 #include <syscall.h>
 #include <unistd.h>
+#include <stdint.h>
 
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
@@ -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.
This page took 0.030254 seconds and 4 git commands to generate.