projects
/
urcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
don't __USE_GNU in urcu.h
[urcu.git]
/
urcu.h
diff --git
a/urcu.h
b/urcu.h
index fb8cedf3e15beab5ba5355b153d0bb999fa1c7fc..2e8c0424abb0d413b6a64035ba05acced231d253 100644
(file)
--- a/
urcu.h
+++ b/
urcu.h
@@
-18,10
+18,14
@@
*/
#include <stdlib.h>
*/
#include <stdlib.h>
+#include <pthread.h>
/* The "volatile" is due to gcc bugs */
#define barrier() __asm__ __volatile__("": : :"memory")
/* The "volatile" is due to gcc bugs */
#define barrier() __asm__ __volatile__("": : :"memory")
+#define likely(x) __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+
/* x86 32/64 specific */
#define mb() asm volatile("mfence":::"memory")
#define rmb() asm volatile("lfence":::"memory")
/* x86 32/64 specific */
#define mb() asm volatile("mfence":::"memory")
#define rmb() asm volatile("lfence":::"memory")
@@
-63,7
+67,13
@@
static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
: "memory");
break;
case 4:
: "memory");
break;
case 4:
- asm volatile("xchgl %0,%1"
+ asm volatile("xchgl %k0,%1"
+ : "=r" (x)
+ : "m" (*__xg(ptr)), "0" (x)
+ : "memory");
+ break;
+ case 8:
+ asm volatile("xchgq %0,%1"
: "=r" (x)
: "m" (*__xg(ptr)), "0" (x)
: "memory");
: "=r" (x)
: "m" (*__xg(ptr)), "0" (x)
: "memory");
@@
-109,6
+119,8
@@
static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
#ifdef DEBUG_YIELD
#include <sched.h>
#ifdef DEBUG_YIELD
#include <sched.h>
+#include <time.h>
+#include <pthread.h>
#define YIELD_READ (1 << 0)
#define YIELD_WRITE (1 << 1)
#define YIELD_READ (1 << 0)
#define YIELD_WRITE (1 << 1)
@@
-157,7
+169,11
@@
static inline void debug_yield_init(void)
#define RCU_GP_CTR_BIT (1U << 8)
#define RCU_GP_CTR_NEST_MASK (RCU_GP_CTR_BIT - 1)
#define RCU_GP_CTR_BIT (1U << 8)
#define RCU_GP_CTR_NEST_MASK (RCU_GP_CTR_BIT - 1)
-/* Global quiescent period counter with low-order bits unused. */
+/*
+ * Global quiescent period counter with low-order bits unused.
+ * Using a int rather than a char to eliminate false register dependencies
+ * causing stalls on some architectures.
+ */
extern int urcu_gp_ctr;
extern int __thread urcu_active_readers;
extern int urcu_gp_ctr;
extern int __thread urcu_active_readers;
@@
-182,7
+198,7
@@
static inline void rcu_read_lock(void)
debug_yield_read();
tmp = urcu_active_readers;
debug_yield_read();
debug_yield_read();
tmp = urcu_active_readers;
debug_yield_read();
- if (
!(tmp & RCU_GP_CTR_NEST_MASK
))
+ if (
likely(!(tmp & RCU_GP_CTR_NEST_MASK)
))
urcu_active_readers = urcu_gp_ctr + RCU_GP_COUNT;
else
urcu_active_readers = tmp + RCU_GP_COUNT;
urcu_active_readers = urcu_gp_ctr + RCU_GP_COUNT;
else
urcu_active_readers = tmp + RCU_GP_COUNT;
This page took
0.024962 seconds
and
4
git commands to generate.