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