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