Commit | Line | Data |
---|---|---|
27b012e2 MD |
1 | #ifndef _URCU_H |
2 | #define _URCU_H | |
3 | ||
b257a10b MD |
4 | /* |
5 | * urcu.h | |
6 | * | |
7 | * Userspace RCU header | |
8 | * | |
9 | * Copyright February 2009 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> | |
10 | * | |
121a5d44 | 11 | * Credits for Paul E. McKenney <paulmck@linux.vnet.ibm.com> |
5e7e64b9 MD |
12 | * for inspiration coming from the Linux kernel RCU and rcu-preempt. |
13 | * | |
121a5d44 | 14 | * LGPL-compatible code should include this header with : |
5e7e64b9 | 15 | * |
121a5d44 MD |
16 | * #define _LGPL_SOURCE |
17 | * #include <urcu.h> | |
18 | * | |
19 | * Distributed under LGPLv2.1 | |
54843abc PM |
20 | * |
21 | * IBM's contributions to this file may be relicensed under LGPLv2 or later. | |
b257a10b MD |
22 | */ |
23 | ||
1430ee0b | 24 | #include <stdlib.h> |
69a757c9 | 25 | #include <pthread.h> |
1430ee0b | 26 | |
121a5d44 | 27 | #ifdef _LGPL_SOURCE |
b0d5e790 | 28 | |
121a5d44 | 29 | #include <urcu-static.h> |
3a86deba MD |
30 | |
31 | /* | |
121a5d44 MD |
32 | * Mappings for static use of the userspace RCU library. |
33 | * Should only be used in LGPL-compatible code. | |
3a86deba | 34 | */ |
3a86deba | 35 | |
121a5d44 MD |
36 | #define rcu_dereference _rcu_dereference |
37 | #define rcu_read_lock _rcu_read_lock | |
38 | #define rcu_read_unlock _rcu_read_unlock | |
41718ff9 | 39 | |
121a5d44 MD |
40 | #define rcu_assign_pointer _rcu_assign_pointer |
41 | #define rcu_xchg_pointer _rcu_xchg_pointer | |
42 | #define rcu_publish_content _rcu_publish_content | |
41718ff9 | 43 | |
121a5d44 | 44 | #else /* !_LGPL_SOURCE */ |
27b012e2 | 45 | |
40e140c9 | 46 | /* |
121a5d44 | 47 | * library wrappers to be used by non-LGPL compatible source code. |
40e140c9 | 48 | */ |
cf380c2f | 49 | |
121a5d44 MD |
50 | extern void rcu_read_lock(void); |
51 | extern void rcu_read_unlock(void); | |
cf380c2f | 52 | |
121a5d44 | 53 | extern void *rcu_dereference(void *p); |
bb488185 | 54 | |
121a5d44 | 55 | extern void *rcu_assign_pointer_sym(void **p, void *v); |
cf380c2f | 56 | |
121a5d44 MD |
57 | #define rcu_assign_pointer(p, v) \ |
58 | rcu_assign_pointer_sym((void **)(p), (v)) | |
cf380c2f | 59 | |
121a5d44 MD |
60 | extern void *rcu_xchg_pointer_sym(void **p, void *v); |
61 | #define rcu_xchg_pointer(p, v) \ | |
62 | rcu_xchg_pointer_sym((void **)(p), (v)) | |
9d335088 | 63 | |
121a5d44 MD |
64 | extern void *rcu_publish_content_sym(void **p, void *v); |
65 | #define rcu_publish_content(p, v) \ | |
66 | rcu_publish_content_sym((void **)(p), (v)) | |
cf380c2f | 67 | |
121a5d44 | 68 | #endif /* !_LGPL_SOURCE */ |
f4a486ac | 69 | |
e462817e | 70 | extern void synchronize_rcu(void); |
27b012e2 MD |
71 | |
72 | /* | |
73 | * Reader thread registration. | |
74 | */ | |
121a5d44 MD |
75 | extern void rcu_register_thread(void); |
76 | extern void rcu_unregister_thread(void); | |
27b012e2 MD |
77 | |
78 | #endif /* _URCU_H */ |