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
This commit is contained in:
Sam Leffler 2005-07-30 01:32:16 +00:00
parent e29c976a58
commit ab8ab90c5b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=148552
2 changed files with 20 additions and 0 deletions

View File

@ -1382,3 +1382,22 @@ m_uiotombuf(struct uio *uio, int how, int len, int align)
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);
}

View File

@ -563,6 +563,7 @@ extern int nmbclusters; /* Maximum number of clusters */
struct uio;
void m_adj(struct mbuf *, int);
void m_align(struct mbuf *, int);
int m_apply(struct mbuf *, int, int,
int (*)(void *, void *, u_int), void *);
int m_append(struct mbuf *, int, c_caddr_t);