xref: /netbsd-src/external/cddl/osnet/dist/lib/libdtrace/common/dt_buf.h (revision a864dc36a152ff257761882aea174a236eb36c81)
1*a864dc36Sdarran /*
2*a864dc36Sdarran  * CDDL HEADER START
3*a864dc36Sdarran  *
4*a864dc36Sdarran  * The contents of this file are subject to the terms of the
5*a864dc36Sdarran  * Common Development and Distribution License, Version 1.0 only
6*a864dc36Sdarran  * (the "License").  You may not use this file except in compliance
7*a864dc36Sdarran  * with the License.
8*a864dc36Sdarran  *
9*a864dc36Sdarran  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*a864dc36Sdarran  * or http://www.opensolaris.org/os/licensing.
11*a864dc36Sdarran  * See the License for the specific language governing permissions
12*a864dc36Sdarran  * and limitations under the License.
13*a864dc36Sdarran  *
14*a864dc36Sdarran  * When distributing Covered Code, include this CDDL HEADER in each
15*a864dc36Sdarran  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*a864dc36Sdarran  * If applicable, add the following below this CDDL HEADER, with the
17*a864dc36Sdarran  * fields enclosed by brackets "[]" replaced with your own identifying
18*a864dc36Sdarran  * information: Portions Copyright [yyyy] [name of copyright owner]
19*a864dc36Sdarran  *
20*a864dc36Sdarran  * CDDL HEADER END
21*a864dc36Sdarran  */
22*a864dc36Sdarran /*
23*a864dc36Sdarran  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*a864dc36Sdarran  * Use is subject to license terms.
25*a864dc36Sdarran  */
26*a864dc36Sdarran 
27*a864dc36Sdarran #ifndef	_DT_BUF_H
28*a864dc36Sdarran #define	_DT_BUF_H
29*a864dc36Sdarran 
30*a864dc36Sdarran #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*a864dc36Sdarran 
32*a864dc36Sdarran #ifdef	__cplusplus
33*a864dc36Sdarran extern "C" {
34*a864dc36Sdarran #endif
35*a864dc36Sdarran 
36*a864dc36Sdarran #include <dtrace.h>
37*a864dc36Sdarran 
38*a864dc36Sdarran typedef struct dt_buf {
39*a864dc36Sdarran 	const char *dbu_name;	/* string name for debugging */
40*a864dc36Sdarran 	uchar_t *dbu_buf;	/* buffer base address */
41*a864dc36Sdarran 	uchar_t *dbu_ptr;	/* current buffer location */
42*a864dc36Sdarran 	size_t dbu_len;		/* buffer size in bytes */
43*a864dc36Sdarran 	int dbu_err;		/* errno value if error */
44*a864dc36Sdarran 	int dbu_resizes;	/* number of resizes */
45*a864dc36Sdarran } dt_buf_t;
46*a864dc36Sdarran 
47*a864dc36Sdarran extern void dt_buf_create(dtrace_hdl_t *, dt_buf_t *, const char *, size_t);
48*a864dc36Sdarran extern void dt_buf_destroy(dtrace_hdl_t *, dt_buf_t *);
49*a864dc36Sdarran extern void dt_buf_reset(dtrace_hdl_t *, dt_buf_t *);
50*a864dc36Sdarran 
51*a864dc36Sdarran extern void dt_buf_write(dtrace_hdl_t *, dt_buf_t *,
52*a864dc36Sdarran     const void *, size_t, size_t);
53*a864dc36Sdarran 
54*a864dc36Sdarran extern void dt_buf_concat(dtrace_hdl_t *, dt_buf_t *,
55*a864dc36Sdarran     const dt_buf_t *, size_t);
56*a864dc36Sdarran 
57*a864dc36Sdarran extern size_t dt_buf_offset(const dt_buf_t *, size_t);
58*a864dc36Sdarran extern size_t dt_buf_len(const dt_buf_t *);
59*a864dc36Sdarran 
60*a864dc36Sdarran extern int dt_buf_error(const dt_buf_t *);
61*a864dc36Sdarran extern void *dt_buf_ptr(const dt_buf_t *);
62*a864dc36Sdarran 
63*a864dc36Sdarran extern void *dt_buf_claim(dtrace_hdl_t *, dt_buf_t *);
64*a864dc36Sdarran 
65*a864dc36Sdarran #ifdef	__cplusplus
66*a864dc36Sdarran }
67*a864dc36Sdarran #endif
68*a864dc36Sdarran 
69*a864dc36Sdarran #endif	/* _DT_BUF_H */
70