xref: /freebsd/cddl/contrib/opensolaris/lib/libdtrace/common/dt_inttab.h (revision 6ff6d951ade3f3379932df7f878ef3ea272cfc59)
16ff6d951SJohn Birrell /*
26ff6d951SJohn Birrell  * CDDL HEADER START
36ff6d951SJohn Birrell  *
46ff6d951SJohn Birrell  * The contents of this file are subject to the terms of the
56ff6d951SJohn Birrell  * Common Development and Distribution License, Version 1.0 only
66ff6d951SJohn Birrell  * (the "License").  You may not use this file except in compliance
76ff6d951SJohn Birrell  * with the License.
86ff6d951SJohn Birrell  *
96ff6d951SJohn Birrell  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
106ff6d951SJohn Birrell  * or http://www.opensolaris.org/os/licensing.
116ff6d951SJohn Birrell  * See the License for the specific language governing permissions
126ff6d951SJohn Birrell  * and limitations under the License.
136ff6d951SJohn Birrell  *
146ff6d951SJohn Birrell  * When distributing Covered Code, include this CDDL HEADER in each
156ff6d951SJohn Birrell  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
166ff6d951SJohn Birrell  * If applicable, add the following below this CDDL HEADER, with the
176ff6d951SJohn Birrell  * fields enclosed by brackets "[]" replaced with your own identifying
186ff6d951SJohn Birrell  * information: Portions Copyright [yyyy] [name of copyright owner]
196ff6d951SJohn Birrell  *
206ff6d951SJohn Birrell  * CDDL HEADER END
216ff6d951SJohn Birrell  */
226ff6d951SJohn Birrell /*
236ff6d951SJohn Birrell  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
246ff6d951SJohn Birrell  * Use is subject to license terms.
256ff6d951SJohn Birrell  */
266ff6d951SJohn Birrell 
276ff6d951SJohn Birrell #ifndef	_DT_INTTAB_H
286ff6d951SJohn Birrell #define	_DT_INTTAB_H
296ff6d951SJohn Birrell 
306ff6d951SJohn Birrell #pragma ident	"%Z%%M%	%I%	%E% SMI"
316ff6d951SJohn Birrell 
326ff6d951SJohn Birrell #include <dtrace.h>
336ff6d951SJohn Birrell 
346ff6d951SJohn Birrell #ifdef	__cplusplus
356ff6d951SJohn Birrell extern "C" {
366ff6d951SJohn Birrell #endif
376ff6d951SJohn Birrell 
386ff6d951SJohn Birrell typedef struct dt_inthash {
396ff6d951SJohn Birrell 	struct dt_inthash *inh_hash;	/* next dt_inthash in hash chain */
406ff6d951SJohn Birrell 	struct dt_inthash *inh_next;	/* next dt_inthash in output table */
416ff6d951SJohn Birrell 	uint64_t inh_value;		/* value associated with this element */
426ff6d951SJohn Birrell 	uint_t inh_index;		/* index associated with this element */
436ff6d951SJohn Birrell 	uint_t inh_flags;		/* flags (see below) */
446ff6d951SJohn Birrell } dt_inthash_t;
456ff6d951SJohn Birrell 
466ff6d951SJohn Birrell typedef struct dt_inttab {
476ff6d951SJohn Birrell 	dtrace_hdl_t *int_hdl;		/* pointer back to library handle */
486ff6d951SJohn Birrell 	dt_inthash_t **int_hash;	/* array of hash buckets */
496ff6d951SJohn Birrell 	uint_t int_hashlen;		/* size of hash bucket array */
506ff6d951SJohn Birrell 	uint_t int_nelems;		/* number of elements hashed */
516ff6d951SJohn Birrell 	dt_inthash_t *int_head;		/* head of table in index order */
526ff6d951SJohn Birrell 	dt_inthash_t *int_tail;		/* tail of table in index order */
536ff6d951SJohn Birrell 	uint_t int_index;		/* next index to hand out */
546ff6d951SJohn Birrell } dt_inttab_t;
556ff6d951SJohn Birrell 
566ff6d951SJohn Birrell #define	DT_INT_PRIVATE	0		/* only a single ref for this entry */
576ff6d951SJohn Birrell #define	DT_INT_SHARED	1		/* multiple refs can share entry */
586ff6d951SJohn Birrell 
596ff6d951SJohn Birrell extern dt_inttab_t *dt_inttab_create(dtrace_hdl_t *);
606ff6d951SJohn Birrell extern void dt_inttab_destroy(dt_inttab_t *);
616ff6d951SJohn Birrell extern int dt_inttab_insert(dt_inttab_t *, uint64_t, uint_t);
626ff6d951SJohn Birrell extern uint_t dt_inttab_size(const dt_inttab_t *);
636ff6d951SJohn Birrell extern void dt_inttab_write(const dt_inttab_t *, uint64_t *);
646ff6d951SJohn Birrell 
656ff6d951SJohn Birrell #ifdef	__cplusplus
666ff6d951SJohn Birrell }
676ff6d951SJohn Birrell #endif
686ff6d951SJohn Birrell 
696ff6d951SJohn Birrell #endif	/* _DT_INTTAB_H */
70