Deleted Added
full compact
mbuf.h (138541) mbuf.h (141668)
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)mbuf.h 8.5 (Berkeley) 2/19/95
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)mbuf.h 8.5 (Berkeley) 2/19/95
30 * $FreeBSD: head/sys/sys/mbuf.h 138541 2004-12-08 05:42:02Z sam $
30 * $FreeBSD: head/sys/sys/mbuf.h 141668 2005-02-10 22:23:02Z bmilekic $
31 */
32
33#ifndef _SYS_MBUF_H_
34#define _SYS_MBUF_H_
35
36/* XXX: These includes suck. Sorry! */
37#include <sys/queue.h>
38#ifdef _KERNEL

--- 251 unchanged lines hidden (view full) ---

290 * mbuf external reference count management macros.
291 *
292 * MEXT_IS_REF(m): true if (m) is not the only mbuf referencing
293 * the external buffer ext_buf.
294 *
295 * MEXT_REM_REF(m): remove reference to m_ext object.
296 *
297 * MEXT_ADD_REF(m): add reference to m_ext object already
31 */
32
33#ifndef _SYS_MBUF_H_
34#define _SYS_MBUF_H_
35
36/* XXX: These includes suck. Sorry! */
37#include <sys/queue.h>
38#ifdef _KERNEL

--- 251 unchanged lines hidden (view full) ---

290 * mbuf external reference count management macros.
291 *
292 * MEXT_IS_REF(m): true if (m) is not the only mbuf referencing
293 * the external buffer ext_buf.
294 *
295 * MEXT_REM_REF(m): remove reference to m_ext object.
296 *
297 * MEXT_ADD_REF(m): add reference to m_ext object already
298 * referred to by (m).
298 * referred to by (m). XXX Note that it is VERY important that you
299 * always set the second mbuf's m_ext.ref_cnt to point to the first
300 * one's (i.e., n->m_ext.ref_cnt = m->m_ext.ref_cnt) AFTER you run
301 * MEXT_ADD_REF(m). This is because m might have a lazy initialized
302 * ref_cnt (NULL) before this is run and it will only be looked up
303 * from here. We should make MEXT_ADD_REF() always take two mbufs
304 * as arguments so that it can take care of this itself.
299 */
305 */
300#define MEXT_IS_REF(m) (*((m)->m_ext.ref_cnt) > 1)
306#define MEXT_IS_REF(m) (((m)->m_ext.ref_cnt != NULL) \
307 && (*((m)->m_ext.ref_cnt) > 1))
301
302#define MEXT_REM_REF(m) do { \
308
309#define MEXT_REM_REF(m) do { \
310 KASSERT((m)->m_ext.ref_cnt != NULL, ("m_ext refcnt lazy NULL")); \
303 KASSERT(*((m)->m_ext.ref_cnt) > 0, ("m_ext refcnt < 0")); \
304 atomic_subtract_int((m)->m_ext.ref_cnt, 1); \
305} while(0)
306
311 KASSERT(*((m)->m_ext.ref_cnt) > 0, ("m_ext refcnt < 0")); \
312 atomic_subtract_int((m)->m_ext.ref_cnt, 1); \
313} while(0)
314
307#define MEXT_ADD_REF(m) atomic_add_int((m)->m_ext.ref_cnt, 1)
315#define MEXT_ADD_REF(m) do { \
316 if ((m)->m_ext.ref_cnt == NULL) { \
317 KASSERT((m)->m_ext.ext_type == EXT_CLUSTER || \
318 (m)->m_ext.ext_type == EXT_PACKET, \
319 ("Unexpected mbuf type has lazy refcnt")); \
320 (m)->m_ext.ref_cnt = (u_int *)uma_find_refcnt( \
321 zone_clust, (m)->m_ext.ext_buf); \
322 *((m)->m_ext.ref_cnt) = 2; \
323 } else \
324 atomic_add_int((m)->m_ext.ref_cnt, 1); \
325} while (0)
308
309#ifdef WITNESS
310#define MBUF_CHECKSLEEP(how) do { \
311 if (how == M_WAITOK) \
312 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \
313 "Sleeping in \"%s\"", __func__); \
314} while(0)
315#else

--- 430 unchanged lines hidden ---
326
327#ifdef WITNESS
328#define MBUF_CHECKSLEEP(how) do { \
329 if (how == M_WAITOK) \
330 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \
331 "Sleeping in \"%s\"", __func__); \
332} while(0)
333#else

--- 430 unchanged lines hidden ---