View | Details | Raw Unified | Return to bug 14042
Collapse All | Expand All

(-)mbuf.h Tue Sep 28 23:39:22 1999 (-8 / +32 lines)
Lines 153-158 Link Here
153
#define        M_DONTWAIT      1
153
#define        M_DONTWAIT      1
154
#define        M_WAIT          0
154
#define        M_WAIT          0
155
155
156
/* 
157
 * Flags to pass to the *_wait functions (when we have to wait for an
158
 * mbuf to be freed).
159
 * XXX this could theoretically also be implemented as a char (which would
160
 * be SLIGHTLY less costly) that would be ORed with a specific 'pattern'
161
 * that could represent each one of the options -- but it's kept this way
162
 * for now for simplicity's sake.
163
 */
164
#define MGET_C         1
165
#define MGETHDR_C      2
166
156
/* Freelists:
167
/* Freelists:
157
 *
168
 *
158
 * Normal mbuf clusters are normally treated as character arrays
169
 * Normal mbuf clusters are normally treated as character arrays
Lines 203-209 Link Here
203
               splx(_ms); \
214
               splx(_ms); \
204
       } else { \
215
       } else { \
205
               splx(_ms); \
216
               splx(_ms); \
206
               (m) = m_retry((how), (type)); \
217
               if (((m)=m_retry((how), (type)))==NULL && (how)==M_WAIT) \
218
                       (m) = m_mballoc_wait(MGET_C,(type)); \
207
       } \
219
       } \
208
}
220
}
209
221
Lines 223-229 Link Here
223
               splx(_ms); \
235
               splx(_ms); \
224
       } else { \
236
       } else { \
225
               splx(_ms); \
237
               splx(_ms); \
226
               (m) = m_retryhdr((how), (type)); \
238
               if (((m)=m_retryhdr((how),(type)))==NULL && (how)==M_WAIT) \
239
                       (m) = m_mballoc_wait(MGETHDR_C,(type)); \
227
       } \
240
       } \
228
}
241
}
229
242
Lines 235-250 Link Here
235
 * MCLFREE releases a reference to a cluster allocated by MCLALLOC,
248
 * MCLFREE releases a reference to a cluster allocated by MCLALLOC,
236
 * freeing the cluster if the reference count has reached 0.
249
 * freeing the cluster if the reference count has reached 0.
237
 */
250
 */
238
#define        MCLALLOC(p, how) \
251
#define        MCLALLOC(p, how) { \
239
       MBUFLOCK( \
252
       int _ms = splimp(); \
240
         if (mclfree == 0) \
253
       if (mclfree == 0) \
241
               (void)m_clalloc(1, (how)); \
254
               (void)m_clalloc(1, (how)); \
242
         if (((p) = (caddr_t)mclfree) != 0) { \
255
       if (((p) = (caddr_t)mclfree) != 0) { \
243
               ++mclrefcnt[mtocl(p)]; \
256
               ++mclrefcnt[mtocl(p)]; \
244
               mbstat.m_clfree--; \
257
               mbstat.m_clfree--; \
245
               mclfree = ((union mcluster *)(p))->mcl_next; \
258
               mclfree = ((union mcluster *)(p))->mcl_next; \
246
         } \
259
               splx(_ms); \
247
       )
260
       } else if ((how) == M_WAIT) { \
261
               splx(_ms); \
262
               (p) = m_clalloc_wait(); \
263
       } \
264
}
248
265
249
#define        MCLGET(m, how) \
266
#define        MCLGET(m, how) \
250
       { MCLALLOC((m)->m_ext.ext_buf, (how)); \
267
       { MCLALLOC((m)->m_ext.ext_buf, (how)); \
Lines 263-268 Link Here
263
               ((union mcluster *)(p))->mcl_next = mclfree; \
280
               ((union mcluster *)(p))->mcl_next = mclfree; \
264
               mclfree = (union mcluster *)(p); \
281
               mclfree = (union mcluster *)(p); \
265
               mbstat.m_clfree++; \
282
               mbstat.m_clfree++; \
283
               (void)m_clalloc_wakeup(); \
266
         } \
284
         } \
267
       )
285
       )
268
286
Lines 284-289 Link Here
284
                               ((union mcluster *)(p))->mcl_next = mclfree; \
302
                               ((union mcluster *)(p))->mcl_next = mclfree; \
285
                               mclfree = (union mcluster *)(p); \
303
                               mclfree = (union mcluster *)(p); \
286
                               mbstat.m_clfree++; \
304
                               mbstat.m_clfree++; \
305
                               (void)m_clalloc_wakeup(); \
287
                       } \
306
                       } \
288
               } \
307
               } \
289
         } \
308
         } \
Lines 292-297 Link Here
292
         mbstat.m_mtypes[MT_FREE]++; \
311
         mbstat.m_mtypes[MT_FREE]++; \
293
         (m)->m_next = mmbfree; \
312
         (m)->m_next = mmbfree; \
294
         mmbfree = (m); \
313
         mmbfree = (m); \
314
         (void)m_mballoc_wakeup(); \
295
       )
315
       )
296
316
297
/*
317
/*
Lines 408-423 Link Here
408
struct mbuf *m_gethdr __P((int, int));
428
struct mbuf *m_gethdr __P((int, int));
409
struct mbuf *m_prepend __P((struct mbuf *,int,int));
429
struct mbuf *m_prepend __P((struct mbuf *,int,int));
410
struct mbuf *m_pullup __P((struct mbuf *, int));
430
struct mbuf *m_pullup __P((struct mbuf *, int));
431
struct mbuf *m_mballoc_wait __P((int,u_short));
411
struct mbuf *m_retry __P((int, int));
432
struct mbuf *m_retry __P((int, int));
412
struct mbuf *m_retryhdr __P((int, int));
433
struct mbuf *m_retryhdr __P((int, int));
413
struct mbuf *m_split __P((struct mbuf *,int,int));
434
struct mbuf *m_split __P((struct mbuf *,int,int));
414
void   m_adj __P((struct mbuf *, int));
435
void   m_adj __P((struct mbuf *, int));
415
void   m_cat __P((struct mbuf *,struct mbuf *));
436
void   m_cat __P((struct mbuf *,struct mbuf *));
437
void   m_mballoc_wakeup __P((void));
438
void   m_clalloc_wakeup __P((void));
416
int    m_mballoc __P((int, int));
439
int    m_mballoc __P((int, int));
417
int    m_clalloc __P((int, int));
440
int    m_clalloc __P((int, int));
418
void   m_copyback __P((struct mbuf *, int, int, caddr_t));
441
void   m_copyback __P((struct mbuf *, int, int, caddr_t));
419
void   m_copydata __P((struct mbuf *,int,int,caddr_t));
442
void   m_copydata __P((struct mbuf *,int,int,caddr_t));
420
void   m_freem __P((struct mbuf *));
443
void   m_freem __P((struct mbuf *));
444
caddr_t        m_clalloc_wait __P((void));
421
#endif /* KERNEL */
445
#endif /* KERNEL */
422
446
423
#endif /* !_SYS_MBUF_H_ */
447
#endif /* !_SYS_MBUF_H_ */

Return to bug 14042