projects
/
urcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
compiler.h: use stddef.h for offsetof
[urcu.git]
/
urcu-static.h
diff --git
a/urcu-static.h
b/urcu-static.h
index 3caa0f93d55058528a07c5fb20ba3a0e80191e79..f2a463c47ab9dd03eff61c84d90c6c0d5edf6f3b 100644
(file)
--- a/
urcu-static.h
+++ b/
urcu-static.h
@@
-34,8
+34,9
@@
#include <syscall.h>
#include <unistd.h>
#include <syscall.h>
#include <unistd.h>
-#include <compiler.h>
-#include <arch.h>
+#include <urcu/compiler.h>
+#include <urcu/arch.h>
+#include <urcu/list.h>
/*
* Identify a shared load. A smp_rmc() or smp_mc() should come before the load.
/*
* Identify a shared load. A smp_rmc() or smp_mc() should come before the load.
@@
-218,7
+219,14
@@
static inline void reader_barrier()
*/
extern long urcu_gp_ctr;
*/
extern long urcu_gp_ctr;
-extern long __thread urcu_active_readers;
+struct urcu_reader {
+ long ctr;
+ struct list_head head;
+ pthread_t tid;
+ char need_mb;
+};
+
+extern struct urcu_reader __thread urcu_reader;
extern int gp_futex;
extern int gp_futex;
@@
-227,8
+235,8
@@
extern int gp_futex;
*/
static inline void wake_up_gp(void)
{
*/
static inline void wake_up_gp(void)
{
- if (unlikely(atomic_read(&gp_futex) == -1)) {
- atomic_set(&gp_futex, 0);
+ if (unlikely(
u
atomic_read(&gp_futex) == -1)) {
+
u
atomic_set(&gp_futex, 0);
futex(&gp_futex, FUTEX_WAKE, 1,
NULL, NULL, 0);
}
futex(&gp_futex, FUTEX_WAKE, 1,
NULL, NULL, 0);
}
@@
-253,17
+261,17
@@
static inline void _rcu_read_lock(void)
{
long tmp;
{
long tmp;
- tmp = urcu_
active_readers
;
+ tmp = urcu_
reader.ctr
;
/* urcu_gp_ctr = RCU_GP_COUNT | (~RCU_GP_CTR_BIT or RCU_GP_CTR_BIT) */
if (likely(!(tmp & RCU_GP_CTR_NEST_MASK))) {
/* urcu_gp_ctr = RCU_GP_COUNT | (~RCU_GP_CTR_BIT or RCU_GP_CTR_BIT) */
if (likely(!(tmp & RCU_GP_CTR_NEST_MASK))) {
- _STORE_SHARED(urcu_
active_readers
, _LOAD_SHARED(urcu_gp_ctr));
+ _STORE_SHARED(urcu_
reader.ctr
, _LOAD_SHARED(urcu_gp_ctr));
/*
* Set active readers count for outermost nesting level before
* accessing the pointer. See force_mb_all_threads().
*/
reader_barrier();
} else {
/*
* Set active readers count for outermost nesting level before
* accessing the pointer. See force_mb_all_threads().
*/
reader_barrier();
} else {
- _STORE_SHARED(urcu_
active_readers
, tmp + RCU_GP_COUNT);
+ _STORE_SHARED(urcu_
reader.ctr
, tmp + RCU_GP_COUNT);
}
}
}
}
@@
-271,21
+279,19
@@
static inline void _rcu_read_unlock(void)
{
long tmp;
{
long tmp;
- tmp = urcu_
active_readers
;
+ tmp = urcu_
reader.ctr
;
/*
* Finish using rcu before decrementing the pointer.
* See force_mb_all_threads().
*/
if (likely((tmp & RCU_GP_CTR_NEST_MASK) == RCU_GP_COUNT)) {
reader_barrier();
/*
* Finish using rcu before decrementing the pointer.
* See force_mb_all_threads().
*/
if (likely((tmp & RCU_GP_CTR_NEST_MASK) == RCU_GP_COUNT)) {
reader_barrier();
- _STORE_SHARED(urcu_active_readers,
- urcu_active_readers - RCU_GP_COUNT);
- /* write urcu_active_readers before read futex */
+ _STORE_SHARED(urcu_reader.ctr, urcu_reader.ctr - RCU_GP_COUNT);
+ /* write urcu_reader.ctr before read futex */
reader_barrier();
wake_up_gp();
} else {
reader_barrier();
wake_up_gp();
} else {
- _STORE_SHARED(urcu_active_readers,
- urcu_active_readers - RCU_GP_COUNT);
+ _STORE_SHARED(urcu_reader.ctr, urcu_reader.ctr - RCU_GP_COUNT);
}
}
}
}
@@
-323,7
+329,7
@@
static inline void _rcu_read_unlock(void)
if (!__builtin_constant_p(_new) || \
((_new) != NULL)) \
wmb(); \
if (!__builtin_constant_p(_new) || \
((_new) != NULL)) \
wmb(); \
-
cmpxchg(p, old, _new);
\
+
uatomic_cmpxchg(p, old, _new);
\
})
/**
})
/**
@@
-337,7
+343,7
@@
static inline void _rcu_read_unlock(void)
if (!__builtin_constant_p(v) || \
((v) != NULL)) \
wmb(); \
if (!__builtin_constant_p(v) || \
((v) != NULL)) \
wmb(); \
-
xchg(p, v);
\
+
uatomic_xchg(p, v);
\
})
/*
})
/*
This page took
0.023763 seconds
and
4
git commands to generate.