/* uipc_mbuf.c 1.41 82/12/14 */
if (m_clalloc(4, MPG_MBUFS
) == 0)
if (m_clalloc(32, MPG_CLUSTERS
) == 0)
s
= splimp(); /* careful: rmalloc isn't reentrant */
mbx
= rmalloc(mbmap
, (long)npg
);
if (memall(&Mbmap
[mbx
], npg
, proc
, CSYS
) == 0)
vmaccess(&Mbmap
[mbx
], (caddr_t
)m
, npg
);
for (i
= 0; i
< ncl
; i
++) {
m
+= CLBYTES
/ sizeof (*m
);
mbstat
.m_clusters
+= ncl
;
for (i
= ncl
* CLBYTES
/ sizeof (*m
); i
> 0; i
--) {
mbstat
.m_mtypes
[MT_DATA
]++;
if (m_clalloc(1, MPG_MBUFS
) == 0)
/* should ask protocols to free code */
/* NEED SOME WAY TO RELEASE SPACE */
* Space allocation routines.
* These are also available as macros
m
= m_get(canwait
, type
);
bzero(mtod(m
, caddr_t
), MLEN
);
#define m_more(x,y) (panic("m_more"), (struct mbuf *)0)
* Mbuffer utility routines.
register struct mbuf
*n
, **np
;
n
->m_len
= MIN(len
, m
->m_len
- off
);
if (m
->m_off
> MMAXOFF
) {
p
= mtod(m
, struct mbuf
*);
n
->m_off
= ((int)p
- (int)n
) + off
;
bcopy(mtod(m
, caddr_t
)+off
, mtod(n
, caddr_t
),
register struct mbuf
*m
, *n
;
if (m
->m_off
>= MMAXOFF
||
m
->m_off
+ m
->m_len
+ n
->m_len
> MMAXOFF
) {
/* just join the two chains */
/* splat the data from one into the other */
bcopy(mtod(n
, caddr_t
), mtod(m
, caddr_t
) + m
->m_len
,
register struct mbuf
*m
, *n
;
while (m
!= NULL
&& len
> 0) {
/* a 2 pass algorithm might be better */
while (len
> 0 && m
->m_len
!= 0) {
while (m
!= NULL
&& m
->m_len
!= 0) {
register struct mbuf
*m
, *n
;
MGET(m
, M_DONTWAIT
, n
->m_type
);
count
= MIN(MLEN
- m
->m_len
, len
);
bcopy(mtod(n
, caddr_t
), mtod(m
, caddr_t
)+m
->m_len
,