* [Qemu-devel] [PATCH qom-cpu v2] cpu: Introduce CPUListState struct
@ 2012-12-19 1:03 Andreas Färber
2012-12-19 13:00 ` Igor Mammedov
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Färber @ 2012-12-19 1:03 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Eduardo Habkost, Paul Brook, Igor Mammedov,
Andreas Färber, Richard Henderson
This generalizes {ARM,M68k,Alpha}CPUListState to avoid declaring it for
each target. Place it in cpu-common.h to avoid circular dependencies.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
---
cpu-common.h | 12 ++++++++++++
target-alpha/cpu.c | 9 ++-------
target-arm/helper.c | 9 ++-------
target-m68k/helper.c | 9 ++-------
4 Dateien geändert, 18 Zeilen hinzugefügt(+), 21 Zeilen entfernt(-)
diff --git a/cpu-common.h b/cpu-common.h
index d2fbafa..a62b6ea 100644
--- a/cpu-common.h
+++ b/cpu-common.h
@@ -12,6 +12,18 @@
#include "bswap.h"
#include "qemu-queue.h"
+/**
+ * CPUListState:
+ * @cpu_fprintf: Print function.
+ * @file: File to print to using @cpu_fprint.
+ *
+ * State commonly used for iterating over CPU models.
+ */
+typedef struct CPUListState {
+ fprintf_function cpu_fprintf;
+ FILE *file;
+} CPUListState;
+
#if !defined(CONFIG_USER_ONLY)
enum device_endian {
diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c
index 2deb3c1..59d8669 100644
--- a/target-alpha/cpu.c
+++ b/target-alpha/cpu.c
@@ -33,11 +33,6 @@ static void alpha_cpu_realize(Object *obj, Error **errp)
#endif
}
-typedef struct AlphaCPUListState {
- fprintf_function cpu_fprintf;
- FILE *file;
-} AlphaCPUListState;
-
/* Sort alphabetically by type name. */
static gint alpha_cpu_list_compare(gconstpointer a, gconstpointer b)
{
@@ -53,7 +48,7 @@ static gint alpha_cpu_list_compare(gconstpointer a, gconstpointer b)
static void alpha_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
- AlphaCPUListState *s = user_data;
+ CPUListState *s = user_data;
(*s->cpu_fprintf)(s->file, " %s\n",
object_class_get_name(oc));
@@ -61,7 +56,7 @@ static void alpha_cpu_list_entry(gpointer data, gpointer user_data)
void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf)
{
- AlphaCPUListState s = {
+ CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
diff --git a/target-arm/helper.c b/target-arm/helper.c
index ab8b734..d2f2fb4 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -1291,11 +1291,6 @@ ARMCPU *cpu_arm_init(const char *cpu_model)
return cpu;
}
-typedef struct ARMCPUListState {
- fprintf_function cpu_fprintf;
- FILE *file;
-} ARMCPUListState;
-
/* Sort alphabetically by type name, except for "any". */
static gint arm_cpu_list_compare(gconstpointer a, gconstpointer b)
{
@@ -1317,7 +1312,7 @@ static gint arm_cpu_list_compare(gconstpointer a, gconstpointer b)
static void arm_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
- ARMCPUListState *s = user_data;
+ CPUListState *s = user_data;
(*s->cpu_fprintf)(s->file, " %s\n",
object_class_get_name(oc));
@@ -1325,7 +1320,7 @@ static void arm_cpu_list_entry(gpointer data, gpointer user_data)
void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf)
{
- ARMCPUListState s = {
+ CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index a5d0100..875a71a 100644
--- a/target-m68k/helper.c
+++ b/target-m68k/helper.c
@@ -25,11 +25,6 @@
#define SIGNBIT (1u << 31)
-typedef struct M68kCPUListState {
- fprintf_function cpu_fprintf;
- FILE *file;
-} M68kCPUListState;
-
/* Sort alphabetically, except for "any". */
static gint m68k_cpu_list_compare(gconstpointer a, gconstpointer b)
{
@@ -51,7 +46,7 @@ static gint m68k_cpu_list_compare(gconstpointer a, gconstpointer b)
static void m68k_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *c = data;
- M68kCPUListState *s = user_data;
+ CPUListState *s = user_data;
(*s->cpu_fprintf)(s->file, "%s\n",
object_class_get_name(c));
@@ -59,7 +54,7 @@ static void m68k_cpu_list_entry(gpointer data, gpointer user_data)
void m68k_cpu_list(FILE *f, fprintf_function cpu_fprintf)
{
- M68kCPUListState s = {
+ CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH qom-cpu v2] cpu: Introduce CPUListState struct
2012-12-19 1:03 [Qemu-devel] [PATCH qom-cpu v2] cpu: Introduce CPUListState struct Andreas Färber
@ 2012-12-19 13:00 ` Igor Mammedov
2012-12-19 13:07 ` Eduardo Habkost
0 siblings, 1 reply; 3+ messages in thread
From: Igor Mammedov @ 2012-12-19 13:00 UTC (permalink / raw)
To: Andreas Färber
Cc: Peter Maydell, Paul Brook, Richard Henderson, qemu-devel,
Eduardo Habkost
On Wed, 19 Dec 2012 02:03:55 +0100
Andreas Färber <afaerber@suse.de> wrote:
> This generalizes {ARM,M68k,Alpha}CPUListState to avoid declaring it for
> each target. Place it in cpu-common.h to avoid circular dependencies.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> ---
> cpu-common.h | 12 ++++++++++++
> target-alpha/cpu.c | 9 ++-------
> target-arm/helper.c | 9 ++-------
> target-m68k/helper.c | 9 ++-------
> 4 Dateien geändert, 18 Zeilen hinzugefügt(+), 21 Zeilen entfernt(-)
>
> diff --git a/cpu-common.h b/cpu-common.h
> index d2fbafa..a62b6ea 100644
> --- a/cpu-common.h
> +++ b/cpu-common.h
> @@ -12,6 +12,18 @@
> #include "bswap.h"
> #include "qemu-queue.h"
>
> +/**
> + * CPUListState:
> + * @cpu_fprintf: Print function.
> + * @file: File to print to using @cpu_fprint.
> + *
> + * State commonly used for iterating over CPU models.
> + */
> +typedef struct CPUListState {
> + fprintf_function cpu_fprintf;
> + FILE *file;
> +} CPUListState;
> +
> #if !defined(CONFIG_USER_ONLY)
>
> enum device_endian {
> diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c
> index 2deb3c1..59d8669 100644
> --- a/target-alpha/cpu.c
> +++ b/target-alpha/cpu.c
> @@ -33,11 +33,6 @@ static void alpha_cpu_realize(Object *obj, Error **errp)
> #endif
> }
>
> -typedef struct AlphaCPUListState {
> - fprintf_function cpu_fprintf;
> - FILE *file;
> -} AlphaCPUListState;
> -
> /* Sort alphabetically by type name. */
> static gint alpha_cpu_list_compare(gconstpointer a, gconstpointer b)
> {
> @@ -53,7 +48,7 @@ static gint alpha_cpu_list_compare(gconstpointer a,
> gconstpointer b) static void alpha_cpu_list_entry(gpointer data, gpointer
> user_data) {
> ObjectClass *oc = data;
> - AlphaCPUListState *s = user_data;
> + CPUListState *s = user_data;
>
> (*s->cpu_fprintf)(s->file, " %s\n",
> object_class_get_name(oc));
> @@ -61,7 +56,7 @@ static void alpha_cpu_list_entry(gpointer data, gpointer
> user_data)
> void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf)
> {
> - AlphaCPUListState s = {
> + CPUListState s = {
> .file = f,
> .cpu_fprintf = cpu_fprintf,
> };
> diff --git a/target-arm/helper.c b/target-arm/helper.c
> index ab8b734..d2f2fb4 100644
> --- a/target-arm/helper.c
> +++ b/target-arm/helper.c
> @@ -1291,11 +1291,6 @@ ARMCPU *cpu_arm_init(const char *cpu_model)
> return cpu;
> }
>
> -typedef struct ARMCPUListState {
> - fprintf_function cpu_fprintf;
> - FILE *file;
> -} ARMCPUListState;
> -
> /* Sort alphabetically by type name, except for "any". */
> static gint arm_cpu_list_compare(gconstpointer a, gconstpointer b)
> {
> @@ -1317,7 +1312,7 @@ static gint arm_cpu_list_compare(gconstpointer a,
> gconstpointer b) static void arm_cpu_list_entry(gpointer data, gpointer
> user_data) {
> ObjectClass *oc = data;
> - ARMCPUListState *s = user_data;
> + CPUListState *s = user_data;
>
> (*s->cpu_fprintf)(s->file, " %s\n",
> object_class_get_name(oc));
> @@ -1325,7 +1320,7 @@ static void arm_cpu_list_entry(gpointer data,
> gpointer user_data)
> void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf)
> {
> - ARMCPUListState s = {
> + CPUListState s = {
> .file = f,
> .cpu_fprintf = cpu_fprintf,
> };
> diff --git a/target-m68k/helper.c b/target-m68k/helper.c
> index a5d0100..875a71a 100644
> --- a/target-m68k/helper.c
> +++ b/target-m68k/helper.c
> @@ -25,11 +25,6 @@
>
> #define SIGNBIT (1u << 31)
>
> -typedef struct M68kCPUListState {
> - fprintf_function cpu_fprintf;
> - FILE *file;
> -} M68kCPUListState;
> -
> /* Sort alphabetically, except for "any". */
> static gint m68k_cpu_list_compare(gconstpointer a, gconstpointer b)
> {
> @@ -51,7 +46,7 @@ static gint m68k_cpu_list_compare(gconstpointer a,
> gconstpointer b) static void m68k_cpu_list_entry(gpointer data, gpointer
> user_data) {
> ObjectClass *c = data;
> - M68kCPUListState *s = user_data;
> + CPUListState *s = user_data;
>
> (*s->cpu_fprintf)(s->file, "%s\n",
> object_class_get_name(c));
> @@ -59,7 +54,7 @@ static void m68k_cpu_list_entry(gpointer data, gpointer
> user_data)
> void m68k_cpu_list(FILE *f, fprintf_function cpu_fprintf)
> {
> - M68kCPUListState s = {
> + CPUListState s = {
> .file = f,
> .cpu_fprintf = cpu_fprintf,
> };
Reviewed-By: Igor Mammedov <imammedo@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH qom-cpu v2] cpu: Introduce CPUListState struct
2012-12-19 13:00 ` Igor Mammedov
@ 2012-12-19 13:07 ` Eduardo Habkost
0 siblings, 0 replies; 3+ messages in thread
From: Eduardo Habkost @ 2012-12-19 13:07 UTC (permalink / raw)
To: Igor Mammedov
Cc: Peter Maydell, Paul Brook, Richard Henderson,
Andreas Färber, qemu-devel
On Wed, Dec 19, 2012 at 02:00:32PM +0100, Igor Mammedov wrote:
> On Wed, 19 Dec 2012 02:03:55 +0100
> Andreas Färber <afaerber@suse.de> wrote:
>
> > This generalizes {ARM,M68k,Alpha}CPUListState to avoid declaring it for
> > each target. Place it in cpu-common.h to avoid circular dependencies.
> >
> > Signed-off-by: Andreas Färber <afaerber@suse.de>
> > Cc: Eduardo Habkost <ehabkost@redhat.com>
> > Cc: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> > cpu-common.h | 12 ++++++++++++
> > target-alpha/cpu.c | 9 ++-------
> > target-arm/helper.c | 9 ++-------
> > target-m68k/helper.c | 9 ++-------
> > 4 Dateien geändert, 18 Zeilen hinzugefügt(+), 21 Zeilen entfernt(-)
> >
> > diff --git a/cpu-common.h b/cpu-common.h
> > index d2fbafa..a62b6ea 100644
> > --- a/cpu-common.h
> > +++ b/cpu-common.h
> > @@ -12,6 +12,18 @@
> > #include "bswap.h"
> > #include "qemu-queue.h"
> >
> > +/**
> > + * CPUListState:
> > + * @cpu_fprintf: Print function.
> > + * @file: File to print to using @cpu_fprint.
> > + *
> > + * State commonly used for iterating over CPU models.
> > + */
> > +typedef struct CPUListState {
> > + fprintf_function cpu_fprintf;
> > + FILE *file;
> > +} CPUListState;
> > +
> > #if !defined(CONFIG_USER_ONLY)
> >
> > enum device_endian {
> > diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c
> > index 2deb3c1..59d8669 100644
> > --- a/target-alpha/cpu.c
> > +++ b/target-alpha/cpu.c
> > @@ -33,11 +33,6 @@ static void alpha_cpu_realize(Object *obj, Error **errp)
> > #endif
> > }
> >
> > -typedef struct AlphaCPUListState {
> > - fprintf_function cpu_fprintf;
> > - FILE *file;
> > -} AlphaCPUListState;
> > -
> > /* Sort alphabetically by type name. */
> > static gint alpha_cpu_list_compare(gconstpointer a, gconstpointer b)
> > {
> > @@ -53,7 +48,7 @@ static gint alpha_cpu_list_compare(gconstpointer a,
> > gconstpointer b) static void alpha_cpu_list_entry(gpointer data, gpointer
> > user_data) {
> > ObjectClass *oc = data;
> > - AlphaCPUListState *s = user_data;
> > + CPUListState *s = user_data;
> >
> > (*s->cpu_fprintf)(s->file, " %s\n",
> > object_class_get_name(oc));
> > @@ -61,7 +56,7 @@ static void alpha_cpu_list_entry(gpointer data, gpointer
> > user_data)
> > void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf)
> > {
> > - AlphaCPUListState s = {
> > + CPUListState s = {
> > .file = f,
> > .cpu_fprintf = cpu_fprintf,
> > };
> > diff --git a/target-arm/helper.c b/target-arm/helper.c
> > index ab8b734..d2f2fb4 100644
> > --- a/target-arm/helper.c
> > +++ b/target-arm/helper.c
> > @@ -1291,11 +1291,6 @@ ARMCPU *cpu_arm_init(const char *cpu_model)
> > return cpu;
> > }
> >
> > -typedef struct ARMCPUListState {
> > - fprintf_function cpu_fprintf;
> > - FILE *file;
> > -} ARMCPUListState;
> > -
> > /* Sort alphabetically by type name, except for "any". */
> > static gint arm_cpu_list_compare(gconstpointer a, gconstpointer b)
> > {
> > @@ -1317,7 +1312,7 @@ static gint arm_cpu_list_compare(gconstpointer a,
> > gconstpointer b) static void arm_cpu_list_entry(gpointer data, gpointer
> > user_data) {
> > ObjectClass *oc = data;
> > - ARMCPUListState *s = user_data;
> > + CPUListState *s = user_data;
> >
> > (*s->cpu_fprintf)(s->file, " %s\n",
> > object_class_get_name(oc));
> > @@ -1325,7 +1320,7 @@ static void arm_cpu_list_entry(gpointer data,
> > gpointer user_data)
> > void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf)
> > {
> > - ARMCPUListState s = {
> > + CPUListState s = {
> > .file = f,
> > .cpu_fprintf = cpu_fprintf,
> > };
> > diff --git a/target-m68k/helper.c b/target-m68k/helper.c
> > index a5d0100..875a71a 100644
> > --- a/target-m68k/helper.c
> > +++ b/target-m68k/helper.c
> > @@ -25,11 +25,6 @@
> >
> > #define SIGNBIT (1u << 31)
> >
> > -typedef struct M68kCPUListState {
> > - fprintf_function cpu_fprintf;
> > - FILE *file;
> > -} M68kCPUListState;
> > -
> > /* Sort alphabetically, except for "any". */
> > static gint m68k_cpu_list_compare(gconstpointer a, gconstpointer b)
> > {
> > @@ -51,7 +46,7 @@ static gint m68k_cpu_list_compare(gconstpointer a,
> > gconstpointer b) static void m68k_cpu_list_entry(gpointer data, gpointer
> > user_data) {
> > ObjectClass *c = data;
> > - M68kCPUListState *s = user_data;
> > + CPUListState *s = user_data;
> >
> > (*s->cpu_fprintf)(s->file, "%s\n",
> > object_class_get_name(c));
> > @@ -59,7 +54,7 @@ static void m68k_cpu_list_entry(gpointer data, gpointer
> > user_data)
> > void m68k_cpu_list(FILE *f, fprintf_function cpu_fprintf)
> > {
> > - M68kCPUListState s = {
> > + CPUListState s = {
> > .file = f,
> > .cpu_fprintf = cpu_fprintf,
> > };
>
> Reviewed-By: Igor Mammedov <imammedo@redhat.com>
--
Eduardo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-19 19:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-19 1:03 [Qemu-devel] [PATCH qom-cpu v2] cpu: Introduce CPUListState struct Andreas Färber
2012-12-19 13:00 ` Igor Mammedov
2012-12-19 13:07 ` Eduardo Habkost
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.