4 /* The "volatile" is due to gcc bugs */
5 #define barrier() __asm__ __volatile__("": : :"memory")
7 /* x86 32/64 specific */
8 #define mb() asm volatile("mfence":::"memory")
9 #define rmb() asm volatile("lfence":::"memory")
10 #define wmb() asm volatile("sfence" ::: "memory")
15 static inline void atomic_inc(int *v
)
17 asm volatile("lock; incl %0"
21 /* Nop everywhere except on alpha. */
22 #define smp_read_barrier_depends()
25 * Prevent the compiler from merging or refetching accesses. The compiler
26 * is also forbidden from reordering successive instances of ACCESS_ONCE(),
27 * but only when the compiler is aware of some particular ordering. One way
28 * to make the compiler aware of ordering is to put the two invocations of
29 * ACCESS_ONCE() in different C statements.
31 * This macro does absolutely -nothing- to prevent the CPU from reordering,
32 * merging, or refetching absolutely anything at any time. Its main intended
33 * use is to mediate communication between process-level code and irq/NMI
34 * handlers, all running on the same CPU.
36 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
39 * rcu_dereference - fetch an RCU-protected pointer in an
40 * RCU read-side critical section. This pointer may later
41 * be safely dereferenced.
43 * Inserts memory barriers on architectures that require them
44 * (currently only the Alpha), and, more importantly, documents
45 * exactly which pointers are protected by RCU.
48 #define rcu_dereference(p) ({ \
49 typeof(p) _________p1 = ACCESS_ONCE(p); \
50 smp_read_barrier_depends(); \
54 #define SIGURCU SIGUSR1
56 /* Global quiescent period parity */
57 extern int urcu_qparity
;
59 extern int __thread urcu_active_readers
[2];
61 static inline int get_urcu_qparity(void)
67 * returns urcu_parity.
69 static inline int rcu_read_lock(void)
71 int urcu_parity
= get_urcu_qparity();
72 urcu_active_readers
[urcu_parity
]++;
74 * Increment active readers count before accessing the pointer.
75 * See force_mb_all_threads().
81 static inline void rcu_read_unlock(int urcu_parity
)
85 * Finish using rcu before decrementing the pointer.
86 * See force_mb_all_threads().
88 urcu_active_readers
[urcu_parity
]--;
91 extern void rcu_write_lock(void);
92 extern void rcu_write_unlock(void);
94 extern void *urcu_publish_content(void **ptr
, void *new);
97 * Reader thread registration.
99 extern void urcu_register_thread(void);
100 extern void urcu_register_thread(void);