]> git.sesse.net Git - bcachefs-tools-debian/blob - include/linux/rcupdate.h
rust: bump rpassword to v7.x
[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 #define kfree_rcu_mightsleep(ptr)       kfree(ptr) /* XXX */
16 #define kvfree_rcu_mightsleep(ptr)      kfree(ptr) /* XXX */
17
18 #define RCU_INIT_POINTER(p, v)          WRITE_ONCE(p, v)
19
20 /* Has the specified rcu_head structure been handed to call_rcu()? */
21
22 /**
23  * rcu_head_init - Initialize rcu_head for rcu_head_after_call_rcu()
24  * @rhp: The rcu_head structure to initialize.
25  *
26  * If you intend to invoke rcu_head_after_call_rcu() to test whether a
27  * given rcu_head structure has already been passed to call_rcu(), then
28  * you must also invoke this rcu_head_init() function on it just after
29  * allocating that structure.  Calls to this function must not race with
30  * calls to call_rcu(), rcu_head_after_call_rcu(), or callback invocation.
31  */
32 static inline void rcu_head_init(struct rcu_head *rhp)
33 {
34         rhp->func = (void *)~0L;
35 }
36
37 static inline bool
38 rcu_head_after_call_rcu(struct rcu_head *rhp,
39                         void (*f)(struct rcu_head *head))
40 {
41         void (*func)(struct rcu_head *head) = READ_ONCE(rhp->func);
42
43         if (func == f)
44                 return true;
45         return false;
46 }
47
48 #endif /* __TOOLS_LINUX_RCUPDATE_H */