xref: /netbsd-src/external/cddl/osnet/dist/lib/libdtrace/common/dt_inttab.h (revision a864dc36a152ff257761882aea174a236eb36c81)
1*a864dc36Sdarran /*
2*a864dc36Sdarran  * CDDL HEADER START
3*a864dc36Sdarran  *
4*a864dc36Sdarran  * The contents of this file are subject to the terms of the
5*a864dc36Sdarran  * Common Development and Distribution License, Version 1.0 only
6*a864dc36Sdarran  * (the "License").  You may not use this file except in compliance
7*a864dc36Sdarran  * with the License.
8*a864dc36Sdarran  *
9*a864dc36Sdarran  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*a864dc36Sdarran  * or http://www.opensolaris.org/os/licensing.
11*a864dc36Sdarran  * See the License for the specific language governing permissions
12*a864dc36Sdarran  * and limitations under the License.
13*a864dc36Sdarran  *
14*a864dc36Sdarran  * When distributing Covered Code, include this CDDL HEADER in each
15*a864dc36Sdarran  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*a864dc36Sdarran  * If applicable, add the following below this CDDL HEADER, with the
17*a864dc36Sdarran  * fields enclosed by brackets "[]" replaced with your own identifying
18*a864dc36Sdarran  * information: Portions Copyright [yyyy] [name of copyright owner]
19*a864dc36Sdarran  *
20*a864dc36Sdarran  * CDDL HEADER END
21*a864dc36Sdarran  */
22*a864dc36Sdarran /*
23*a864dc36Sdarran  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*a864dc36Sdarran  * Use is subject to license terms.
25*a864dc36Sdarran  */
26*a864dc36Sdarran 
27*a864dc36Sdarran #ifndef	_DT_INTTAB_H
28*a864dc36Sdarran #define	_DT_INTTAB_H
29*a864dc36Sdarran 
30*a864dc36Sdarran #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*a864dc36Sdarran 
32*a864dc36Sdarran #include <dtrace.h>
33*a864dc36Sdarran 
34*a864dc36Sdarran #ifdef	__cplusplus
35*a864dc36Sdarran extern "C" {
36*a864dc36Sdarran #endif
37*a864dc36Sdarran 
38*a864dc36Sdarran typedef struct dt_inthash {
39*a864dc36Sdarran 	struct dt_inthash *inh_hash;	/* next dt_inthash in hash chain */
40*a864dc36Sdarran 	struct dt_inthash *inh_next;	/* next dt_inthash in output table */
41*a864dc36Sdarran 	uint64_t inh_value;		/* value associated with this element */
42*a864dc36Sdarran 	uint_t inh_index;		/* index associated with this element */
43*a864dc36Sdarran 	uint_t inh_flags;		/* flags (see below) */
44*a864dc36Sdarran } dt_inthash_t;
45*a864dc36Sdarran 
46*a864dc36Sdarran typedef struct dt_inttab {
47*a864dc36Sdarran 	dtrace_hdl_t *int_hdl;		/* pointer back to library handle */
48*a864dc36Sdarran 	dt_inthash_t **int_hash;	/* array of hash buckets */
49*a864dc36Sdarran 	uint_t int_hashlen;		/* size of hash bucket array */
50*a864dc36Sdarran 	uint_t int_nelems;		/* number of elements hashed */
51*a864dc36Sdarran 	dt_inthash_t *int_head;		/* head of table in index order */
52*a864dc36Sdarran 	dt_inthash_t *int_tail;		/* tail of table in index order */
53*a864dc36Sdarran 	uint_t int_index;		/* next index to hand out */
54*a864dc36Sdarran } dt_inttab_t;
55*a864dc36Sdarran 
56*a864dc36Sdarran #define	DT_INT_PRIVATE	0		/* only a single ref for this entry */
57*a864dc36Sdarran #define	DT_INT_SHARED	1		/* multiple refs can share entry */
58*a864dc36Sdarran 
59*a864dc36Sdarran extern dt_inttab_t *dt_inttab_create(dtrace_hdl_t *);
60*a864dc36Sdarran extern void dt_inttab_destroy(dt_inttab_t *);
61*a864dc36Sdarran extern int dt_inttab_insert(dt_inttab_t *, uint64_t, uint_t);
62*a864dc36Sdarran extern uint_t dt_inttab_size(const dt_inttab_t *);
63*a864dc36Sdarran extern void dt_inttab_write(const dt_inttab_t *, uint64_t *);
64*a864dc36Sdarran 
65*a864dc36Sdarran #ifdef	__cplusplus
66*a864dc36Sdarran }
67*a864dc36Sdarran #endif
68*a864dc36Sdarran 
69*a864dc36Sdarran #endif	/* _DT_INTTAB_H */
70