1191783Srmacklem/*-
2191783Srmacklem * Copyright (c) 2009 Rick Macklem, University of Guelph
3191783Srmacklem * All rights reserved.
4191783Srmacklem *
5191783Srmacklem * Redistribution and use in source and binary forms, with or without
6191783Srmacklem * modification, are permitted provided that the following conditions
7191783Srmacklem * are met:
8191783Srmacklem * 1. Redistributions of source code must retain the above copyright
9191783Srmacklem *    notice, this list of conditions and the following disclaimer.
10191783Srmacklem * 2. Redistributions in binary form must reproduce the above copyright
11191783Srmacklem *    notice, this list of conditions and the following disclaimer in the
12191783Srmacklem *    documentation and/or other materials provided with the distribution.
13191783Srmacklem *
14191783Srmacklem * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15191783Srmacklem * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16191783Srmacklem * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17191783Srmacklem * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18191783Srmacklem * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19191783Srmacklem * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20191783Srmacklem * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21191783Srmacklem * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22191783Srmacklem * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23191783Srmacklem * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24191783Srmacklem * SUCH DAMAGE.
25191783Srmacklem *
26191783Srmacklem * $FreeBSD$
27191783Srmacklem */
28191783Srmacklem
29191783Srmacklem#ifndef _NFS_NFSKPIPORT_H_
30207785Srmacklem#define	_NFS_NFSKPIPORT_H_
31191783Srmacklem/*
32191783Srmacklem * These definitions are needed since the generic code is now using Darwin8
33191783Srmacklem * KPI stuff. (I know, seems a bit silly, but I want the code to build on
34191783Srmacklem * Darwin8 and hopefully subsequent releases from Apple.)
35191783Srmacklem */
36191783Srmacklemtypedef	struct mount *		mount_t;
37191783Srmacklem#define	vfs_statfs(m)		(&((m)->mnt_stat))
38191783Srmacklem#define	vfs_flags(m)		((m)->mnt_flag)
39191783Srmacklem
40191783Srmacklemtypedef struct vnode *		vnode_t;
41191783Srmacklem#define	vnode_mount(v)		((v)->v_mount)
42191783Srmacklem#define	vnode_vtype(v)		((v)->v_type)
43191783Srmacklem
44191783Srmacklemtypedef struct mbuf *		mbuf_t;
45191783Srmacklem#define	mbuf_freem(m)		m_freem(m)
46191783Srmacklem#define	mbuf_data(m)		mtod((m), void *)
47191783Srmacklem#define	mbuf_len(m)		((m)->m_len)
48191783Srmacklem#define	mbuf_next(m)		((m)->m_next)
49191783Srmacklem#define	mbuf_setlen(m, l)	((m)->m_len = (l))
50191783Srmacklem#define	mbuf_setnext(m, p)	((m)->m_next = (p))
51191783Srmacklem#define	mbuf_pkthdr_len(m)	((m)->m_pkthdr.len)
52191783Srmacklem#define	mbuf_pkthdr_setlen(m, l) ((m)->m_pkthdr.len = (l))
53191783Srmacklem#define	mbuf_pkthdr_setrcvif(m, p) ((m)->m_pkthdr.rcvif = (p))
54191783Srmacklem
55191783Srmacklem/*
56191783Srmacklem * This stuff is needed by Darwin for handling the uio structure.
57191783Srmacklem */
58191783Srmacklem#define	CAST_USER_ADDR_T(a)	(a)
59191783Srmacklem#define	CAST_DOWN(c, a)		((c) (a))
60191783Srmacklem#define	uio_uio_resid(p)	((p)->uio_resid)
61191783Srmacklem#define	uio_uio_resid_add(p, v)	((p)->uio_resid += (v))
62191783Srmacklem#define	uio_uio_resid_set(p, v)	((p)->uio_resid = (v))
63191783Srmacklem#define	uio_iov_base(p)		((p)->uio_iov->iov_base)
64191783Srmacklem#define	uio_iov_base_add(p, v)	do {					\
65191783Srmacklem	char *pp;							\
66191783Srmacklem	pp = (char *)(p)->uio_iov->iov_base;				\
67191783Srmacklem	pp += (v);							\
68191783Srmacklem	(p)->uio_iov->iov_base = (void *)pp;				\
69191783Srmacklem    } while (0)
70191783Srmacklem#define	uio_iov_len(p)		((p)->uio_iov->iov_len)
71191783Srmacklem#define	uio_iov_len_add(p, v)	((p)->uio_iov->iov_len += (v))
72191783Srmacklem
73207785Srmacklem#endif	/* _NFS_NFSKPIPORT_H */
74