diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2007-11-27 16:38:51 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2007-11-27 16:38:51 +0000 |
commit | 71abb69ad5b56f2815e077a3ef725973b5a7e280 (patch) | |
tree | 3d5dcb1b7c775d86a0454bf10df173e609b24678 /sys | |
parent | 661bb1dc316274e863790dc316fd698c664f4b92 (diff) |
make the deceptively complicated leading and trailing space into functions.
this reduces kernel size quite a bit. ok claudio
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/uipc_mbuf.c | 22 | ||||
-rw-r--r-- | sys/sys/mbuf.h | 20 |
2 files changed, 26 insertions, 16 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index c95648a262a..df1c2be80b1 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.86 2007/09/26 13:05:52 henning Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.87 2007/11/27 16:38:50 tedu Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -1037,3 +1037,23 @@ m_apply(struct mbuf *m, int off, int len, return (0); } + +int +m_leadingspace(struct mbuf *m) +{ + if (M_READONLY((m))) + return 0; + return ((m)->m_flags & M_EXT ? (m)->m_data - (m)->m_ext.ext_buf : + (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : + (m)->m_data - (m)->m_dat); +} + +int +m_trailingspace(struct mbuf *m) +{ + if (M_READONLY(m)) + return 0; + return ((m)->m_flags & M_EXT ? (m)->m_ext.ext_buf + + (m)->m_ext.ext_size - ((m)->m_data + (m)->m_len) : + &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len)); +} diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index dc531b8d371..53ff71c5fba 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.h,v 1.94 2007/09/26 13:05:52 henning Exp $ */ +/* $OpenBSD: mbuf.h,v 1.95 2007/11/27 16:38:50 tedu Exp $ */ /* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */ /* @@ -386,25 +386,15 @@ do { \ * Compute the amount of space available * before the current start of data in an mbuf. */ -#define _M_LEADINGSPACE(m) \ - ((m)->m_flags & M_EXT ? (m)->m_data - (m)->m_ext.ext_buf : \ - (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \ - (m)->m_data - (m)->m_dat) - -#define M_LEADINGSPACE(m) \ - (M_READONLY((m)) ? 0 : _M_LEADINGSPACE((m))) +int m_leadingspace(struct mbuf *); +#define M_LEADINGSPACE(m) m_leadingspace(m) /* * Compute the amount of space available * after the end of data in an mbuf. */ -#define _M_TRAILINGSPACE(m) \ - ((m)->m_flags & M_EXT ? (m)->m_ext.ext_buf + \ - (m)->m_ext.ext_size - ((m)->m_data + (m)->m_len) : \ - &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len)) - -#define M_TRAILINGSPACE(m) \ - (M_READONLY((m)) ? 0 : _M_TRAILINGSPACE((m))) +int m_trailingspace(struct mbuf *); +#define M_TRAILINGSPACE(m) m_trailingspace(m) /* * Arrange to prepend space of size plen to mbuf m. |