2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2015 Joyent, Inc.
16 #ifndef _SYS_REFHASH_H
17 #define _SYS_REFHASH_H
19 #include <sys/types.h>
22 #define RHL_F_DEAD 0x01
24 typedef struct refhash_link
{
25 list_node_t rhl_chain_link
;
26 list_node_t rhl_global_link
;
31 typedef uint64_t (*refhash_hash_f
)(const void *);
32 typedef int (*refhash_cmp_f
)(const void *, const void *);
33 typedef void (*refhash_dtor_f
)(void *);
34 typedef int (*refhash_eval_f
)(const void *, void *);
36 typedef struct refhash
{
38 uint_t rh_bucket_count
;
40 size_t rh_obj_size
; /* used by mdb */
43 refhash_hash_f rh_hash
;
45 refhash_dtor_f rh_dtor
;
48 extern refhash_t
*refhash_create(uint_t
, refhash_hash_f
, refhash_cmp_f
,
49 refhash_dtor_f
, size_t, size_t, size_t, int);
50 extern void refhash_destroy(refhash_t
*);
51 extern void refhash_insert(refhash_t
*, void *);
52 extern void refhash_remove(refhash_t
*, void *);
53 extern void *refhash_lookup(refhash_t
*, const void *);
54 extern void *refhash_linear_search(refhash_t
*, refhash_eval_f
, void *);
55 extern void refhash_hold(refhash_t
*, void *);
56 extern void refhash_rele(refhash_t
*, void *);
57 extern void *refhash_first(refhash_t
*);
58 extern void *refhash_next(refhash_t
*, void *);
59 extern boolean_t
refhash_obj_valid(refhash_t
*hp
, const void *);
61 #endif /* _SYS_REFHASH_H */