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