summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_mbuf.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2005-07-30 01:32:16 +0000
committersam <sam@FreeBSD.org>2005-07-30 01:32:16 +0000
commit9e1f21a348a1ee4cd2f5caf7ed4863bae3c9cda6 (patch)
tree2f8c453affdad041103ee8c4deb9a82d903fc6b1 /sys/kern/uipc_mbuf.c
parent509594693ef28516f1629eb4c97a83491b019050 (diff)
downloadFreeBSD-src-9e1f21a348a1ee4cd2f5caf7ed4863bae3c9cda6.zip
FreeBSD-src-9e1f21a348a1ee4cd2f5caf7ed4863bae3c9cda6.tar.gz
add m_align, a function to align any type of mbuf (i.e. it
is a superset of M_ALIGN and MH_ALIGN) Reviewed by: several
Diffstat (limited to 'sys/kern/uipc_mbuf.c')
-rw-r--r--sys/kern/uipc_mbuf.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index ce00553..6a0e9ba 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1382,3 +1382,22 @@ nospace:
m_freem(m_final);
return (NULL);
}
+
+/*
+ * Set the m_data pointer of a newly-allocated mbuf
+ * to place an object of the specified size at the
+ * end of the mbuf, longword aligned.
+ */
+void
+m_align(struct mbuf *m, int len)
+{
+ int adjust;
+
+ if (m->m_flags & M_EXT)
+ adjust = m->m_ext.ext_size - len;
+ else if (m->m_flags & M_PKTHDR)
+ adjust = MHLEN - len;
+ else
+ adjust = MLEN - len;
+ m->m_data += adjust &~ (sizeof(long)-1);
+}
OpenPOWER on IntegriCloud