subr_mchain.c (107940) | subr_mchain.c (109623) |
---|---|
1/* 2 * Copyright (c) 2000, 2001 Boris Popov 3 * 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 --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * | 1/* 2 * Copyright (c) 2000, 2001 Boris Popov 3 * 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 --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * |
32 * $FreeBSD: head/sys/kern/subr_mchain.c 107940 2002-12-16 16:20:06Z robert $ | 32 * $FreeBSD: head/sys/kern/subr_mchain.c 109623 2003-01-21 08:56:16Z alfred $ |
33 */ 34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/endian.h> 38#include <sys/errno.h> 39#include <sys/mbuf.h> 40#include <sys/module.h> --- 12 unchanged lines hidden (view full) --- 53/* 54 * Various helper functions 55 */ 56int 57mb_init(struct mbchain *mbp) 58{ 59 struct mbuf *m; 60 | 33 */ 34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/endian.h> 38#include <sys/errno.h> 39#include <sys/mbuf.h> 40#include <sys/module.h> --- 12 unchanged lines hidden (view full) --- 53/* 54 * Various helper functions 55 */ 56int 57mb_init(struct mbchain *mbp) 58{ 59 struct mbuf *m; 60 |
61 m = m_gethdr(M_TRYWAIT, MT_DATA); | 61 m = m_gethdr(0, MT_DATA); |
62 if (m == NULL) 63 return ENOBUFS; 64 m->m_len = 0; 65 mb_initm(mbp, m); 66 return 0; 67} 68 69void --- 40 unchanged lines hidden (view full) --- 110{ 111 struct mbuf *m, *mn; 112 caddr_t bpos; 113 114 if (size > MLEN) 115 panic("mb_reserve: size = %d\n", size); 116 m = mbp->mb_cur; 117 if (mbp->mb_mleft < size) { | 62 if (m == NULL) 63 return ENOBUFS; 64 m->m_len = 0; 65 mb_initm(mbp, m); 66 return 0; 67} 68 69void --- 40 unchanged lines hidden (view full) --- 110{ 111 struct mbuf *m, *mn; 112 caddr_t bpos; 113 114 if (size > MLEN) 115 panic("mb_reserve: size = %d\n", size); 116 m = mbp->mb_cur; 117 if (mbp->mb_mleft < size) { |
118 mn = m_get(M_TRYWAIT, MT_DATA); | 118 mn = m_get(0, MT_DATA); |
119 if (mn == NULL) 120 return NULL; 121 mbp->mb_cur = m->m_next = mn; 122 m = mn; 123 m->m_len = 0; 124 mbp->mb_mleft = M_TRAILINGSPACE(m); 125 } 126 mbp->mb_mleft -= size; --- 60 unchanged lines hidden (view full) --- 187 int cplen, error, mleft, count; 188 189 m = mbp->mb_cur; 190 mleft = mbp->mb_mleft; 191 192 while (size > 0) { 193 if (mleft == 0) { 194 if (m->m_next == NULL) { | 119 if (mn == NULL) 120 return NULL; 121 mbp->mb_cur = m->m_next = mn; 122 m = mn; 123 m->m_len = 0; 124 mbp->mb_mleft = M_TRAILINGSPACE(m); 125 } 126 mbp->mb_mleft -= size; --- 60 unchanged lines hidden (view full) --- 187 int cplen, error, mleft, count; 188 189 m = mbp->mb_cur; 190 mleft = mbp->mb_mleft; 191 192 while (size > 0) { 193 if (mleft == 0) { 194 if (m->m_next == NULL) { |
195 m = m_getm(m, size, M_TRYWAIT, MT_DATA); | 195 m = m_getm(m, size, 0, MT_DATA); |
196 if (m == NULL) 197 return ENOBUFS; 198 } 199 m = m->m_next; 200 mleft = M_TRAILINGSPACE(m); 201 continue; 202 } 203 cplen = mleft > size ? size : mleft; --- 84 unchanged lines hidden (view full) --- 288/* 289 * Routines for fetching data from an mbuf chain 290 */ 291int 292md_init(struct mdchain *mdp) 293{ 294 struct mbuf *m; 295 | 196 if (m == NULL) 197 return ENOBUFS; 198 } 199 m = m->m_next; 200 mleft = M_TRAILINGSPACE(m); 201 continue; 202 } 203 cplen = mleft > size ? size : mleft; --- 84 unchanged lines hidden (view full) --- 288/* 289 * Routines for fetching data from an mbuf chain 290 */ 291int 292md_init(struct mdchain *mdp) 293{ 294 struct mbuf *m; 295 |
296 m = m_gethdr(M_TRYWAIT, MT_DATA); | 296 m = m_gethdr(0, MT_DATA); |
297 if (m == NULL) 298 return ENOBUFS; 299 m->m_len = 0; 300 md_initm(mdp, m); 301 return 0; 302} 303 304void --- 191 unchanged lines hidden (view full) --- 496 return 0; 497} 498 499int 500md_get_mbuf(struct mdchain *mdp, int size, struct mbuf **ret) 501{ 502 struct mbuf *m = mdp->md_cur, *rm; 503 | 297 if (m == NULL) 298 return ENOBUFS; 299 m->m_len = 0; 300 md_initm(mdp, m); 301 return 0; 302} 303 304void --- 191 unchanged lines hidden (view full) --- 496 return 0; 497} 498 499int 500md_get_mbuf(struct mdchain *mdp, int size, struct mbuf **ret) 501{ 502 struct mbuf *m = mdp->md_cur, *rm; 503 |
504 rm = m_copym(m, mdp->md_pos - mtod(m, u_char*), size, M_TRYWAIT); | 504 rm = m_copym(m, mdp->md_pos - mtod(m, u_char*), size, 0); |
505 if (rm == NULL) 506 return EBADRPC; 507 md_get_mem(mdp, NULL, size, MB_MZERO); 508 *ret = rm; 509 return 0; 510} 511 512int --- 31 unchanged lines hidden --- | 505 if (rm == NULL) 506 return EBADRPC; 507 md_get_mem(mdp, NULL, size, MB_MZERO); 508 *ret = rm; 509 return 0; 510} 511 512int --- 31 unchanged lines hidden --- |