diff options
author | Randall Stewart <rrs@FreeBSD.org> | 2023-04-01 05:46:38 +0000 |
---|---|---|
committer | Randall Stewart <rrs@FreeBSD.org> | 2023-04-01 05:46:38 +0000 |
commit | 73ee5756dee6b2110eb6fb2b2ef3cde39a1fcb4f (patch) | |
tree | 32251ae7fe68feb89a31e29ff45abcaba7750f1a /sys/sys/mbuf.h | |
parent | 63b113af5706420b149b5b8b2189d1e4d0b9782d (diff) | |
download | src-73ee5756dee6b2110eb6fb2b2ef3cde39a1fcb4f.tar.gz src-73ee5756dee6b2110eb6fb2b2ef3cde39a1fcb4f.zip |
Diffstat (limited to 'sys/sys/mbuf.h')
-rw-r--r-- | sys/sys/mbuf.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index a6a28291123d..4798c9c2a9ab 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1236,6 +1236,16 @@ m_align(struct mbuf *m, int len) (M_WRITABLE(m) ? ((m)->m_data - M_START(m)) : 0) /* + * So M_TRAILINGROOM() is for when you want to know how much space + * would be there if it was writable. This can be used to + * detect changes in mbufs by knowing the value at one point + * and then being able to compare it later to the current M_TRAILINGROOM(). + * The TRAILINGSPACE() macro is not suitable for this since an mbuf + * at one point might not be writable and then later it becomes writable + * even though the space at the back of it has not changed. + */ +#define M_TRAILINGROOM(m) ((M_START(m) + M_SIZE(m)) - ((m)->m_data + (m)->m_len)) +/* * Compute the amount of space available after the end of data in an mbuf. * * The M_WRITABLE() is a temporary, conservative safety measure: the burden @@ -1245,9 +1255,7 @@ m_align(struct mbuf *m, int len) * for mbufs with external storage. We now allow mbuf-embedded data to be * read-only as well. */ -#define M_TRAILINGSPACE(m) \ - (M_WRITABLE(m) ? \ - ((M_START(m) + M_SIZE(m)) - ((m)->m_data + (m)->m_len)) : 0) +#define M_TRAILINGSPACE(m) (M_WRITABLE(m) ? M_TRAILINGROOM(m) : 0) /* * Arrange to prepend space of size plen to mbuf m. If a new mbuf must be |