qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/2] Introduce macro for defining qdev propertie


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 2/2] Introduce macro for defining qdev properties
Date: Fri, 17 Jul 2009 15:05:21 -0500
User-agent: Thunderbird 2.0.0.21 (X11/20090320)

Blue Swirl wrote:
I'm not sure how to do this without GCC extensions.  We could potentially
add macro decorators and use a sparse-like tool to extract property lists
automatically from device state.

Then there is the template way:

Yes, I also considered that.

Another option would be comment decorators along with a post-processor.

typedef struct MyDeviceStruct
{
   SysBusDevice parent;

   /* public */
  QDEV_PROP(uint32_t, queue_depth);
  QDEV_PROP(uint32_t, tx_mitigation_delay);
  QDEV_PROP(CharDriverState *, chr);
} MyDeviceStruct;

Normally, we:

#define QDEV_PROP(a, b) a b

But then we could also do something like:

#define QDEV_PROP(a, b) QPROP_CANARY stringify(a) stringify(b)

Then run through CPP and grep 'CANARY | typedef struct' and then parse the output to build the table at build time.

Of course, we could just do QDEV_PROP like I originally proposed and then if we ever support something other than GCC, we can introduce a CPP post-processor to build the tables at compile time.

This is the approach we're taking for constructors after all.

--
Regards,

Anthony Liguori





reply via email to

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