Fix: RCU hash table seed
[lttng-tools.git] / src / common / hashtable / hashtable.h
CommitLineData
bec39940
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
d14d33bf
AM
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.
bec39940
DG
7 *
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
d14d33bf 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
bec39940
DG
11 * more details.
12 *
d14d33bf
AM
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.
bec39940
DG
16 */
17
18#ifndef _LTT_HT_H
19#define _LTT_HT_H
20
21#include <urcu.h>
10a8a223
DG
22
23#include "rculfhash.h"
24#include "rculfhash-internal.h"
bec39940 25
b6314938
DG
26extern unsigned long lttng_ht_seed;
27
bec39940
DG
28typedef unsigned long (*hash_fct)(void *_key, unsigned long seed);
29typedef cds_lfht_match_fct hash_match_fct;
30
31enum lttng_ht_type {
32 LTTNG_HT_TYPE_STRING,
33 LTTNG_HT_TYPE_ULONG,
34};
35
36struct lttng_ht {
37 struct cds_lfht *ht;
38 cds_lfht_match_fct match_fct;
39 hash_fct hash_fct;
40};
41
42struct lttng_ht_iter {
43 struct cds_lfht_iter iter;
44};
45
46struct lttng_ht_node_str {
47 char *key;
48 struct cds_lfht_node node;
49 struct rcu_head head;
50};
51
52struct lttng_ht_node_ulong {
53 unsigned long key;
54 struct cds_lfht_node node;
55 struct rcu_head head;
56};
57
58/* Hashtable new and destroy */
59extern struct lttng_ht *lttng_ht_new(unsigned long size, int type);
60extern void lttng_ht_destroy(struct lttng_ht *ht);
61
62/* Specialized node init and free functions */
63extern void lttng_ht_node_init_str(struct lttng_ht_node_str *node, char *key);
64extern void lttng_ht_node_init_ulong(struct lttng_ht_node_ulong *node,
65 unsigned long key);
66extern void lttng_ht_node_free_str(struct lttng_ht_node_str *node);
67extern void lttng_ht_node_free_ulong(struct lttng_ht_node_ulong *node);
68
69extern void lttng_ht_lookup(struct lttng_ht *ht, void *key,
70 struct lttng_ht_iter *iter);
71
72/* Specialized add unique functions */
73extern void lttng_ht_add_unique_str(struct lttng_ht *ht,
74 struct lttng_ht_node_str *node);
75extern void lttng_ht_add_unique_ulong(struct lttng_ht *ht,
76 struct lttng_ht_node_ulong *node);
852d0037
DG
77extern struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(
78 struct lttng_ht *ht, struct lttng_ht_node_ulong *node);
aefea3b7
DG
79extern void lttng_ht_add_ulong(struct lttng_ht *ht,
80 struct lttng_ht_node_ulong *node);
bec39940
DG
81
82extern int lttng_ht_del(struct lttng_ht *ht, struct lttng_ht_iter *iter);
83
84extern void lttng_ht_get_first(struct lttng_ht *ht,
85 struct lttng_ht_iter *iter);
86extern void lttng_ht_get_next(struct lttng_ht *ht, struct lttng_ht_iter *iter);
87
88extern unsigned long lttng_ht_get_count(struct lttng_ht *ht);
89
90extern struct lttng_ht_node_str *lttng_ht_iter_get_node_str(
91 struct lttng_ht_iter *iter);
92extern struct lttng_ht_node_ulong *lttng_ht_iter_get_node_ulong(
93 struct lttng_ht_iter *iter);
94
95#endif /* _LTT_HT_H */
This page took 0.030459 seconds and 4 git commands to generate.