summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2007-05-27 20:54:26 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2007-05-27 20:54:26 +0000
commit9633961c8ea8042fb22c2f4cbefc824a6980bcbd (patch)
treeb652a0c77381c84d99defb05b29909772d6799df /sys/kern
parentc51554c18c6367c56e04251989f51d729fa69e0e (diff)
Kill the nasty MGET, MGETHDR and MCLGET makros and replace them with normal
functions. The world is no longer running on a PDP11 so function call overhead is not an issue. Diff by tbert, tested by many, OK art@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_mbuf.c83
1 files changed, 48 insertions, 35 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 0074b8f63a0..a7786a6ec06 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.80 2007/03/15 11:48:09 claudio Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.81 2007/05/27 20:54:25 claudio Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -153,15 +153,24 @@ m_reclaim(void *arg, int flags)
/*
* Space allocation routines.
- * These are also available as macros
- * for critical paths.
*/
struct mbuf *
m_get(int nowait, int type)
{
struct mbuf *m;
-
- MGET(m, nowait, type);
+ int s;
+
+ s = splvm();
+ m = pool_get(&mbpool, nowait == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : 0);
+ if (m) {
+ m->m_type = type;
+ mbstat.m_mtypes[type]++;
+ m->m_next = (struct mbuf *)NULL;
+ m->m_nextpkt = (struct mbuf *)NULL;
+ m->m_data = m->m_dat;
+ m->m_flags = 0;
+ }
+ splx(s);
return (m);
}
@@ -169,8 +178,21 @@ struct mbuf *
m_gethdr(int nowait, int type)
{
struct mbuf *m;
-
- MGETHDR(m, nowait, type);
+ int s;
+
+ s = splvm();
+ m = pool_get(&mbpool, nowait == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : 0);
+ if (m) {
+ m->m_type = type;
+ mbstat.m_mtypes[type]++;
+ m->m_next = (struct mbuf *)NULL;
+ m->m_nextpkt = (struct mbuf *)NULL;
+ m->m_data = m->m_pktdat;
+ m->m_flags = M_PKTHDR;
+ SLIST_INIT(&m->m_pkthdr.tags);
+ m->m_pkthdr.csum_flags = 0;
+ }
+ splx(s);
return (m);
}
@@ -186,6 +208,25 @@ m_getclr(int nowait, int type)
return (m);
}
+void
+m_clget(struct mbuf *m, int how)
+{
+ int s;
+
+ s = splvm();
+ m->m_ext.ext_buf =
+ pool_get(&mclpool, how == M_WAIT ? (PR_WAITOK|PR_LIMITFAIL) : 0);
+ splx(s);
+ if (m->m_ext.ext_buf != NULL) {
+ m->m_data = m->m_ext.ext_buf;
+ m->m_flags |= M_EXT|M_CLUSTER;
+ m->m_ext.ext_size = MCLBYTES;
+ m->m_ext.ext_free = NULL;
+ m->m_ext.ext_arg = NULL;
+ MCLINITREFERENCE(m);
+ }
+}
+
struct mbuf *
m_free(struct mbuf *m)
{
@@ -944,31 +985,3 @@ m_apply(struct mbuf *m, int off, int len,
return (0);
}
-
-#ifdef SMALL_KERNEL
-/*
- * The idea of adding code in a small kernel might look absurd, but this is
- * instead of macros.
- */
-struct mbuf *
-_sk_mget(int how, int type)
-{
- struct mbuf *m;
- _MGET(m, how, type);
- return m;
-}
-
-struct mbuf *
-_sk_mgethdr(int how, int type)
-{
- struct mbuf *m;
- _MGETHDR(m, how, type);
- return m;
-}
-
-void
-_sk_mclget(struct mbuf *m, int how)
-{
- _MCLGET(m, how);
-}
-#endif /* SMALL_KERNEL */