strsun.h revision 6990:d24af98bb8ea
1234353Sdim/*
2193323Sed * CDDL HEADER START
3193323Sed *
4193323Sed * The contents of this file are subject to the terms of the
5193323Sed * Common Development and Distribution License (the "License").
6193323Sed * You may not use this file except in compliance with the License.
7193323Sed *
8193323Sed * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9193323Sed * or http://www.opensolaris.org/os/licensing.
10193323Sed * See the License for the specific language governing permissions
11193323Sed * and limitations under the License.
12193323Sed *
13193323Sed * When distributing Covered Code, include this CDDL HEADER in each
14234353Sdim * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15193323Sed * If applicable, add the following below this CDDL HEADER, with the
16193323Sed * fields enclosed by brackets "[]" replaced with your own identifying
17193323Sed * information: Portions Copyright [yyyy] [name of copyright owner]
18193323Sed *
19193323Sed * CDDL HEADER END
20193323Sed */
21193323Sed/*
22198090Srdivacky * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23226633Sdim * Use is subject to license terms.
24193323Sed */
25224145Sdim
26224145Sdim#ifndef	_SYS_STRSUN_H
27224145Sdim#define	_SYS_STRSUN_H
28193323Sed
29193323Sed#pragma ident	"%Z%%M%	%I%	%E% SMI"
30193323Sed
31224145Sdim#include <sys/stream.h>
32193323Sed#include <sys/types.h>
33193323Sed
34193323Sed#ifdef	__cplusplus
35193323Sedextern "C" {
36193323Sed#endif
37208599Srdivacky
38208599Srdivacky/*
39206124Srdivacky * Solaris DDI STREAMS utility routines.
40193323Sed *
41199481Srdivacky * See the appropriate section 9F manpage for documentation.
42199481Srdivacky */
43193323Sed
44199481Srdivacky#define	DB_BASE(mp)	((mp)->b_datap->db_base)
45234353Sdim#define	DB_LIM(mp)	((mp)->b_datap->db_lim)
46218893Sdim#define	DB_REF(mp)	((mp)->b_datap->db_ref)
47199481Srdivacky#define	DB_TYPE(mp)	((mp)->b_datap->db_type)
48199481Srdivacky#define	DB_FLAGS(mp)	((mp)->b_datap->db_flags)
49199481Srdivacky
50193323Sed#define	_PTRDIFF(p1, p2)	((intptr_t)((uintptr_t)(p1) - (uintptr_t)(p2)))
51193323Sed#define	MBLKL(mp)		_PTRDIFF((mp)->b_wptr, (mp)->b_rptr)
52193323Sed#define	MBLKSIZE(mp)		_PTRDIFF(DB_LIM(mp), DB_BASE(mp))
53199481Srdivacky#define	MBLKHEAD(mp)		_PTRDIFF((mp)->b_rptr, DB_BASE(mp))
54193323Sed#define	MBLKTAIL(mp)		_PTRDIFF(DB_LIM(mp), (mp)->b_wptr)
55193323Sed#define	MBLKIN(mp, off, len) (((off) <= MBLKL(mp)) && \
56193323Sed	(((mp)->b_rptr + (off) + (len)) <= (mp)->b_wptr))
57199481Srdivacky
58193323Sed#ifdef	_KERNEL
59198090Srdivackyextern void	mcopyin(mblk_t *, void *, size_t, void *);
60193323Sedextern void	mcopyout(mblk_t *, void *, size_t, void *, mblk_t *);
61193323Sedextern void	merror(queue_t *, mblk_t *, int);
62193323Sedextern void	mioc2ack(mblk_t *, mblk_t *, size_t, int);
63193323Sedextern void	miocack(queue_t *, mblk_t *, int, int);
64193323Sedextern void	miocnak(queue_t *, mblk_t *, int, int);
65208599Srdivackyextern int	miocpullup(mblk_t *, size_t);
66208599Srdivackyextern mblk_t	*mexchange(queue_t *, mblk_t *, size_t, uchar_t, int32_t);
67206124Srdivackyextern size_t	msgsize(mblk_t *);
68193323Sedextern void	mcopymsg(mblk_t *, void *);
69199481Srdivacky
70199481Srdivacky#endif	/* _KERNEL */
71193323Sed
72199481Srdivacky#ifdef	__cplusplus
73234353Sdim}
74218893Sdim#endif
75199481Srdivacky
76199481Srdivacky#endif	/* _SYS_STRSUN_H */
77199481Srdivacky