From: Anthony Liguori <anthony@codemonkey.ws>
To: "Andreas Färber" <afaerber@suse.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH RFC 5/7] cpu: Introduce cpu_class_foreach()
Date: Sun, 29 Jan 2012 20:16:11 -0600 [thread overview]
Message-ID: <4F25FD6B.6010102@codemonkey.ws> (raw)
In-Reply-To: <1327843531-32403-6-git-send-email-afaerber@suse.de>
On 01/29/2012 07:25 AM, Andreas Färber wrote:
> Provides an easy way to loop over all non-abstract CPU classes.
>
> Signed-off-by: Andreas Färber<afaerber@suse.de>
I have a patch in my next series which provides an interface for this.
https://github.com/aliguori/qemu/commit/42ab3f78477307438591c77816f06f12cf9d9fc0
I'll post a proper version tomorrow.
Regards,
Anthony Liguori
> ---
> hw/cpu.c | 25 +++++++++++++++++++++++++
> include/qemu/cpu.h | 9 +++++++++
> 2 files changed, 34 insertions(+), 0 deletions(-)
>
> diff --git a/hw/cpu.c b/hw/cpu.c
> index c0e9cfa..ac0add7 100644
> --- a/hw/cpu.c
> +++ b/hw/cpu.c
> @@ -11,6 +11,31 @@
> #include "qemu/cpu.h"
> #include "qemu-common.h"
>
> +struct CPUListData {
> + void (*fn)(ObjectClass *klass, void *opaque);
> + void *opaque;
> +};
> +
> +static void cpu_class_foreach_tramp(ObjectClass *klass, void *opaque)
> +{
> + struct CPUListData *s = opaque;
> +
> + if (!object_class_is_abstract(klass)&&
> + object_class_dynamic_cast(klass, TYPE_CPU) != NULL) {
> + s->fn(klass, s->opaque);
> + }
> +}
> +
> +void cpu_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
> + void *opaque)
> +{
> + struct CPUListData s = {
> + .fn = fn,
> + .opaque = opaque,
> + };
> + object_class_foreach(cpu_class_foreach_tramp,&s);
> +}
> +
> static TypeInfo cpu_type_info = {
> .name = TYPE_CPU,
> .parent = TYPE_OBJECT,
> diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h
> index 4b81f3b..d06c87e 100644
> --- a/include/qemu/cpu.h
> +++ b/include/qemu/cpu.h
> @@ -24,4 +24,13 @@ typedef struct CPU {
> } CPU;
>
>
> +/**
> + * cpu_class_foreach:
> + * @fn: Callback function called for each non-abstract CPU type.
> + * @opaque: Opaque data passed through to the callback function.
> + */
> +void cpu_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
> + void *opaque);
> +
> +
> #endif
next prev parent reply other threads:[~2012-01-30 2:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-29 13:25 [Qemu-devel] [PATCH RFC 0/7] Introduce QOM CPU and use for target-arm Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH 1/7][RESEND] qom: Introduce object_class_is_abstract() Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH RFC 2/7] qom: Register QOM infrastructure early Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH RFC 3/7] qom: Add QOM support to user emulators Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH RFC 4/7] qom: Introduce CPU class Andreas Färber
2012-01-30 2:14 ` Anthony Liguori
2012-01-30 11:58 ` Andreas Färber
2012-01-31 10:36 ` Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH RFC 5/7] cpu: Introduce cpu_class_foreach() Andreas Färber
2012-01-30 2:16 ` Anthony Liguori [this message]
2012-01-30 12:02 ` Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH RFC 6/7] target-arm: Introduce QOM CPU and use for it CPUID lookup Andreas Färber
2012-01-30 2:19 ` Anthony Liguori
2012-01-30 12:11 ` Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH RFC 7/7] target-arm: Embed CPUARMState in QOM ARMCPU Andreas Färber
2012-01-30 2:22 ` Anthony Liguori
2012-01-30 12:52 ` Andreas Färber
2012-01-30 16:01 ` Andreas Färber
2012-01-29 23:50 ` [Qemu-devel] [PATCH RFC 8/7] target-arm: Use IoC for CPU init Andreas Färber
2012-01-30 2:23 ` Anthony Liguori
2012-01-29 23:50 ` [Qemu-devel] [PATCH RFC 9/7] target-arm: Move CPU feature flags to class Andreas Färber
2012-01-30 19:27 ` Andreas Färber
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=4F25FD6B.6010102@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=afaerber@suse.de \
--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.