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