All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: qemu-devel@nongnu.org, Paul Brook <paul@codesourcery.com>
Subject: [Qemu-devel] Re: [PATCH 2/2] Introduce macro for defining qdev properties
Date: Tue, 21 Jul 2009 10:30:28 +0200	[thread overview]
Message-ID: <4A657CA4.7080203@redhat.com> (raw)
In-Reply-To: <1247841685-18495-3-git-send-email-aliguori@us.ibm.com>

On 07/17/09 16:41, Anthony Liguori wrote:
> This patch introduces macros for defining qdev properties.  The default macro
> is clever enough to infer the type of the structure field and to automatically
> generate a name for the property.  Additional macros are provided that allow
> infered values to be overridden along with a set of macros to define properties
> with default values.

> +#define TYPEOF_FIELD(type, field) typeof(((type *)0)->field)

Hmm, tried to create something simliar.  Didn't work, looks like I did 
something wrong :-(

> +#define QDEV_PROP_TYPE_INFER(type, field)                          \
> +        CHOOSE(TYPES_COMPAT(TYPEOF_FIELD(type, field), uint16_t),  \
> +&qdev_prop_uint16,                                         \
> +        CHOOSE(TYPES_COMPAT(TYPEOF_FIELD(type, field), int16_t),   \
> +&qdev_prop_uint16,                                         \
> +        CHOOSE(TYPES_COMPAT(TYPEOF_FIELD(type, field), uint32_t),  \
> +&qdev_prop_uint32,                                         \
> +        CHOOSE(TYPES_COMPAT(TYPEOF_FIELD(type, field), int32_t),   \
> +&qdev_prop_uint32,                                         \
> +        CHOOSE(TYPES_COMPAT(TYPEOF_FIELD(type, field), CharDriverState *), \
> +&qdev_prop_chrdev,                                         \
> +        /* force a build break when inference fails */             \
> +       (double)3.14159265)))))

You probably want to use something like 
&qdev_prop_not_found_for_this_type instead of pi to get a somewhat 
better error message.

Overall this looks pretty good to me.

cheers,
   Gerd

      parent reply	other threads:[~2009-07-21  8:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-17 14:41 [Qemu-devel] [PATCH 0/2][RFC] Introduce macros for setting properties Anthony Liguori
2009-07-17 14:41 ` [Qemu-devel] [PATCH 1/2] Introduce CharDriverState qdev property type Anthony Liguori
2009-07-21 14:46   ` [Qemu-devel] " Gerd Hoffmann
2009-07-21 14:53     ` Anthony Liguori
2009-07-21 15:03       ` Gerd Hoffmann
2009-07-21 15:14         ` Gerd Hoffmann
2009-07-21 15:23         ` Anthony Liguori
2009-07-21 15:34           ` Gerd Hoffmann
2009-07-21 15:47             ` Anthony Liguori
2009-07-22  9:48               ` Gerd Hoffmann
2009-07-17 14:41 ` [Qemu-devel] [PATCH 2/2] Introduce macro for defining qdev properties Anthony Liguori
2009-07-17 17:23   ` Blue Swirl
2009-07-17 17:26     ` Anthony Liguori
2009-07-17 17:33     ` Paul Brook
2009-07-17 18:11       ` Anthony Liguori
2009-07-17 18:32         ` Blue Swirl
2009-07-17 20:05           ` Anthony Liguori
2009-07-17 22:58             ` Paul Brook
2009-07-18 12:43               ` Jamie Lokier
2009-07-18 16:13                 ` Anthony Liguori
2009-07-20  2:29                   ` Jamie Lokier
2009-07-21  8:30   ` Gerd Hoffmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A657CA4.7080203@redhat.com \
    --to=kraxel@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.