Revert FreeBSD compatibility layer
[lttng-tools.git] / src / common / hashtable / hashtable.h
CommitLineData
bec39940
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; only version 2 of the License.
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
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307, USA.
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
DG
25
26typedef unsigned long (*hash_fct)(void *_key, unsigned long seed);
27typedef cds_lfht_match_fct hash_match_fct;
28
29enum lttng_ht_type {
30 LTTNG_HT_TYPE_STRING,
31 LTTNG_HT_TYPE_ULONG,
32};
33
34struct lttng_ht {
35 struct cds_lfht *ht;
36 cds_lfht_match_fct match_fct;
37 hash_fct hash_fct;
38};
39
40struct lttng_ht_iter {
41 struct cds_lfht_iter iter;
42};
43
44struct lttng_ht_node_str {
45 char *key;
46 struct cds_lfht_node node;
47 struct rcu_head head;
48};
49
50struct lttng_ht_node_ulong {
51 unsigned long key;
52 struct cds_lfht_node node;
53 struct rcu_head head;
54};
55
56/* Hashtable new and destroy */
57extern struct lttng_ht *lttng_ht_new(unsigned long size, int type);
58extern void lttng_ht_destroy(struct lttng_ht *ht);
59
60/* Specialized node init and free functions */
61extern void lttng_ht_node_init_str(struct lttng_ht_node_str *node, char *key);
62extern void lttng_ht_node_init_ulong(struct lttng_ht_node_ulong *node,
63 unsigned long key);
64extern void lttng_ht_node_free_str(struct lttng_ht_node_str *node);
65extern void lttng_ht_node_free_ulong(struct lttng_ht_node_ulong *node);
66
67extern void lttng_ht_lookup(struct lttng_ht *ht, void *key,
68 struct lttng_ht_iter *iter);
69
70/* Specialized add unique functions */
71extern void lttng_ht_add_unique_str(struct lttng_ht *ht,
72 struct lttng_ht_node_str *node);
73extern void lttng_ht_add_unique_ulong(struct lttng_ht *ht,
74 struct lttng_ht_node_ulong *node);
75
76extern int lttng_ht_del(struct lttng_ht *ht, struct lttng_ht_iter *iter);
77
78extern void lttng_ht_get_first(struct lttng_ht *ht,
79 struct lttng_ht_iter *iter);
80extern void lttng_ht_get_next(struct lttng_ht *ht, struct lttng_ht_iter *iter);
81
82extern unsigned long lttng_ht_get_count(struct lttng_ht *ht);
83
84extern struct lttng_ht_node_str *lttng_ht_iter_get_node_str(
85 struct lttng_ht_iter *iter);
86extern struct lttng_ht_node_ulong *lttng_ht_iter_get_node_ulong(
87 struct lttng_ht_iter *iter);
88
89#endif /* _LTT_HT_H */
This page took 0.037826 seconds and 4 git commands to generate.