2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "rculfhash.h"
24 #include "rculfhash-internal.h"
26 typedef unsigned long (*hash_fct
)(void *_key
, unsigned long seed
);
27 typedef cds_lfht_match_fct hash_match_fct
;
36 cds_lfht_match_fct match_fct
;
40 struct lttng_ht_iter
{
41 struct cds_lfht_iter iter
;
44 struct lttng_ht_node_str
{
46 struct cds_lfht_node node
;
50 struct lttng_ht_node_ulong
{
52 struct cds_lfht_node node
;
56 /* Hashtable new and destroy */
57 extern struct lttng_ht
*lttng_ht_new(unsigned long size
, int type
);
58 extern void lttng_ht_destroy(struct lttng_ht
*ht
);
60 /* Specialized node init and free functions */
61 extern void lttng_ht_node_init_str(struct lttng_ht_node_str
*node
, char *key
);
62 extern void lttng_ht_node_init_ulong(struct lttng_ht_node_ulong
*node
,
64 extern void lttng_ht_node_free_str(struct lttng_ht_node_str
*node
);
65 extern void lttng_ht_node_free_ulong(struct lttng_ht_node_ulong
*node
);
67 extern void lttng_ht_lookup(struct lttng_ht
*ht
, void *key
,
68 struct lttng_ht_iter
*iter
);
70 /* Specialized add unique functions */
71 extern void lttng_ht_add_unique_str(struct lttng_ht
*ht
,
72 struct lttng_ht_node_str
*node
);
73 extern void lttng_ht_add_unique_ulong(struct lttng_ht
*ht
,
74 struct lttng_ht_node_ulong
*node
);
75 struct lttng_ht_node_ulong
*lttng_ht_add_replace_ulong(struct lttng_ht
*ht
,
76 struct lttng_ht_node_ulong
*node
);
78 extern int lttng_ht_del(struct lttng_ht
*ht
, struct lttng_ht_iter
*iter
);
80 extern void lttng_ht_get_first(struct lttng_ht
*ht
,
81 struct lttng_ht_iter
*iter
);
82 extern void lttng_ht_get_next(struct lttng_ht
*ht
, struct lttng_ht_iter
*iter
);
84 extern unsigned long lttng_ht_get_count(struct lttng_ht
*ht
);
86 extern struct lttng_ht_node_str
*lttng_ht_iter_get_node_str(
87 struct lttng_ht_iter
*iter
);
88 extern struct lttng_ht_node_ulong
*lttng_ht_iter_get_node_ulong(
89 struct lttng_ht_iter
*iter
);
91 #endif /* _LTT_HT_H */