Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/mbuf.h
Show First 20 Lines • Show All 1,230 Lines • ▼ Show 20 Lines | |||||
* NB: In previous versions, M_LEADINGSPACE() would only check M_WRITABLE() | * NB: In previous versions, M_LEADINGSPACE() would only check M_WRITABLE() | ||||
* for mbufs with external storage. We now allow mbuf-embedded data to be | * for mbufs with external storage. We now allow mbuf-embedded data to be | ||||
* read-only as well. | * read-only as well. | ||||
*/ | */ | ||||
#define M_LEADINGSPACE(m) \ | #define M_LEADINGSPACE(m) \ | ||||
(M_WRITABLE(m) ? ((m)->m_data - M_START(m)) : 0) | (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. | * 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 | * The M_WRITABLE() is a temporary, conservative safety measure: the burden | ||||
* of checking writability of the mbuf data area rests solely with the caller. | * of checking writability of the mbuf data area rests solely with the caller. | ||||
* | * | ||||
* NB: In previous versions, M_TRAILINGSPACE() would only check M_WRITABLE() | * NB: In previous versions, M_TRAILINGSPACE() would only check M_WRITABLE() | ||||
* for mbufs with external storage. We now allow mbuf-embedded data to be | * for mbufs with external storage. We now allow mbuf-embedded data to be | ||||
* read-only as well. | * read-only as well. | ||||
*/ | */ | ||||
#define M_TRAILINGSPACE(m) \ | #define M_TRAILINGSPACE(m) (M_WRITABLE(m) ? M_TRAILINGROOM(m) : 0) | ||||
(M_WRITABLE(m) ? \ | |||||
((M_START(m) + M_SIZE(m)) - ((m)->m_data + (m)->m_len)) : 0) | |||||
/* | /* | ||||
* Arrange to prepend space of size plen to mbuf m. If a new mbuf must be | * Arrange to prepend space of size plen to mbuf m. If a new mbuf must be | ||||
* allocated, how specifies whether to wait. If the allocation fails, the | * allocated, how specifies whether to wait. If the allocation fails, the | ||||
* original mbuf chain is freed and m is set to NULL. | * original mbuf chain is freed and m is set to NULL. | ||||
*/ | */ | ||||
#define M_PREPEND(m, plen, how) do { \ | #define M_PREPEND(m, plen, how) do { \ | ||||
struct mbuf **_mmp = &(m); \ | struct mbuf **_mmp = &(m); \ | ||||
▲ Show 20 Lines • Show All 450 Lines • Show Last 20 Lines |