2 * Copyright (C) 2011 EfficiOS Inc.
4 * SPDX-License-Identifier: GPL-2.0-only
14 #include <common/macros.h>
15 #include <lttng/lttng-export.h>
16 #include <urcu/rculfhash.h>
18 LTTNG_EXPORT
extern unsigned long lttng_ht_seed
;
20 typedef unsigned long (*hash_fct_type
)(const void *_key
, unsigned long seed
);
21 typedef cds_lfht_match_fct hash_match_fct
;
27 LTTNG_HT_TYPE_TWO_U64
,
32 cds_lfht_match_fct match_fct
;
33 hash_fct_type hash_fct
;
36 struct lttng_ht_iter
{
37 struct cds_lfht_iter iter
;
40 struct lttng_ht_node_str
{
42 struct cds_lfht_node node
;
46 struct lttng_ht_node_ulong
{
48 struct cds_lfht_node node
;
52 struct lttng_ht_node_u64
{
54 struct cds_lfht_node node
;
58 struct lttng_ht_two_u64
{
63 struct lttng_ht_node_two_u64
{
64 struct lttng_ht_two_u64 key
;
65 struct cds_lfht_node node
;
69 /* Hashtable new and destroy */
70 struct lttng_ht
*lttng_ht_new(unsigned long size
, enum lttng_ht_type type
);
71 void lttng_ht_destroy(struct lttng_ht
*ht
);
73 /* Specialized node init and free functions */
74 void lttng_ht_node_init_str(struct lttng_ht_node_str
*node
, char *key
);
75 void lttng_ht_node_init_ulong(struct lttng_ht_node_ulong
*node
,
77 void lttng_ht_node_init_u64(struct lttng_ht_node_u64
*node
,
79 void lttng_ht_node_init_two_u64(struct lttng_ht_node_two_u64
*node
,
80 uint64_t key1
, uint64_t key2
);
81 void lttng_ht_node_free_str(struct lttng_ht_node_str
*node
);
82 void lttng_ht_node_free_ulong(struct lttng_ht_node_ulong
*node
);
83 void lttng_ht_node_free_u64(struct lttng_ht_node_u64
*node
);
84 void lttng_ht_node_free_two_u64(struct lttng_ht_node_two_u64
*node
);
86 void lttng_ht_lookup(struct lttng_ht
*ht
, const void *key
,
87 struct lttng_ht_iter
*iter
);
89 /* Specialized add unique functions */
90 void lttng_ht_add_unique_str(struct lttng_ht
*ht
,
91 struct lttng_ht_node_str
*node
);
92 void lttng_ht_add_unique_ulong(struct lttng_ht
*ht
,
93 struct lttng_ht_node_ulong
*node
);
94 void lttng_ht_add_unique_u64(struct lttng_ht
*ht
,
95 struct lttng_ht_node_u64
*node
);
96 void lttng_ht_add_unique_two_u64(struct lttng_ht
*ht
,
97 struct lttng_ht_node_two_u64
*node
);
98 struct lttng_ht_node_ulong
*lttng_ht_add_replace_ulong(
99 struct lttng_ht
*ht
, struct lttng_ht_node_ulong
*node
);
100 struct lttng_ht_node_u64
*lttng_ht_add_replace_u64(
101 struct lttng_ht
*ht
, struct lttng_ht_node_u64
*node
);
102 void lttng_ht_add_str(struct lttng_ht
*ht
,
103 struct lttng_ht_node_str
*node
);
104 void lttng_ht_add_ulong(struct lttng_ht
*ht
,
105 struct lttng_ht_node_ulong
*node
);
106 void lttng_ht_add_u64(struct lttng_ht
*ht
,
107 struct lttng_ht_node_u64
*node
);
109 int lttng_ht_del(struct lttng_ht
*ht
, struct lttng_ht_iter
*iter
);
111 void lttng_ht_get_first(struct lttng_ht
*ht
,
112 struct lttng_ht_iter
*iter
);
113 void lttng_ht_get_next(struct lttng_ht
*ht
, struct lttng_ht_iter
*iter
);
115 unsigned long lttng_ht_get_count(struct lttng_ht
*ht
);
117 struct lttng_ht_node_str
*lttng_ht_iter_get_node_str(
118 struct lttng_ht_iter
*iter
);
119 struct lttng_ht_node_ulong
*lttng_ht_iter_get_node_ulong(
120 struct lttng_ht_iter
*iter
);
121 struct lttng_ht_node_u64
*lttng_ht_iter_get_node_u64(
122 struct lttng_ht_iter
*iter
);
123 struct lttng_ht_node_two_u64
*lttng_ht_iter_get_node_two_u64(
124 struct lttng_ht_iter
*iter
);
126 #endif /* _LTT_HT_H */