e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal/*
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * CDDL HEADER START
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal *
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * This file and its contents are supplied under the terms of the
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * Common Development and Distribution License ("CDDL"), version 1.0.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * You may only use this file in accordance with the terms of version
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * 1.0 of the CDDL.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal *
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * A full copy of the text of the CDDL should have accompanied this
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * source. A copy of the CDDL is also available via the Internet at
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * http://www.illumos.org/license/CDDL.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal *
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * CDDL HEADER END
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal */
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal/*
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * Copyright (c) 2012 by Delphix. All rights reserved.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal */
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#ifndef _DT_PQ_H
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#define _DT_PQ_H
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#include <dtrace.h>
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#ifdef __cplusplus
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalextern "C" {
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#endif
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhaltypedef uint64_t (*dt_pq_value_f)(void *, void *);
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhaltypedef struct dt_pq {
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal dtrace_hdl_t *dtpq_hdl; /* dtrace handle */
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal void **dtpq_items; /* array of elements */
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal uint_t dtpq_size; /* count of allocated elements */
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal uint_t dtpq_last; /* next free slot */
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal dt_pq_value_f dtpq_value; /* callback to get the value */
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal void *dtpq_arg; /* callback argument */
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal} dt_pq_t;
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalextern dt_pq_t *dt_pq_init(dtrace_hdl_t *, uint_t size, dt_pq_value_f, void *);
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalextern void dt_pq_fini(dt_pq_t *);
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalextern void dt_pq_insert(dt_pq_t *, void *);
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalextern void *dt_pq_pop(dt_pq_t *);
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalextern void *dt_pq_walk(dt_pq_t *, uint_t *);
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#ifdef __cplusplus
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal}
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#endif
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#endif /* _DT_PQ_H */