Commit | Line | Data |
---|---|---|
d553beef MD |
1 | #ifndef _URCU_RCUJA_H |
2 | #define _URCU_RCUJA_H | |
3 | ||
4 | /* | |
5 | * urcu/rcuja.h | |
6 | * | |
7 | * Userspace RCU library - RCU Judy Array | |
8 | * | |
9 | * Copyright 2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
10 | * | |
11 | * This library is free software; you can redistribute it and/or | |
12 | * modify it under the terms of the GNU Lesser General Public | |
13 | * License as published by the Free Software Foundation; either | |
14 | * version 2.1 of the License, or (at your option) any later version. | |
15 | * | |
16 | * This library is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 | * Lesser General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU Lesser General Public | |
22 | * License along with this library; if not, write to the Free Software | |
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
24 | * | |
25 | * Include this file _after_ including your URCU flavor. | |
26 | */ | |
27 | ||
28 | #include <stdint.h> | |
29 | #include <urcu/compiler.h> | |
30 | #include <urcu-call-rcu.h> | |
31 | #include <urcu-flavor.h> | |
32 | #include <stdint.h> | |
33 | #include <urcu/rcuhlist.h> | |
34 | ||
35 | #ifdef __cplusplus | |
36 | extern "C" { | |
37 | #endif | |
38 | ||
39 | struct cds_ja_node { | |
40 | /* Linked list of nodes with same key */ | |
41 | struct cds_hlist_node list; | |
42 | /* delayed reclaim */ | |
43 | struct rcu_head head; | |
44 | }; | |
45 | ||
46 | struct cds_ja; | |
47 | ||
48 | /* | |
49 | * cds_ja_node_init - initialize a judy array node | |
50 | * @node: the node to initialize. | |
51 | * | |
52 | * This function is kept to be eventually used for debugging purposes | |
53 | * (detection of memory corruption). | |
54 | */ | |
55 | static inline | |
56 | void cds_ja_node_init(struct cds_ja_node *node) | |
57 | { | |
58 | } | |
59 | ||
60 | struct cds_hlist_head cds_ja_lookup(struct cds_ja *ja, uint64_t key); | |
61 | ||
62 | int cds_ja_add(struct cds_ja *ja, uint64_t key, | |
63 | struct cds_ja_node *new_node); | |
64 | ||
75d573aa MD |
65 | struct cds_ja_node *cds_ja_add_unique(struct cds_ja *ja, uint64_t key, |
66 | struct cds_ja_node *new_node); | |
67 | ||
d553beef MD |
68 | int cds_ja_del(struct cds_ja *ja, uint64_t key, |
69 | struct cds_ja_node *node); | |
70 | ||
71 | struct cds_ja *_cds_ja_new(unsigned int key_bits, | |
72 | const struct rcu_flavor_struct *flavor); | |
73 | ||
74 | static inline | |
75 | struct cds_ja *cds_ja_new(unsigned int key_bits) | |
76 | { | |
77 | return _cds_ja_new(key_bits, &rcu_flavor); | |
78 | } | |
79 | ||
80 | int cds_ja_destroy(struct cds_ja *ja, | |
81 | void (*free_node_cb)(struct rcu_head *head)); | |
82 | ||
83 | #ifdef __cplusplus | |
84 | } | |
85 | #endif | |
86 | ||
87 | #endif /* _URCU_RCUJA_H */ |