struct mbuf uses a C99 open char array to allow inlining data. Inlining
this in another structure is however a GNU extension. The inlines used
so far in struct Slirp were actually only needed as head of struct
mbuf lists. This replaces these inline with mere struct quehead,
and use casts as appropriate.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
void
if_init(Slirp *slirp)
{
void
if_init(Slirp *slirp)
{
- slirp->if_fastq.ifq_next = slirp->if_fastq.ifq_prev = &slirp->if_fastq;
- slirp->if_batchq.ifq_next = slirp->if_batchq.ifq_prev = &slirp->if_batchq;
- slirp->next_m = &slirp->if_batchq;
+ slirp->if_fastq.qh_link = slirp->if_fastq.qh_rlink = &slirp->if_fastq;
+ slirp->if_batchq.qh_link = slirp->if_batchq.qh_rlink = &slirp->if_batchq;
+ slirp->next_m = (struct mbuf *) &slirp->if_batchq;
* We mustn't put this packet back on the fastq (or we'll send it out of order)
* XXX add cache here?
*/
* We mustn't put this packet back on the fastq (or we'll send it out of order)
* XXX add cache here?
*/
- for (ifq = slirp->if_batchq.ifq_prev; ifq != &slirp->if_batchq;
+ for (ifq = (struct mbuf *) slirp->if_batchq.qh_rlink;
+ (struct quehead *) ifq != &slirp->if_batchq;
ifq = ifq->ifq_prev) {
if (so == ifq->ifq_so) {
/* A match! */
ifq = ifq->ifq_prev) {
if (so == ifq->ifq_so) {
/* A match! */
/* No match, check which queue to put it on */
if (so && (so->so_iptos & IPTOS_LOWDELAY)) {
/* No match, check which queue to put it on */
if (so && (so->so_iptos & IPTOS_LOWDELAY)) {
- ifq = slirp->if_fastq.ifq_prev;
+ ifq = (struct mbuf *) slirp->if_fastq.qh_rlink;
on_fastq = 1;
/*
* Check if this packet is a part of the last
on_fastq = 1;
/*
* Check if this packet is a part of the last
- ifq = slirp->if_batchq.ifq_prev;
+ ifq = (struct mbuf *) slirp->if_batchq.qh_rlink;
/* Set next_m if the queue was empty so far */
/* Set next_m if the queue was empty so far */
- if (slirp->next_m == &slirp->if_batchq) {
+ if ((struct quehead *) slirp->next_m == &slirp->if_batchq) {
}
slirp->if_start_busy = true;
}
slirp->if_start_busy = true;
- if (slirp->if_fastq.ifq_next != &slirp->if_fastq) {
- ifm_next = slirp->if_fastq.ifq_next;
+ if (slirp->if_fastq.qh_link != &slirp->if_fastq) {
+ ifm_next = (struct mbuf *) slirp->if_fastq.qh_link;
next_from_batchq = false;
next_from_batchq = false;
- } else if (slirp->next_m != &slirp->if_batchq) {
+ } else if ((struct quehead *) slirp->next_m != &slirp->if_batchq) {
/* Nothing on fastq, pick up from batchq via next_m */
ifm_next = slirp->next_m;
next_from_batchq = true;
/* Nothing on fastq, pick up from batchq via next_m */
ifm_next = slirp->next_m;
next_from_batchq = true;
from_batchq = next_from_batchq;
ifm_next = ifm->ifq_next;
from_batchq = next_from_batchq;
ifm_next = ifm->ifq_next;
- if (ifm_next == &slirp->if_fastq) {
+ if ((struct quehead *) ifm_next == &slirp->if_fastq) {
/* No more packets in fastq, switch to batchq */
ifm_next = slirp->next_m;
next_from_batchq = true;
}
/* No more packets in fastq, switch to batchq */
ifm_next = slirp->next_m;
next_from_batchq = true;
}
- if (ifm_next == &slirp->if_batchq) {
+ if ((struct quehead *) ifm_next == &slirp->if_batchq) {
/* end of batchq */
ifm_next = NULL;
}
/* end of batchq */
ifm_next = NULL;
}
/* Next packet in fastq is from the same session */
ifm_next = next;
next_from_batchq = false;
/* Next packet in fastq is from the same session */
ifm_next = next;
next_from_batchq = false;
- } else if (slirp->next_m == &slirp->if_batchq) {
+ } else if ((struct quehead *) slirp->next_m == &slirp->if_batchq) {
/* Set next_m and ifm_next if the session packet is now the
* only one on batchq */
slirp->next_m = ifm_next = next;
/* Set next_m and ifm_next if the session packet is now the
* only one on batchq */
slirp->next_m = ifm_next = next;
void
m_init(Slirp *slirp)
{
void
m_init(Slirp *slirp)
{
- slirp->m_freelist.m_next = slirp->m_freelist.m_prev = &slirp->m_freelist;
- slirp->m_usedlist.m_next = slirp->m_usedlist.m_prev = &slirp->m_usedlist;
+ slirp->m_freelist.qh_link = slirp->m_freelist.qh_rlink = &slirp->m_freelist;
+ slirp->m_usedlist.qh_link = slirp->m_usedlist.qh_rlink = &slirp->m_usedlist;
}
void m_cleanup(Slirp *slirp)
{
struct mbuf *m, *next;
}
void m_cleanup(Slirp *slirp)
{
struct mbuf *m, *next;
- m = slirp->m_usedlist.m_next;
- while (m != &slirp->m_usedlist) {
+ m = (struct mbuf *) slirp->m_usedlist.qh_link;
+ while ((struct quehead *) m != &slirp->m_usedlist) {
next = m->m_next;
if (m->m_flags & M_EXT) {
free(m->m_ext);
next = m->m_next;
if (m->m_flags & M_EXT) {
free(m->m_ext);
- m = slirp->m_freelist.m_next;
- while (m != &slirp->m_freelist) {
+ m = (struct mbuf *) slirp->m_freelist.qh_link;
+ while ((struct quehead *) m != &slirp->m_freelist) {
next = m->m_next;
free(m);
m = next;
next = m->m_next;
free(m);
m = next;
- if (slirp->m_freelist.m_next == &slirp->m_freelist) {
+ if (slirp->m_freelist.qh_link == &slirp->m_freelist) {
m = (struct mbuf *)malloc(SLIRP_MSIZE);
if (m == NULL) goto end_error;
slirp->mbuf_alloced++;
m = (struct mbuf *)malloc(SLIRP_MSIZE);
if (m == NULL) goto end_error;
slirp->mbuf_alloced++;
flags = M_DOFREE;
m->slirp = slirp;
} else {
flags = M_DOFREE;
m->slirp = slirp;
} else {
- m = slirp->m_freelist.m_next;
+ m = (struct mbuf *) slirp->m_freelist.qh_link;
DEBUG_ARG("dat = %p", dat);
/* bug corrected for M_EXT buffers */
DEBUG_ARG("dat = %p", dat);
/* bug corrected for M_EXT buffers */
- for (m = slirp->m_usedlist.m_next; m != &slirp->m_usedlist;
+ for (m = (struct mbuf *) slirp->m_usedlist.qh_link;
+ (struct quehead *) m != &slirp->m_usedlist;
m = m->m_next) {
if (m->m_flags & M_EXT) {
if( (char *)dat>=m->m_ext && (char *)dat<(m->m_ext + m->m_size) )
m = m->m_next) {
if (m->m_flags & M_EXT) {
if( (char *)dat>=m->m_ext && (char *)dat<(m->m_ext + m->m_size) )
int slirp_debug = DBG_CALL|DBG_MISC|DBG_ERROR;
#endif
int slirp_debug = DBG_CALL|DBG_MISC|DBG_ERROR;
#endif
-struct quehead {
- struct quehead *qh_link;
- struct quehead *qh_rlink;
-};
-
inline void
insque(void *a, void *b)
{
inline void
insque(void *a, void *b)
{
+struct slirp_quehead {
+ struct slirp_quehead *qh_link;
+ struct slirp_quehead *qh_rlink;
+};
+
void slirp_insque(void *, void *);
void slirp_remque(void *);
int add_exec(struct ex_list **, int, char *, struct in_addr, int);
void slirp_insque(void *, void *);
void slirp_remque(void *);
int add_exec(struct ex_list **, int, char *, struct in_addr, int);
have different prototypes. */
#define insque slirp_insque
#define remque slirp_remque
have different prototypes. */
#define insque slirp_insque
#define remque slirp_remque
+#define quehead slirp_quehead
#ifdef HAVE_SYS_STROPTS_H
#include <sys/stropts.h>
#ifdef HAVE_SYS_STROPTS_H
#include <sys/stropts.h>
struct ex_list *exec_list;
/* mbuf states */
struct ex_list *exec_list;
/* mbuf states */
- struct mbuf m_freelist, m_usedlist;
+ struct quehead m_freelist;
+ struct quehead m_usedlist;
int mbuf_alloced;
/* if states */
int mbuf_alloced;
/* if states */
- struct mbuf if_fastq; /* fast queue (for interactive data) */
- struct mbuf if_batchq; /* queue for non-interactive data */
+ struct quehead if_fastq; /* fast queue (for interactive data) */
+ struct quehead if_batchq; /* queue for non-interactive data */
struct mbuf *next_m; /* pointer to next mbuf to output */
bool if_start_busy; /* avoid if_start recursion */
struct mbuf *next_m; /* pointer to next mbuf to output */
bool if_start_busy; /* avoid if_start recursion */