xref: /freebsd/cddl/contrib/opensolaris/lib/libdtrace/common/dt_buf.h (revision 6ff6d951ade3f3379932df7f878ef3ea272cfc59)
16ff6d951SJohn Birrell /*
26ff6d951SJohn Birrell  * CDDL HEADER START
36ff6d951SJohn Birrell  *
46ff6d951SJohn Birrell  * The contents of this file are subject to the terms of the
56ff6d951SJohn Birrell  * Common Development and Distribution License, Version 1.0 only
66ff6d951SJohn Birrell  * (the "License").  You may not use this file except in compliance
76ff6d951SJohn Birrell  * with the License.
86ff6d951SJohn Birrell  *
96ff6d951SJohn Birrell  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
106ff6d951SJohn Birrell  * or http://www.opensolaris.org/os/licensing.
116ff6d951SJohn Birrell  * See the License for the specific language governing permissions
126ff6d951SJohn Birrell  * and limitations under the License.
136ff6d951SJohn Birrell  *
146ff6d951SJohn Birrell  * When distributing Covered Code, include this CDDL HEADER in each
156ff6d951SJohn Birrell  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
166ff6d951SJohn Birrell  * If applicable, add the following below this CDDL HEADER, with the
176ff6d951SJohn Birrell  * fields enclosed by brackets "[]" replaced with your own identifying
186ff6d951SJohn Birrell  * information: Portions Copyright [yyyy] [name of copyright owner]
196ff6d951SJohn Birrell  *
206ff6d951SJohn Birrell  * CDDL HEADER END
216ff6d951SJohn Birrell  */
226ff6d951SJohn Birrell /*
236ff6d951SJohn Birrell  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
246ff6d951SJohn Birrell  * Use is subject to license terms.
256ff6d951SJohn Birrell  */
266ff6d951SJohn Birrell 
276ff6d951SJohn Birrell #ifndef	_DT_BUF_H
286ff6d951SJohn Birrell #define	_DT_BUF_H
296ff6d951SJohn Birrell 
306ff6d951SJohn Birrell #pragma ident	"%Z%%M%	%I%	%E% SMI"
316ff6d951SJohn Birrell 
326ff6d951SJohn Birrell #ifdef	__cplusplus
336ff6d951SJohn Birrell extern "C" {
346ff6d951SJohn Birrell #endif
356ff6d951SJohn Birrell 
366ff6d951SJohn Birrell #include <dtrace.h>
376ff6d951SJohn Birrell 
386ff6d951SJohn Birrell typedef struct dt_buf {
396ff6d951SJohn Birrell 	const char *dbu_name;	/* string name for debugging */
406ff6d951SJohn Birrell 	uchar_t *dbu_buf;	/* buffer base address */
416ff6d951SJohn Birrell 	uchar_t *dbu_ptr;	/* current buffer location */
426ff6d951SJohn Birrell 	size_t dbu_len;		/* buffer size in bytes */
436ff6d951SJohn Birrell 	int dbu_err;		/* errno value if error */
446ff6d951SJohn Birrell 	int dbu_resizes;	/* number of resizes */
456ff6d951SJohn Birrell } dt_buf_t;
466ff6d951SJohn Birrell 
476ff6d951SJohn Birrell extern void dt_buf_create(dtrace_hdl_t *, dt_buf_t *, const char *, size_t);
486ff6d951SJohn Birrell extern void dt_buf_destroy(dtrace_hdl_t *, dt_buf_t *);
496ff6d951SJohn Birrell extern void dt_buf_reset(dtrace_hdl_t *, dt_buf_t *);
506ff6d951SJohn Birrell 
516ff6d951SJohn Birrell extern void dt_buf_write(dtrace_hdl_t *, dt_buf_t *,
526ff6d951SJohn Birrell     const void *, size_t, size_t);
536ff6d951SJohn Birrell 
546ff6d951SJohn Birrell extern void dt_buf_concat(dtrace_hdl_t *, dt_buf_t *,
556ff6d951SJohn Birrell     const dt_buf_t *, size_t);
566ff6d951SJohn Birrell 
576ff6d951SJohn Birrell extern size_t dt_buf_offset(const dt_buf_t *, size_t);
586ff6d951SJohn Birrell extern size_t dt_buf_len(const dt_buf_t *);
596ff6d951SJohn Birrell 
606ff6d951SJohn Birrell extern int dt_buf_error(const dt_buf_t *);
616ff6d951SJohn Birrell extern void *dt_buf_ptr(const dt_buf_t *);
626ff6d951SJohn Birrell 
636ff6d951SJohn Birrell extern void *dt_buf_claim(dtrace_hdl_t *, dt_buf_t *);
646ff6d951SJohn Birrell 
656ff6d951SJohn Birrell #ifdef	__cplusplus
666ff6d951SJohn Birrell }
676ff6d951SJohn Birrell #endif
686ff6d951SJohn Birrell 
696ff6d951SJohn Birrell #endif	/* _DT_BUF_H */
70