]> git.sesse.net Git - bcachefs-tools-debian/blob - include/linux/rcupdate.h
Update bcachefs sources to 70fa0c1ff4 fixup! bcachefs: Btree key cache improvements
[bcachefs-tools-debian] / include / linux / rcupdate.h
1 #ifndef __TOOLS_LINUX_RCUPDATE_H
2 #define __TOOLS_LINUX_RCUPDATE_H
3
4 #include <urcu.h>
5 #include <linux/compiler.h>
6
7 #define ULONG_CMP_GE(a, b)      (ULONG_MAX / 2 >= (a) - (b))
8
9 #define rcu_dereference_check(p, c)     rcu_dereference(p)
10 #define rcu_dereference_raw(p)          rcu_dereference(p)
11 #define rcu_dereference_protected(p, c) rcu_dereference(p)
12 #define rcu_access_pointer(p)           READ_ONCE(p)
13
14 #define kfree_rcu(ptr, rcu_head)        kfree(ptr) /* XXX */
15
16 #define RCU_INIT_POINTER(p, v)          WRITE_ONCE(p, v)
17
18 /* Has the specified rcu_head structure been handed to call_rcu()? */
19
20 /**
21  * rcu_head_init - Initialize rcu_head for rcu_head_after_call_rcu()
22  * @rhp: The rcu_head structure to initialize.
23  *
24  * If you intend to invoke rcu_head_after_call_rcu() to test whether a
25  * given rcu_head structure has already been passed to call_rcu(), then
26  * you must also invoke this rcu_head_init() function on it just after
27  * allocating that structure.  Calls to this function must not race with
28  * calls to call_rcu(), rcu_head_after_call_rcu(), or callback invocation.
29  */
30 static inline void rcu_head_init(struct rcu_head *rhp)
31 {
32         rhp->func = (void *)~0L;
33 }
34
35 static inline bool
36 rcu_head_after_call_rcu(struct rcu_head *rhp,
37                         void (*f)(struct rcu_head *head))
38 {
39         void (*func)(struct rcu_head *head) = READ_ONCE(rhp->func);
40
41         if (func == f)
42                 return true;
43         return false;
44 }
45
46 #endif /* __TOOLS_LINUX_RCUPDATE_H */