qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/3] qobject: assume base of a qobject is at off


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 2/3] qobject: assume base of a qobject is at offset 0
Date: Wed, 21 Mar 2018 16:34:53 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 21/03/2018 16:29, Eric Blake wrote:
> 
> Not necessarily - can we use multiple layers of macros?  (Untested)
> 
> #define QOBJECT_0(x) x
> #define QOBJECT_1(x) ({ \
>     QEMU_BUILD_BUG_ON(offsetof(typeof(*x), base)); \
>     &(x)->base; })
> #define QOBJECT(x) QOBJECT_ ## QEMU_GENERIC(x, \
>     (QObject *, 0),
>     (const QObject *, 0),
>     1)(x)
> 
> or with an additional layer of glue() if needed
> 
> That is, reduce the QEMU_GENERIC expansion into something that generates
> only a single preprocessor token, where we then use to decide which
> OTHER macro to expand, so that we are only evaluating &(x)->base when we
> selected the derived types.

I don't think so.  Macro expansion happens way earlier.

Paolo



reply via email to

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