xref: /freebsd/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pq.h (revision 40f65a4df509c6b29b9e72407c7afefe28838844)
1*09e6105fSMark Johnston /*
2*09e6105fSMark Johnston  * CDDL HEADER START
3*09e6105fSMark Johnston  *
4*09e6105fSMark Johnston  * This file and its contents are supplied under the terms of the
5*09e6105fSMark Johnston  * Common Development and Distribution License ("CDDL"), version 1.0.
6*09e6105fSMark Johnston  * You may only use this file in accordance with the terms of version
7*09e6105fSMark Johnston  * 1.0 of the CDDL.
8*09e6105fSMark Johnston  *
9*09e6105fSMark Johnston  * A full copy of the text of the CDDL should have accompanied this
10*09e6105fSMark Johnston  * source.  A copy of the CDDL is also available via the Internet at
11*09e6105fSMark Johnston  * http://www.illumos.org/license/CDDL.
12*09e6105fSMark Johnston  *
13*09e6105fSMark Johnston  * CDDL HEADER END
14*09e6105fSMark Johnston  */
15*09e6105fSMark Johnston 
16*09e6105fSMark Johnston /*
17*09e6105fSMark Johnston  * Copyright (c) 2012 by Delphix. All rights reserved.
18*09e6105fSMark Johnston  */
19*09e6105fSMark Johnston 
20*09e6105fSMark Johnston #ifndef	_DT_PQ_H
21*09e6105fSMark Johnston #define	_DT_PQ_H
22*09e6105fSMark Johnston 
23*09e6105fSMark Johnston #include <dtrace.h>
24*09e6105fSMark Johnston 
25*09e6105fSMark Johnston #ifdef	__cplusplus
26*09e6105fSMark Johnston extern "C" {
27*09e6105fSMark Johnston #endif
28*09e6105fSMark Johnston 
29*09e6105fSMark Johnston typedef uint64_t (*dt_pq_value_f)(void *, void *);
30*09e6105fSMark Johnston 
31*09e6105fSMark Johnston typedef struct dt_pq {
32*09e6105fSMark Johnston 	dtrace_hdl_t *dtpq_hdl;		/* dtrace handle */
33*09e6105fSMark Johnston 	void **dtpq_items;		/* array of elements */
34*09e6105fSMark Johnston 	uint_t dtpq_size;		/* count of allocated elements */
35*09e6105fSMark Johnston 	uint_t dtpq_last;		/* next free slot */
36*09e6105fSMark Johnston 	dt_pq_value_f dtpq_value;	/* callback to get the value */
37*09e6105fSMark Johnston 	void *dtpq_arg;			/* callback argument */
38*09e6105fSMark Johnston } dt_pq_t;
39*09e6105fSMark Johnston 
40*09e6105fSMark Johnston extern dt_pq_t *dt_pq_init(dtrace_hdl_t *, uint_t size, dt_pq_value_f, void *);
41*09e6105fSMark Johnston extern void dt_pq_fini(dt_pq_t *);
42*09e6105fSMark Johnston 
43*09e6105fSMark Johnston extern void dt_pq_insert(dt_pq_t *, void *);
44*09e6105fSMark Johnston extern void *dt_pq_pop(dt_pq_t *);
45*09e6105fSMark Johnston extern void *dt_pq_walk(dt_pq_t *, uint_t *);
46*09e6105fSMark Johnston 
47*09e6105fSMark Johnston #ifdef	__cplusplus
48*09e6105fSMark Johnston }
49*09e6105fSMark Johnston #endif
50*09e6105fSMark Johnston 
51*09e6105fSMark Johnston #endif	/* _DT_PQ_H */
52