2 * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
4 * SPDX-License-Identifier: GPL-2.0-only
14 #include <common/macros.h>
15 #include <urcu/rculfhash.h>
17 extern unsigned long lttng_ht_seed
;
19 typedef unsigned long (*hash_fct
)(const void *_key
, unsigned long seed
);
20 typedef cds_lfht_match_fct hash_match_fct
;
26 LTTNG_HT_TYPE_TWO_U64
,
31 cds_lfht_match_fct match_fct
;
35 struct lttng_ht_iter
{
36 struct cds_lfht_iter iter
;
39 struct lttng_ht_node_str
{
41 struct cds_lfht_node node
;
45 struct lttng_ht_node_ulong
{
47 struct cds_lfht_node node
;
51 struct lttng_ht_node_u64
{
53 struct cds_lfht_node node
;
57 struct lttng_ht_two_u64
{
62 struct lttng_ht_node_two_u64
{
63 struct lttng_ht_two_u64 key
;
64 struct cds_lfht_node node
;
68 /* Hashtable new and destroy */
70 struct lttng_ht
*lttng_ht_new(unsigned long size
, int type
);
72 void lttng_ht_destroy(struct lttng_ht
*ht
);
74 /* Specialized node init and free functions */
76 void lttng_ht_node_init_str(struct lttng_ht_node_str
*node
, char *key
);
78 void lttng_ht_node_init_ulong(struct lttng_ht_node_ulong
*node
,
81 void lttng_ht_node_init_u64(struct lttng_ht_node_u64
*node
,
84 void lttng_ht_node_init_two_u64(struct lttng_ht_node_two_u64
*node
,
85 uint64_t key1
, uint64_t key2
);
87 void lttng_ht_node_free_str(struct lttng_ht_node_str
*node
);
89 void lttng_ht_node_free_ulong(struct lttng_ht_node_ulong
*node
);
91 void lttng_ht_node_free_u64(struct lttng_ht_node_u64
*node
);
93 void lttng_ht_node_free_two_u64(struct lttng_ht_node_two_u64
*node
);
96 void lttng_ht_lookup(struct lttng_ht
*ht
, const void *key
,
97 struct lttng_ht_iter
*iter
);
99 /* Specialized add unique functions */
101 void lttng_ht_add_unique_str(struct lttng_ht
*ht
,
102 struct lttng_ht_node_str
*node
);
104 void lttng_ht_add_unique_ulong(struct lttng_ht
*ht
,
105 struct lttng_ht_node_ulong
*node
);
107 void lttng_ht_add_unique_u64(struct lttng_ht
*ht
,
108 struct lttng_ht_node_u64
*node
);
110 void lttng_ht_add_unique_two_u64(struct lttng_ht
*ht
,
111 struct lttng_ht_node_two_u64
*node
);
113 struct lttng_ht_node_ulong
*lttng_ht_add_replace_ulong(
114 struct lttng_ht
*ht
, struct lttng_ht_node_ulong
*node
);
116 struct lttng_ht_node_u64
*lttng_ht_add_replace_u64(
117 struct lttng_ht
*ht
, struct lttng_ht_node_u64
*node
);
119 void lttng_ht_add_str(struct lttng_ht
*ht
,
120 struct lttng_ht_node_str
*node
);
122 void lttng_ht_add_ulong(struct lttng_ht
*ht
,
123 struct lttng_ht_node_ulong
*node
);
125 void lttng_ht_add_u64(struct lttng_ht
*ht
,
126 struct lttng_ht_node_u64
*node
);
129 int lttng_ht_del(struct lttng_ht
*ht
, struct lttng_ht_iter
*iter
);
132 void lttng_ht_get_first(struct lttng_ht
*ht
,
133 struct lttng_ht_iter
*iter
);
135 void lttng_ht_get_next(struct lttng_ht
*ht
, struct lttng_ht_iter
*iter
);
138 unsigned long lttng_ht_get_count(struct lttng_ht
*ht
);
141 struct lttng_ht_node_str
*lttng_ht_iter_get_node_str(
142 struct lttng_ht_iter
*iter
);
144 struct lttng_ht_node_ulong
*lttng_ht_iter_get_node_ulong(
145 struct lttng_ht_iter
*iter
);
147 struct lttng_ht_node_u64
*lttng_ht_iter_get_node_u64(
148 struct lttng_ht_iter
*iter
);
150 struct lttng_ht_node_two_u64
*lttng_ht_iter_get_node_two_u64(
151 struct lttng_ht_iter
*iter
);
153 #endif /* _LTT_HT_H */