Changeset 8bbaf3b in rtems


Ignore:
Timestamp:
May 20, 1999, 1:32:54 PM (22 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
0aeda88
Parents:
5a064dca
Message:

Removed all post 4.0 changes.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/libnetworking/sys/mbuf.h

    r5a064dca r8bbaf3b  
    171171 * drivers.
    172172 */
    173 #define MBUFLOCK(_code) \
     173#define MBUFLOCK(code) \
    174174        { int ms = splimp(); \
    175           { _code } \
     175          { code } \
    176176          splx(ms); \
    177177        }
     
    187187 * and internal data.
    188188 */
    189 #define MGET(_m, _how, _type) { \
     189#define MGET(m, how, type) { \
    190190          int _ms = splimp(); \
    191191          if (mmbfree == 0) \
    192                 (void)m_mballoc(1, (_how)); \
    193           if (((_m) = mmbfree) != 0) { \
    194                 mmbfree = (_m)->m_next; \
    195 /* printf( "MGET: %p\n", (_m) ); */ \
     192                (void)m_mballoc(1, (how)); \
     193          if (((m) = mmbfree) != 0) { \
     194                mmbfree = (m)->m_next; \
    196195                mbstat.m_mtypes[MT_FREE]--; \
    197                 (_m)->m_type = (_type); \
    198                 mbstat.m_mtypes[_type]++; \
    199                 (_m)->m_next = (struct mbuf *)NULL; \
    200                 (_m)->m_nextpkt = (struct mbuf *)NULL; \
    201                 (_m)->m_data = (_m)->m_dat; \
    202                 (_m)->m_flags = 0; \
     196                (m)->m_type = (type); \
     197                mbstat.m_mtypes[type]++; \
     198                (m)->m_next = (struct mbuf *)NULL; \
     199                (m)->m_nextpkt = (struct mbuf *)NULL; \
     200                (m)->m_data = (m)->m_dat; \
     201                (m)->m_flags = 0; \
    203202                splx(_ms); \
    204203        } else { \
    205204                splx(_ms); \
    206                 (_m) = m_retry((_how), (_type)); \
     205                (m) = m_retry((how), (type)); \
    207206        } \
    208207}
    209208
    210 #define MGETHDR(_m, _how, _type) { \
     209#define MGETHDR(m, how, type) { \
    211210          int _ms = splimp(); \
    212211          if (mmbfree == 0) \
    213                 (void)m_mballoc(1, (_how)); \
    214           if (((_m) = mmbfree) != 0) { \
    215                 mmbfree = (_m)->m_next; \
    216 /* printf( "MGETHDR: %p\n", (_m) ); */ \
     212                (void)m_mballoc(1, (how)); \
     213          if (((m) = mmbfree) != 0) { \
     214                mmbfree = (m)->m_next; \
    217215                mbstat.m_mtypes[MT_FREE]--; \
    218                 (_m)->m_type = (_type); \
    219                 mbstat.m_mtypes[_type]++; \
    220                 (_m)->m_next = (struct mbuf *)NULL; \
    221                 (_m)->m_nextpkt = (struct mbuf *)NULL; \
    222                 (_m)->m_data = (_m)->m_pktdat; \
    223                 (_m)->m_flags = M_PKTHDR; \
     216                (m)->m_type = (type); \
     217                mbstat.m_mtypes[type]++; \
     218                (m)->m_next = (struct mbuf *)NULL; \
     219                (m)->m_nextpkt = (struct mbuf *)NULL; \
     220                (m)->m_data = (m)->m_pktdat; \
     221                (m)->m_flags = M_PKTHDR; \
    224222                splx(_ms); \
    225223        } else { \
    226224                splx(_ms); \
    227                 (_m) = m_retryhdr((_how), (_type)); \
     225                (m) = m_retryhdr((how), (type)); \
    228226        } \
    229227}
     
    237235 * freeing the cluster if the reference count has reached 0.
    238236 */
    239 #define MCLALLOC(_p, _how) \
     237#define MCLALLOC(p, how) \
    240238        MBUFLOCK( \
    241239          if (mclfree == 0) \
    242                 (void)m_clalloc(1, (_how)); \
    243           if (((_p) = (caddr_t)mclfree) != 0) { \
    244                 ++mclrefcnt[mtocl(_p)]; \
     240                (void)m_clalloc(1, (how)); \
     241          if (((p) = (caddr_t)mclfree) != 0) { \
     242                ++mclrefcnt[mtocl(p)]; \
    245243                mbstat.m_clfree--; \
    246                 mclfree = ((union mcluster *)(_p))->mcl_next; \
     244                mclfree = ((union mcluster *)(p))->mcl_next; \
    247245          } \
    248246        )
    249247
    250 #define MCLGET(_m, _how) \
    251         { MCLALLOC((_m)->m_ext.ext_buf, (_how)); \
    252           if ((_m)->m_ext.ext_buf != NULL) { \
    253                 (_m)->m_data = (_m)->m_ext.ext_buf; \
    254                 (_m)->m_flags |= M_EXT; \
    255                 (_m)->m_ext.ext_free = NULL;  \
    256                 (_m)->m_ext.ext_ref = NULL;  \
    257                 (_m)->m_ext.ext_size = MCLBYTES;  \
     248#define MCLGET(m, how) \
     249        { MCLALLOC((m)->m_ext.ext_buf, (how)); \
     250          if ((m)->m_ext.ext_buf != NULL) { \
     251                (m)->m_data = (m)->m_ext.ext_buf; \
     252                (m)->m_flags |= M_EXT; \
     253                (m)->m_ext.ext_free = NULL;  \
     254                (m)->m_ext.ext_ref = NULL;  \
     255                (m)->m_ext.ext_size = MCLBYTES;  \
    258256          } \
    259257        }
    260258
    261 #define MCLFREE(_p) \
     259#define MCLFREE(p) \
    262260        MBUFLOCK ( \
    263           if (--mclrefcnt[mtocl(_p)] == 0) { \
    264                 ((union mcluster *)(_p))->mcl_next = mclfree; \
    265                 mclfree = (union mcluster *)(_p); \
     261          if (--mclrefcnt[mtocl(p)] == 0) { \
     262                ((union mcluster *)(p))->mcl_next = mclfree; \
     263                mclfree = (union mcluster *)(p); \
    266264                mbstat.m_clfree++; \
    267265          } \
     
    273271 * Place the successor, if any, in n.
    274272 */
    275 #define MFREE(_m, _n) \
     273#define MFREE(m, n) \
    276274        MBUFLOCK(  \
    277 /* printf( "MFREE: %p\n", (_m) ); */ \
    278           mbstat.m_mtypes[(_m)->m_type]--; \
    279           if ((_m)->m_flags & M_EXT) { \
    280                 if ((_m)->m_ext.ext_free) \
    281                         (*((_m)->m_ext.ext_free))((_m)->m_ext.ext_buf, \
    282                             (_m)->m_ext.ext_size); \
     275          mbstat.m_mtypes[(m)->m_type]--; \
     276          if ((m)->m_flags & M_EXT) { \
     277                if ((m)->m_ext.ext_free) \
     278                        (*((m)->m_ext.ext_free))((m)->m_ext.ext_buf, \
     279                            (m)->m_ext.ext_size); \
    283280                else { \
    284                         char *p = (_m)->m_ext.ext_buf; \
     281                        char *p = (m)->m_ext.ext_buf; \
    285282                        if (--mclrefcnt[mtocl(p)] == 0) { \
    286283                                ((union mcluster *)(p))->mcl_next = mclfree; \
     
    290287                } \
    291288          } \
    292           (_n) = (_m)->m_next; \
    293           (_m)->m_type = MT_FREE; \
     289          (n) = (m)->m_next; \
     290          (m)->m_type = MT_FREE; \
    294291          mbstat.m_mtypes[MT_FREE]++; \
    295           (_m)->m_next = mmbfree; \
    296           mmbfree = (_m); \
     292          (m)->m_next = mmbfree; \
     293          mmbfree = (m); \
    297294        )
    298295
     
    301298 * from must have M_PKTHDR set, and to must be empty.
    302299 */
    303 #define M_COPY_PKTHDR(_to, _from) { \
    304         (_to)->m_pkthdr = (_from)->m_pkthdr; \
    305         (_to)->m_flags = (_from)->m_flags & M_COPYFLAGS; \
    306         (_to)->m_data = (_to)->m_pktdat; \
     300#define M_COPY_PKTHDR(to, from) { \
     301        (to)->m_pkthdr = (from)->m_pkthdr; \
     302        (to)->m_flags = (from)->m_flags & M_COPYFLAGS; \
     303        (to)->m_data = (to)->m_pktdat; \
    307304}
    308305
     
    311308 * an object of the specified size at the end of the mbuf, longword aligned.
    312309 */
    313 #define M_ALIGN(_m, _len) \
    314         { (_m)->m_data += (MLEN - (_len)) &~ (sizeof(long) - 1); }
     310#define M_ALIGN(m, len) \
     311        { (m)->m_data += (MLEN - (len)) &~ (sizeof(long) - 1); }
    315312/*
    316313 * As above, for mbufs allocated with m_gethdr/MGETHDR
    317314 * or initialized by M_COPY_PKTHDR.
    318315 */
    319 #define MH_ALIGN(_m, _len) \
    320         { (_m)->m_data += (MHLEN - (_len)) &~ (sizeof(long) - 1); }
     316#define MH_ALIGN(m, len) \
     317        { (m)->m_data += (MHLEN - (len)) &~ (sizeof(long) - 1); }
    321318
    322319/*
     
    324321 * before the current start of data in an mbuf.
    325322 */
    326 #define M_LEADINGSPACE(_m) \
    327         ((_m)->m_flags & M_EXT ? /* (_m)->m_data - (_m)->m_ext.ext_buf */ 0 : \
    328             (_m)->m_flags & M_PKTHDR ? (_m)->m_data - (_m)->m_pktdat : \
    329             (_m)->m_data - (_m)->m_dat)
     323#define M_LEADINGSPACE(m) \
     324        ((m)->m_flags & M_EXT ? /* (m)->m_data - (m)->m_ext.ext_buf */ 0 : \
     325            (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \
     326            (m)->m_data - (m)->m_dat)
    330327
    331328/*
     
    333330 * after the end of data in an mbuf.
    334331 */
    335 #define M_TRAILINGSPACE(_m) \
    336         ((_m)->m_flags & M_EXT ? (_m)->m_ext.ext_buf + (_m)->m_ext.ext_size - \
    337             ((_m)->m_data + (_m)->m_len) : \
    338             &(_m)->m_dat[MLEN] - ((_m)->m_data + (_m)->m_len))
     332#define M_TRAILINGSPACE(m) \
     333        ((m)->m_flags & M_EXT ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size - \
     334            ((m)->m_data + (m)->m_len) : \
     335            &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len))
    339336
    340337/*
     
    344341 * is freed and m is set to NULL.
    345342 */
    346 #define M_PREPEND(_m, _plen, _how) { \
    347         if (M_LEADINGSPACE(_m) >= (_plen)) { \
    348                 (_m)->m_data -= (_plen); \
    349                 (_m)->m_len += (_plen); \
     343#define M_PREPEND(m, plen, how) { \
     344        if (M_LEADINGSPACE(m) >= (plen)) { \
     345                (m)->m_data -= (plen); \
     346                (m)->m_len += (plen); \
    350347        } else \
    351                 (_m) = m_prepend((_m), (_plen), (_how)); \
    352         if ((_m) && (_m)->m_flags & M_PKTHDR) \
    353                 (_m)->m_pkthdr.len += (_plen); \
     348                (m) = m_prepend((m), (plen), (how)); \
     349        if ((m) && (m)->m_flags & M_PKTHDR) \
     350                (m)->m_pkthdr.len += (plen); \
    354351}
    355352
    356353/* change mbuf to new type */
    357 #define MCHTYPE(_m, _t) { \
    358         MBUFLOCK(mbstat.m_mtypes[(_m)->m_type]--; mbstat.m_mtypes[t]++;) \
    359         (_m)->m_type = t;\
     354#define MCHTYPE(m, t) { \
     355        MBUFLOCK(mbstat.m_mtypes[(m)->m_type]--; mbstat.m_mtypes[t]++;) \
     356        (m)->m_type = t;\
    360357}
    361358
  • c/src/lib/libnetworking/sys/mbuf.h

    r5a064dca r8bbaf3b  
    171171 * drivers.
    172172 */
    173 #define MBUFLOCK(_code) \
     173#define MBUFLOCK(code) \
    174174        { int ms = splimp(); \
    175           { _code } \
     175          { code } \
    176176          splx(ms); \
    177177        }
     
    187187 * and internal data.
    188188 */
    189 #define MGET(_m, _how, _type) { \
     189#define MGET(m, how, type) { \
    190190          int _ms = splimp(); \
    191191          if (mmbfree == 0) \
    192                 (void)m_mballoc(1, (_how)); \
    193           if (((_m) = mmbfree) != 0) { \
    194                 mmbfree = (_m)->m_next; \
    195 /* printf( "MGET: %p\n", (_m) ); */ \
     192                (void)m_mballoc(1, (how)); \
     193          if (((m) = mmbfree) != 0) { \
     194                mmbfree = (m)->m_next; \
    196195                mbstat.m_mtypes[MT_FREE]--; \
    197                 (_m)->m_type = (_type); \
    198                 mbstat.m_mtypes[_type]++; \
    199                 (_m)->m_next = (struct mbuf *)NULL; \
    200                 (_m)->m_nextpkt = (struct mbuf *)NULL; \
    201                 (_m)->m_data = (_m)->m_dat; \
    202                 (_m)->m_flags = 0; \
     196                (m)->m_type = (type); \
     197                mbstat.m_mtypes[type]++; \
     198                (m)->m_next = (struct mbuf *)NULL; \
     199                (m)->m_nextpkt = (struct mbuf *)NULL; \
     200                (m)->m_data = (m)->m_dat; \
     201                (m)->m_flags = 0; \
    203202                splx(_ms); \
    204203        } else { \
    205204                splx(_ms); \
    206                 (_m) = m_retry((_how), (_type)); \
     205                (m) = m_retry((how), (type)); \
    207206        } \
    208207}
    209208
    210 #define MGETHDR(_m, _how, _type) { \
     209#define MGETHDR(m, how, type) { \
    211210          int _ms = splimp(); \
    212211          if (mmbfree == 0) \
    213                 (void)m_mballoc(1, (_how)); \
    214           if (((_m) = mmbfree) != 0) { \
    215                 mmbfree = (_m)->m_next; \
    216 /* printf( "MGETHDR: %p\n", (_m) ); */ \
     212                (void)m_mballoc(1, (how)); \
     213          if (((m) = mmbfree) != 0) { \
     214                mmbfree = (m)->m_next; \
    217215                mbstat.m_mtypes[MT_FREE]--; \
    218                 (_m)->m_type = (_type); \
    219                 mbstat.m_mtypes[_type]++; \
    220                 (_m)->m_next = (struct mbuf *)NULL; \
    221                 (_m)->m_nextpkt = (struct mbuf *)NULL; \
    222                 (_m)->m_data = (_m)->m_pktdat; \
    223                 (_m)->m_flags = M_PKTHDR; \
     216                (m)->m_type = (type); \
     217                mbstat.m_mtypes[type]++; \
     218                (m)->m_next = (struct mbuf *)NULL; \
     219                (m)->m_nextpkt = (struct mbuf *)NULL; \
     220                (m)->m_data = (m)->m_pktdat; \
     221                (m)->m_flags = M_PKTHDR; \
    224222                splx(_ms); \
    225223        } else { \
    226224                splx(_ms); \
    227                 (_m) = m_retryhdr((_how), (_type)); \
     225                (m) = m_retryhdr((how), (type)); \
    228226        } \
    229227}
     
    237235 * freeing the cluster if the reference count has reached 0.
    238236 */
    239 #define MCLALLOC(_p, _how) \
     237#define MCLALLOC(p, how) \
    240238        MBUFLOCK( \
    241239          if (mclfree == 0) \
    242                 (void)m_clalloc(1, (_how)); \
    243           if (((_p) = (caddr_t)mclfree) != 0) { \
    244                 ++mclrefcnt[mtocl(_p)]; \
     240                (void)m_clalloc(1, (how)); \
     241          if (((p) = (caddr_t)mclfree) != 0) { \
     242                ++mclrefcnt[mtocl(p)]; \
    245243                mbstat.m_clfree--; \
    246                 mclfree = ((union mcluster *)(_p))->mcl_next; \
     244                mclfree = ((union mcluster *)(p))->mcl_next; \
    247245          } \
    248246        )
    249247
    250 #define MCLGET(_m, _how) \
    251         { MCLALLOC((_m)->m_ext.ext_buf, (_how)); \
    252           if ((_m)->m_ext.ext_buf != NULL) { \
    253                 (_m)->m_data = (_m)->m_ext.ext_buf; \
    254                 (_m)->m_flags |= M_EXT; \
    255                 (_m)->m_ext.ext_free = NULL;  \
    256                 (_m)->m_ext.ext_ref = NULL;  \
    257                 (_m)->m_ext.ext_size = MCLBYTES;  \
     248#define MCLGET(m, how) \
     249        { MCLALLOC((m)->m_ext.ext_buf, (how)); \
     250          if ((m)->m_ext.ext_buf != NULL) { \
     251                (m)->m_data = (m)->m_ext.ext_buf; \
     252                (m)->m_flags |= M_EXT; \
     253                (m)->m_ext.ext_free = NULL;  \
     254                (m)->m_ext.ext_ref = NULL;  \
     255                (m)->m_ext.ext_size = MCLBYTES;  \
    258256          } \
    259257        }
    260258
    261 #define MCLFREE(_p) \
     259#define MCLFREE(p) \
    262260        MBUFLOCK ( \
    263           if (--mclrefcnt[mtocl(_p)] == 0) { \
    264                 ((union mcluster *)(_p))->mcl_next = mclfree; \
    265                 mclfree = (union mcluster *)(_p); \
     261          if (--mclrefcnt[mtocl(p)] == 0) { \
     262                ((union mcluster *)(p))->mcl_next = mclfree; \
     263                mclfree = (union mcluster *)(p); \
    266264                mbstat.m_clfree++; \
    267265          } \
     
    273271 * Place the successor, if any, in n.
    274272 */
    275 #define MFREE(_m, _n) \
     273#define MFREE(m, n) \
    276274        MBUFLOCK(  \
    277 /* printf( "MFREE: %p\n", (_m) ); */ \
    278           mbstat.m_mtypes[(_m)->m_type]--; \
    279           if ((_m)->m_flags & M_EXT) { \
    280                 if ((_m)->m_ext.ext_free) \
    281                         (*((_m)->m_ext.ext_free))((_m)->m_ext.ext_buf, \
    282                             (_m)->m_ext.ext_size); \
     275          mbstat.m_mtypes[(m)->m_type]--; \
     276          if ((m)->m_flags & M_EXT) { \
     277                if ((m)->m_ext.ext_free) \
     278                        (*((m)->m_ext.ext_free))((m)->m_ext.ext_buf, \
     279                            (m)->m_ext.ext_size); \
    283280                else { \
    284                         char *p = (_m)->m_ext.ext_buf; \
     281                        char *p = (m)->m_ext.ext_buf; \
    285282                        if (--mclrefcnt[mtocl(p)] == 0) { \
    286283                                ((union mcluster *)(p))->mcl_next = mclfree; \
     
    290287                } \
    291288          } \
    292           (_n) = (_m)->m_next; \
    293           (_m)->m_type = MT_FREE; \
     289          (n) = (m)->m_next; \
     290          (m)->m_type = MT_FREE; \
    294291          mbstat.m_mtypes[MT_FREE]++; \
    295           (_m)->m_next = mmbfree; \
    296           mmbfree = (_m); \
     292          (m)->m_next = mmbfree; \
     293          mmbfree = (m); \
    297294        )
    298295
     
    301298 * from must have M_PKTHDR set, and to must be empty.
    302299 */
    303 #define M_COPY_PKTHDR(_to, _from) { \
    304         (_to)->m_pkthdr = (_from)->m_pkthdr; \
    305         (_to)->m_flags = (_from)->m_flags & M_COPYFLAGS; \
    306         (_to)->m_data = (_to)->m_pktdat; \
     300#define M_COPY_PKTHDR(to, from) { \
     301        (to)->m_pkthdr = (from)->m_pkthdr; \
     302        (to)->m_flags = (from)->m_flags & M_COPYFLAGS; \
     303        (to)->m_data = (to)->m_pktdat; \
    307304}
    308305
     
    311308 * an object of the specified size at the end of the mbuf, longword aligned.
    312309 */
    313 #define M_ALIGN(_m, _len) \
    314         { (_m)->m_data += (MLEN - (_len)) &~ (sizeof(long) - 1); }
     310#define M_ALIGN(m, len) \
     311        { (m)->m_data += (MLEN - (len)) &~ (sizeof(long) - 1); }
    315312/*
    316313 * As above, for mbufs allocated with m_gethdr/MGETHDR
    317314 * or initialized by M_COPY_PKTHDR.
    318315 */
    319 #define MH_ALIGN(_m, _len) \
    320         { (_m)->m_data += (MHLEN - (_len)) &~ (sizeof(long) - 1); }
     316#define MH_ALIGN(m, len) \
     317        { (m)->m_data += (MHLEN - (len)) &~ (sizeof(long) - 1); }
    321318
    322319/*
     
    324321 * before the current start of data in an mbuf.
    325322 */
    326 #define M_LEADINGSPACE(_m) \
    327         ((_m)->m_flags & M_EXT ? /* (_m)->m_data - (_m)->m_ext.ext_buf */ 0 : \
    328             (_m)->m_flags & M_PKTHDR ? (_m)->m_data - (_m)->m_pktdat : \
    329             (_m)->m_data - (_m)->m_dat)
     323#define M_LEADINGSPACE(m) \
     324        ((m)->m_flags & M_EXT ? /* (m)->m_data - (m)->m_ext.ext_buf */ 0 : \
     325            (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \
     326            (m)->m_data - (m)->m_dat)
    330327
    331328/*
     
    333330 * after the end of data in an mbuf.
    334331 */
    335 #define M_TRAILINGSPACE(_m) \
    336         ((_m)->m_flags & M_EXT ? (_m)->m_ext.ext_buf + (_m)->m_ext.ext_size - \
    337             ((_m)->m_data + (_m)->m_len) : \
    338             &(_m)->m_dat[MLEN] - ((_m)->m_data + (_m)->m_len))
     332#define M_TRAILINGSPACE(m) \
     333        ((m)->m_flags & M_EXT ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size - \
     334            ((m)->m_data + (m)->m_len) : \
     335            &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len))
    339336
    340337/*
     
    344341 * is freed and m is set to NULL.
    345342 */
    346 #define M_PREPEND(_m, _plen, _how) { \
    347         if (M_LEADINGSPACE(_m) >= (_plen)) { \
    348                 (_m)->m_data -= (_plen); \
    349                 (_m)->m_len += (_plen); \
     343#define M_PREPEND(m, plen, how) { \
     344        if (M_LEADINGSPACE(m) >= (plen)) { \
     345                (m)->m_data -= (plen); \
     346                (m)->m_len += (plen); \
    350347        } else \
    351                 (_m) = m_prepend((_m), (_plen), (_how)); \
    352         if ((_m) && (_m)->m_flags & M_PKTHDR) \
    353                 (_m)->m_pkthdr.len += (_plen); \
     348                (m) = m_prepend((m), (plen), (how)); \
     349        if ((m) && (m)->m_flags & M_PKTHDR) \
     350                (m)->m_pkthdr.len += (plen); \
    354351}
    355352
    356353/* change mbuf to new type */
    357 #define MCHTYPE(_m, _t) { \
    358         MBUFLOCK(mbstat.m_mtypes[(_m)->m_type]--; mbstat.m_mtypes[t]++;) \
    359         (_m)->m_type = t;\
     354#define MCHTYPE(m, t) { \
     355        MBUFLOCK(mbstat.m_mtypes[(m)->m_type]--; mbstat.m_mtypes[t]++;) \
     356        (m)->m_type = t;\
    360357}
    361358
  • c/src/libnetworking/sys/mbuf.h

    r5a064dca r8bbaf3b  
    171171 * drivers.
    172172 */
    173 #define MBUFLOCK(_code) \
     173#define MBUFLOCK(code) \
    174174        { int ms = splimp(); \
    175           { _code } \
     175          { code } \
    176176          splx(ms); \
    177177        }
     
    187187 * and internal data.
    188188 */
    189 #define MGET(_m, _how, _type) { \
     189#define MGET(m, how, type) { \
    190190          int _ms = splimp(); \
    191191          if (mmbfree == 0) \
    192                 (void)m_mballoc(1, (_how)); \
    193           if (((_m) = mmbfree) != 0) { \
    194                 mmbfree = (_m)->m_next; \
    195 /* printf( "MGET: %p\n", (_m) ); */ \
     192                (void)m_mballoc(1, (how)); \
     193          if (((m) = mmbfree) != 0) { \
     194                mmbfree = (m)->m_next; \
    196195                mbstat.m_mtypes[MT_FREE]--; \
    197                 (_m)->m_type = (_type); \
    198                 mbstat.m_mtypes[_type]++; \
    199                 (_m)->m_next = (struct mbuf *)NULL; \
    200                 (_m)->m_nextpkt = (struct mbuf *)NULL; \
    201                 (_m)->m_data = (_m)->m_dat; \
    202                 (_m)->m_flags = 0; \
     196                (m)->m_type = (type); \
     197                mbstat.m_mtypes[type]++; \
     198                (m)->m_next = (struct mbuf *)NULL; \
     199                (m)->m_nextpkt = (struct mbuf *)NULL; \
     200                (m)->m_data = (m)->m_dat; \
     201                (m)->m_flags = 0; \
    203202                splx(_ms); \
    204203        } else { \
    205204                splx(_ms); \
    206                 (_m) = m_retry((_how), (_type)); \
     205                (m) = m_retry((how), (type)); \
    207206        } \
    208207}
    209208
    210 #define MGETHDR(_m, _how, _type) { \
     209#define MGETHDR(m, how, type) { \
    211210          int _ms = splimp(); \
    212211          if (mmbfree == 0) \
    213                 (void)m_mballoc(1, (_how)); \
    214           if (((_m) = mmbfree) != 0) { \
    215                 mmbfree = (_m)->m_next; \
    216 /* printf( "MGETHDR: %p\n", (_m) ); */ \
     212                (void)m_mballoc(1, (how)); \
     213          if (((m) = mmbfree) != 0) { \
     214                mmbfree = (m)->m_next; \
    217215                mbstat.m_mtypes[MT_FREE]--; \
    218                 (_m)->m_type = (_type); \
    219                 mbstat.m_mtypes[_type]++; \
    220                 (_m)->m_next = (struct mbuf *)NULL; \
    221                 (_m)->m_nextpkt = (struct mbuf *)NULL; \
    222                 (_m)->m_data = (_m)->m_pktdat; \
    223                 (_m)->m_flags = M_PKTHDR; \
     216                (m)->m_type = (type); \
     217                mbstat.m_mtypes[type]++; \
     218                (m)->m_next = (struct mbuf *)NULL; \
     219                (m)->m_nextpkt = (struct mbuf *)NULL; \
     220                (m)->m_data = (m)->m_pktdat; \
     221                (m)->m_flags = M_PKTHDR; \
    224222                splx(_ms); \
    225223        } else { \
    226224                splx(_ms); \
    227                 (_m) = m_retryhdr((_how), (_type)); \
     225                (m) = m_retryhdr((how), (type)); \
    228226        } \
    229227}
     
    237235 * freeing the cluster if the reference count has reached 0.
    238236 */
    239 #define MCLALLOC(_p, _how) \
     237#define MCLALLOC(p, how) \
    240238        MBUFLOCK( \
    241239          if (mclfree == 0) \
    242                 (void)m_clalloc(1, (_how)); \
    243           if (((_p) = (caddr_t)mclfree) != 0) { \
    244                 ++mclrefcnt[mtocl(_p)]; \
     240                (void)m_clalloc(1, (how)); \
     241          if (((p) = (caddr_t)mclfree) != 0) { \
     242                ++mclrefcnt[mtocl(p)]; \
    245243                mbstat.m_clfree--; \
    246                 mclfree = ((union mcluster *)(_p))->mcl_next; \
     244                mclfree = ((union mcluster *)(p))->mcl_next; \
    247245          } \
    248246        )
    249247
    250 #define MCLGET(_m, _how) \
    251         { MCLALLOC((_m)->m_ext.ext_buf, (_how)); \
    252           if ((_m)->m_ext.ext_buf != NULL) { \
    253                 (_m)->m_data = (_m)->m_ext.ext_buf; \
    254                 (_m)->m_flags |= M_EXT; \
    255                 (_m)->m_ext.ext_free = NULL;  \
    256                 (_m)->m_ext.ext_ref = NULL;  \
    257                 (_m)->m_ext.ext_size = MCLBYTES;  \
     248#define MCLGET(m, how) \
     249        { MCLALLOC((m)->m_ext.ext_buf, (how)); \
     250          if ((m)->m_ext.ext_buf != NULL) { \
     251                (m)->m_data = (m)->m_ext.ext_buf; \
     252                (m)->m_flags |= M_EXT; \
     253                (m)->m_ext.ext_free = NULL;  \
     254                (m)->m_ext.ext_ref = NULL;  \
     255                (m)->m_ext.ext_size = MCLBYTES;  \
    258256          } \
    259257        }
    260258
    261 #define MCLFREE(_p) \
     259#define MCLFREE(p) \
    262260        MBUFLOCK ( \
    263           if (--mclrefcnt[mtocl(_p)] == 0) { \
    264                 ((union mcluster *)(_p))->mcl_next = mclfree; \
    265                 mclfree = (union mcluster *)(_p); \
     261          if (--mclrefcnt[mtocl(p)] == 0) { \
     262                ((union mcluster *)(p))->mcl_next = mclfree; \
     263                mclfree = (union mcluster *)(p); \
    266264                mbstat.m_clfree++; \
    267265          } \
     
    273271 * Place the successor, if any, in n.
    274272 */
    275 #define MFREE(_m, _n) \
     273#define MFREE(m, n) \
    276274        MBUFLOCK(  \
    277 /* printf( "MFREE: %p\n", (_m) ); */ \
    278           mbstat.m_mtypes[(_m)->m_type]--; \
    279           if ((_m)->m_flags & M_EXT) { \
    280                 if ((_m)->m_ext.ext_free) \
    281                         (*((_m)->m_ext.ext_free))((_m)->m_ext.ext_buf, \
    282                             (_m)->m_ext.ext_size); \
     275          mbstat.m_mtypes[(m)->m_type]--; \
     276          if ((m)->m_flags & M_EXT) { \
     277                if ((m)->m_ext.ext_free) \
     278                        (*((m)->m_ext.ext_free))((m)->m_ext.ext_buf, \
     279                            (m)->m_ext.ext_size); \
    283280                else { \
    284                         char *p = (_m)->m_ext.ext_buf; \
     281                        char *p = (m)->m_ext.ext_buf; \
    285282                        if (--mclrefcnt[mtocl(p)] == 0) { \
    286283                                ((union mcluster *)(p))->mcl_next = mclfree; \
     
    290287                } \
    291288          } \
    292           (_n) = (_m)->m_next; \
    293           (_m)->m_type = MT_FREE; \
     289          (n) = (m)->m_next; \
     290          (m)->m_type = MT_FREE; \
    294291          mbstat.m_mtypes[MT_FREE]++; \
    295           (_m)->m_next = mmbfree; \
    296           mmbfree = (_m); \
     292          (m)->m_next = mmbfree; \
     293          mmbfree = (m); \
    297294        )
    298295
     
    301298 * from must have M_PKTHDR set, and to must be empty.
    302299 */
    303 #define M_COPY_PKTHDR(_to, _from) { \
    304         (_to)->m_pkthdr = (_from)->m_pkthdr; \
    305         (_to)->m_flags = (_from)->m_flags & M_COPYFLAGS; \
    306         (_to)->m_data = (_to)->m_pktdat; \
     300#define M_COPY_PKTHDR(to, from) { \
     301        (to)->m_pkthdr = (from)->m_pkthdr; \
     302        (to)->m_flags = (from)->m_flags & M_COPYFLAGS; \
     303        (to)->m_data = (to)->m_pktdat; \
    307304}
    308305
     
    311308 * an object of the specified size at the end of the mbuf, longword aligned.
    312309 */
    313 #define M_ALIGN(_m, _len) \
    314         { (_m)->m_data += (MLEN - (_len)) &~ (sizeof(long) - 1); }
     310#define M_ALIGN(m, len) \
     311        { (m)->m_data += (MLEN - (len)) &~ (sizeof(long) - 1); }
    315312/*
    316313 * As above, for mbufs allocated with m_gethdr/MGETHDR
    317314 * or initialized by M_COPY_PKTHDR.
    318315 */
    319 #define MH_ALIGN(_m, _len) \
    320         { (_m)->m_data += (MHLEN - (_len)) &~ (sizeof(long) - 1); }
     316#define MH_ALIGN(m, len) \
     317        { (m)->m_data += (MHLEN - (len)) &~ (sizeof(long) - 1); }
    321318
    322319/*
     
    324321 * before the current start of data in an mbuf.
    325322 */
    326 #define M_LEADINGSPACE(_m) \
    327         ((_m)->m_flags & M_EXT ? /* (_m)->m_data - (_m)->m_ext.ext_buf */ 0 : \
    328             (_m)->m_flags & M_PKTHDR ? (_m)->m_data - (_m)->m_pktdat : \
    329             (_m)->m_data - (_m)->m_dat)
     323#define M_LEADINGSPACE(m) \
     324        ((m)->m_flags & M_EXT ? /* (m)->m_data - (m)->m_ext.ext_buf */ 0 : \
     325            (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \
     326            (m)->m_data - (m)->m_dat)
    330327
    331328/*
     
    333330 * after the end of data in an mbuf.
    334331 */
    335 #define M_TRAILINGSPACE(_m) \
    336         ((_m)->m_flags & M_EXT ? (_m)->m_ext.ext_buf + (_m)->m_ext.ext_size - \
    337             ((_m)->m_data + (_m)->m_len) : \
    338             &(_m)->m_dat[MLEN] - ((_m)->m_data + (_m)->m_len))
     332#define M_TRAILINGSPACE(m) \
     333        ((m)->m_flags & M_EXT ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size - \
     334            ((m)->m_data + (m)->m_len) : \
     335            &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len))
    339336
    340337/*
     
    344341 * is freed and m is set to NULL.
    345342 */
    346 #define M_PREPEND(_m, _plen, _how) { \
    347         if (M_LEADINGSPACE(_m) >= (_plen)) { \
    348                 (_m)->m_data -= (_plen); \
    349                 (_m)->m_len += (_plen); \
     343#define M_PREPEND(m, plen, how) { \
     344        if (M_LEADINGSPACE(m) >= (plen)) { \
     345                (m)->m_data -= (plen); \
     346                (m)->m_len += (plen); \
    350347        } else \
    351                 (_m) = m_prepend((_m), (_plen), (_how)); \
    352         if ((_m) && (_m)->m_flags & M_PKTHDR) \
    353                 (_m)->m_pkthdr.len += (_plen); \
     348                (m) = m_prepend((m), (plen), (how)); \
     349        if ((m) && (m)->m_flags & M_PKTHDR) \
     350                (m)->m_pkthdr.len += (plen); \
    354351}
    355352
    356353/* change mbuf to new type */
    357 #define MCHTYPE(_m, _t) { \
    358         MBUFLOCK(mbstat.m_mtypes[(_m)->m_type]--; mbstat.m_mtypes[t]++;) \
    359         (_m)->m_type = t;\
     354#define MCHTYPE(m, t) { \
     355        MBUFLOCK(mbstat.m_mtypes[(m)->m_type]--; mbstat.m_mtypes[t]++;) \
     356        (m)->m_type = t;\
    360357}
    361358
  • cpukit/libnetworking/sys/mbuf.h

    r5a064dca r8bbaf3b  
    171171 * drivers.
    172172 */
    173 #define MBUFLOCK(_code) \
     173#define MBUFLOCK(code) \
    174174        { int ms = splimp(); \
    175           { _code } \
     175          { code } \
    176176          splx(ms); \
    177177        }
     
    187187 * and internal data.
    188188 */
    189 #define MGET(_m, _how, _type) { \
     189#define MGET(m, how, type) { \
    190190          int _ms = splimp(); \
    191191          if (mmbfree == 0) \
    192                 (void)m_mballoc(1, (_how)); \
    193           if (((_m) = mmbfree) != 0) { \
    194                 mmbfree = (_m)->m_next; \
    195 /* printf( "MGET: %p\n", (_m) ); */ \
     192                (void)m_mballoc(1, (how)); \
     193          if (((m) = mmbfree) != 0) { \
     194                mmbfree = (m)->m_next; \
    196195                mbstat.m_mtypes[MT_FREE]--; \
    197                 (_m)->m_type = (_type); \
    198                 mbstat.m_mtypes[_type]++; \
    199                 (_m)->m_next = (struct mbuf *)NULL; \
    200                 (_m)->m_nextpkt = (struct mbuf *)NULL; \
    201                 (_m)->m_data = (_m)->m_dat; \
    202                 (_m)->m_flags = 0; \
     196                (m)->m_type = (type); \
     197                mbstat.m_mtypes[type]++; \
     198                (m)->m_next = (struct mbuf *)NULL; \
     199                (m)->m_nextpkt = (struct mbuf *)NULL; \
     200                (m)->m_data = (m)->m_dat; \
     201                (m)->m_flags = 0; \
    203202                splx(_ms); \
    204203        } else { \
    205204                splx(_ms); \
    206                 (_m) = m_retry((_how), (_type)); \
     205                (m) = m_retry((how), (type)); \
    207206        } \
    208207}
    209208
    210 #define MGETHDR(_m, _how, _type) { \
     209#define MGETHDR(m, how, type) { \
    211210          int _ms = splimp(); \
    212211          if (mmbfree == 0) \
    213                 (void)m_mballoc(1, (_how)); \
    214           if (((_m) = mmbfree) != 0) { \
    215                 mmbfree = (_m)->m_next; \
    216 /* printf( "MGETHDR: %p\n", (_m) ); */ \
     212                (void)m_mballoc(1, (how)); \
     213          if (((m) = mmbfree) != 0) { \
     214                mmbfree = (m)->m_next; \
    217215                mbstat.m_mtypes[MT_FREE]--; \
    218                 (_m)->m_type = (_type); \
    219                 mbstat.m_mtypes[_type]++; \
    220                 (_m)->m_next = (struct mbuf *)NULL; \
    221                 (_m)->m_nextpkt = (struct mbuf *)NULL; \
    222                 (_m)->m_data = (_m)->m_pktdat; \
    223                 (_m)->m_flags = M_PKTHDR; \
     216                (m)->m_type = (type); \
     217                mbstat.m_mtypes[type]++; \
     218                (m)->m_next = (struct mbuf *)NULL; \
     219                (m)->m_nextpkt = (struct mbuf *)NULL; \
     220                (m)->m_data = (m)->m_pktdat; \
     221                (m)->m_flags = M_PKTHDR; \
    224222                splx(_ms); \
    225223        } else { \
    226224                splx(_ms); \
    227                 (_m) = m_retryhdr((_how), (_type)); \
     225                (m) = m_retryhdr((how), (type)); \
    228226        } \
    229227}
     
    237235 * freeing the cluster if the reference count has reached 0.
    238236 */
    239 #define MCLALLOC(_p, _how) \
     237#define MCLALLOC(p, how) \
    240238        MBUFLOCK( \
    241239          if (mclfree == 0) \
    242                 (void)m_clalloc(1, (_how)); \
    243           if (((_p) = (caddr_t)mclfree) != 0) { \
    244                 ++mclrefcnt[mtocl(_p)]; \
     240                (void)m_clalloc(1, (how)); \
     241          if (((p) = (caddr_t)mclfree) != 0) { \
     242                ++mclrefcnt[mtocl(p)]; \
    245243                mbstat.m_clfree--; \
    246                 mclfree = ((union mcluster *)(_p))->mcl_next; \
     244                mclfree = ((union mcluster *)(p))->mcl_next; \
    247245          } \
    248246        )
    249247
    250 #define MCLGET(_m, _how) \
    251         { MCLALLOC((_m)->m_ext.ext_buf, (_how)); \
    252           if ((_m)->m_ext.ext_buf != NULL) { \
    253                 (_m)->m_data = (_m)->m_ext.ext_buf; \
    254                 (_m)->m_flags |= M_EXT; \
    255                 (_m)->m_ext.ext_free = NULL;  \
    256                 (_m)->m_ext.ext_ref = NULL;  \
    257                 (_m)->m_ext.ext_size = MCLBYTES;  \
     248#define MCLGET(m, how) \
     249        { MCLALLOC((m)->m_ext.ext_buf, (how)); \
     250          if ((m)->m_ext.ext_buf != NULL) { \
     251                (m)->m_data = (m)->m_ext.ext_buf; \
     252                (m)->m_flags |= M_EXT; \
     253                (m)->m_ext.ext_free = NULL;  \
     254                (m)->m_ext.ext_ref = NULL;  \
     255                (m)->m_ext.ext_size = MCLBYTES;  \
    258256          } \
    259257        }
    260258
    261 #define MCLFREE(_p) \
     259#define MCLFREE(p) \
    262260        MBUFLOCK ( \
    263           if (--mclrefcnt[mtocl(_p)] == 0) { \
    264                 ((union mcluster *)(_p))->mcl_next = mclfree; \
    265                 mclfree = (union mcluster *)(_p); \
     261          if (--mclrefcnt[mtocl(p)] == 0) { \
     262                ((union mcluster *)(p))->mcl_next = mclfree; \
     263                mclfree = (union mcluster *)(p); \
    266264                mbstat.m_clfree++; \
    267265          } \
     
    273271 * Place the successor, if any, in n.
    274272 */
    275 #define MFREE(_m, _n) \
     273#define MFREE(m, n) \
    276274        MBUFLOCK(  \
    277 /* printf( "MFREE: %p\n", (_m) ); */ \
    278           mbstat.m_mtypes[(_m)->m_type]--; \
    279           if ((_m)->m_flags & M_EXT) { \
    280                 if ((_m)->m_ext.ext_free) \
    281                         (*((_m)->m_ext.ext_free))((_m)->m_ext.ext_buf, \
    282                             (_m)->m_ext.ext_size); \
     275          mbstat.m_mtypes[(m)->m_type]--; \
     276          if ((m)->m_flags & M_EXT) { \
     277                if ((m)->m_ext.ext_free) \
     278                        (*((m)->m_ext.ext_free))((m)->m_ext.ext_buf, \
     279                            (m)->m_ext.ext_size); \
    283280                else { \
    284                         char *p = (_m)->m_ext.ext_buf; \
     281                        char *p = (m)->m_ext.ext_buf; \
    285282                        if (--mclrefcnt[mtocl(p)] == 0) { \
    286283                                ((union mcluster *)(p))->mcl_next = mclfree; \
     
    290287                } \
    291288          } \
    292           (_n) = (_m)->m_next; \
    293           (_m)->m_type = MT_FREE; \
     289          (n) = (m)->m_next; \
     290          (m)->m_type = MT_FREE; \
    294291          mbstat.m_mtypes[MT_FREE]++; \
    295           (_m)->m_next = mmbfree; \
    296           mmbfree = (_m); \
     292          (m)->m_next = mmbfree; \
     293          mmbfree = (m); \
    297294        )
    298295
     
    301298 * from must have M_PKTHDR set, and to must be empty.
    302299 */
    303 #define M_COPY_PKTHDR(_to, _from) { \
    304         (_to)->m_pkthdr = (_from)->m_pkthdr; \
    305         (_to)->m_flags = (_from)->m_flags & M_COPYFLAGS; \
    306         (_to)->m_data = (_to)->m_pktdat; \
     300#define M_COPY_PKTHDR(to, from) { \
     301        (to)->m_pkthdr = (from)->m_pkthdr; \
     302        (to)->m_flags = (from)->m_flags & M_COPYFLAGS; \
     303        (to)->m_data = (to)->m_pktdat; \
    307304}
    308305
     
    311308 * an object of the specified size at the end of the mbuf, longword aligned.
    312309 */
    313 #define M_ALIGN(_m, _len) \
    314         { (_m)->m_data += (MLEN - (_len)) &~ (sizeof(long) - 1); }
     310#define M_ALIGN(m, len) \
     311        { (m)->m_data += (MLEN - (len)) &~ (sizeof(long) - 1); }
    315312/*
    316313 * As above, for mbufs allocated with m_gethdr/MGETHDR
    317314 * or initialized by M_COPY_PKTHDR.
    318315 */
    319 #define MH_ALIGN(_m, _len) \
    320         { (_m)->m_data += (MHLEN - (_len)) &~ (sizeof(long) - 1); }
     316#define MH_ALIGN(m, len) \
     317        { (m)->m_data += (MHLEN - (len)) &~ (sizeof(long) - 1); }
    321318
    322319/*
     
    324321 * before the current start of data in an mbuf.
    325322 */
    326 #define M_LEADINGSPACE(_m) \
    327         ((_m)->m_flags & M_EXT ? /* (_m)->m_data - (_m)->m_ext.ext_buf */ 0 : \
    328             (_m)->m_flags & M_PKTHDR ? (_m)->m_data - (_m)->m_pktdat : \
    329             (_m)->m_data - (_m)->m_dat)
     323#define M_LEADINGSPACE(m) \
     324        ((m)->m_flags & M_EXT ? /* (m)->m_data - (m)->m_ext.ext_buf */ 0 : \
     325            (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \
     326            (m)->m_data - (m)->m_dat)
    330327
    331328/*
     
    333330 * after the end of data in an mbuf.
    334331 */
    335 #define M_TRAILINGSPACE(_m) \
    336         ((_m)->m_flags & M_EXT ? (_m)->m_ext.ext_buf + (_m)->m_ext.ext_size - \
    337             ((_m)->m_data + (_m)->m_len) : \
    338             &(_m)->m_dat[MLEN] - ((_m)->m_data + (_m)->m_len))
     332#define M_TRAILINGSPACE(m) \
     333        ((m)->m_flags & M_EXT ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size - \
     334            ((m)->m_data + (m)->m_len) : \
     335            &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len))
    339336
    340337/*
     
    344341 * is freed and m is set to NULL.
    345342 */
    346 #define M_PREPEND(_m, _plen, _how) { \
    347         if (M_LEADINGSPACE(_m) >= (_plen)) { \
    348                 (_m)->m_data -= (_plen); \
    349                 (_m)->m_len += (_plen); \
     343#define M_PREPEND(m, plen, how) { \
     344        if (M_LEADINGSPACE(m) >= (plen)) { \
     345                (m)->m_data -= (plen); \
     346                (m)->m_len += (plen); \
    350347        } else \
    351                 (_m) = m_prepend((_m), (_plen), (_how)); \
    352         if ((_m) && (_m)->m_flags & M_PKTHDR) \
    353                 (_m)->m_pkthdr.len += (_plen); \
     348                (m) = m_prepend((m), (plen), (how)); \
     349        if ((m) && (m)->m_flags & M_PKTHDR) \
     350                (m)->m_pkthdr.len += (plen); \
    354351}
    355352
    356353/* change mbuf to new type */
    357 #define MCHTYPE(_m, _t) { \
    358         MBUFLOCK(mbstat.m_mtypes[(_m)->m_type]--; mbstat.m_mtypes[t]++;) \
    359         (_m)->m_type = t;\
     354#define MCHTYPE(m, t) { \
     355        MBUFLOCK(mbstat.m_mtypes[(m)->m_type]--; mbstat.m_mtypes[t]++;) \
     356        (m)->m_type = t;\
    360357}
    361358
Note: See TracChangeset for help on using the changeset viewer.