qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [Qemu-trivial] [PATCH] slirp: reorder include to fix Fr


From: Michael Tokarev
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] slirp: reorder include to fix FreeBSD build failure
Date: Sat, 13 Jul 2013 13:12:59 +0400
User-agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:17.0) Gecko/20130704 Icedove/17.0.7

13.07.2013 00:29, Ed Maste wrote:
> Signed-off-by: Ed Maste <address@hidden>
> ---
> The issue comes from slirp/mbuf.h #defining m_flags, which conflicts with
> a header included via <semaphore.h> on FreeBSD.

Umgh.  How.. disgusting... :(

Here's the code in question.


/* header at beginning of each mbuf: */
struct m_hdr {
        struct  mbuf *mh_next;          /* Linked list of mbufs */
        struct  mbuf *mh_prev;
        struct  mbuf *mh_nextpkt;       /* Next packet in queue/record */
        struct  mbuf *mh_prevpkt; /* Flags aren't used in the output queue */
        int     mh_flags;         /* Misc flags */
...
};

struct mbuf {
        struct  m_hdr m_hdr;
        Slirp *slirp;
        bool    arp_requested;
...
};

#define m_next          m_hdr.mh_next
#define m_prev          m_hdr.mh_prev
#define m_nextpkt       m_hdr.mh_nextpkt
#define m_prevpkt       m_hdr.mh_prevpkt
#define m_flags         m_hdr.mh_flags
...

It looks to me that we should just get rid of all this.
struct m_hdr isn't used anywhere else so all its
members can be included directly into struct mbuf,
removing a good portion of those disgusting #defines.

Remaining:

struct mbuf {
        union M_dat {
                char    m_dat_[1]; /* ANSI don't like 0 sized arrays */
                char    *m_ext_;
        } M_dat;
};

#define m_dat           M_dat.m_dat_
#define m_ext           M_dat.m_ext_

This can be done by using an unnamed union, ie, by omitting
M_dat.

And since the code almost everywhere uses those m_* defines, it
is trivial to fix this for real.

Something like the attached.

Maybe we should get rid of the rest of indirections here too,
ifq_prev ifs_prev etc, but i'm not sure about these.

Thanks,

/mjt

Attachment: slirp-remove-mbuf-m_hdr-m_dat-indirection.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]