From: Eduardo Habkost <ehabkost@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Igor Mammedov <imammedo@redhat.com>
Subject: [Qemu-devel] [PULL v2 12/39] moxie: cleanup cpu type name composition
Date: Fri, 27 Oct 2017 16:20:40 +0200 [thread overview]
Message-ID: <20171027142107.15542-13-ehabkost@redhat.com> (raw)
In-Reply-To: <20171027142107.15542-1-ehabkost@redhat.com>
From: Igor Mammedov <imammedo@redhat.com>
introduce MOXIE_CPU_TYPE_NAME macro and consistently use it
to construct cpu type names. While at it replace dynamic
cpu type name composition with static data.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1507211474-188400-16-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target/moxie/cpu.h | 3 +++
target/moxie/cpu.c | 56 +++++++++++++++++-------------------------------------
2 files changed, 20 insertions(+), 39 deletions(-)
diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h
index 75decaadd6..d37e6a5572 100644
--- a/target/moxie/cpu.h
+++ b/target/moxie/cpu.h
@@ -122,6 +122,9 @@ int cpu_moxie_signal_handler(int host_signum, void *pinfo,
#define cpu_init(cpu_model) cpu_generic_init(TYPE_MOXIE_CPU, cpu_model)
+#define MOXIE_CPU_TYPE_SUFFIX "-" TYPE_MOXIE_CPU
+#define MOXIE_CPU_TYPE_NAME(model) model MOXIE_CPU_TYPE_SUFFIX
+
#define cpu_signal_handler cpu_moxie_signal_handler
static inline int cpu_mmu_index(CPUMoxieState *env, bool ifetch)
diff --git a/target/moxie/cpu.c b/target/moxie/cpu.c
index 44441b2cf2..f1389e5097 100644
--- a/target/moxie/cpu.c
+++ b/target/moxie/cpu.c
@@ -86,7 +86,7 @@ static ObjectClass *moxie_cpu_class_by_name(const char *cpu_model)
ObjectClass *oc;
char *typename;
- typename = g_strdup_printf("%s-" TYPE_MOXIE_CPU, cpu_model);
+ typename = g_strdup_printf(MOXIE_CPU_TYPE_NAME("%s"), cpu_model);
oc = object_class_by_name(typename);
g_free(typename);
if (oc != NULL && (!object_class_dynamic_cast(oc, TYPE_MOXIE_CPU) ||
@@ -134,46 +134,24 @@ static void moxie_any_initfn(Object *obj)
/* Set cpu feature flags */
}
-typedef struct MoxieCPUInfo {
- const char *name;
- void (*initfn)(Object *obj);
-} MoxieCPUInfo;
-
-static const MoxieCPUInfo moxie_cpus[] = {
- { .name = "MoxieLite", .initfn = moxielite_initfn },
- { .name = "any", .initfn = moxie_any_initfn },
-};
+#define DEFINE_MOXIE_CPU_TYPE(cpu_model, initfn) \
+ { \
+ .parent = TYPE_MOXIE_CPU, \
+ .instance_init = initfn, \
+ .name = MOXIE_CPU_TYPE_NAME(cpu_model), \
+ }
-static void cpu_register(const MoxieCPUInfo *info)
-{
- TypeInfo type_info = {
- .parent = TYPE_MOXIE_CPU,
+static const TypeInfo moxie_cpus_type_infos[] = {
+ { /* base class should be registered first */
+ .name = TYPE_MOXIE_CPU,
+ .parent = TYPE_CPU,
.instance_size = sizeof(MoxieCPU),
- .instance_init = info->initfn,
+ .instance_init = moxie_cpu_initfn,
.class_size = sizeof(MoxieCPUClass),
- };
-
- type_info.name = g_strdup_printf("%s-" TYPE_MOXIE_CPU, info->name);
- type_register(&type_info);
- g_free((void *)type_info.name);
-}
-
-static const TypeInfo moxie_cpu_type_info = {
- .name = TYPE_MOXIE_CPU,
- .parent = TYPE_CPU,
- .instance_size = sizeof(MoxieCPU),
- .instance_init = moxie_cpu_initfn,
- .class_size = sizeof(MoxieCPUClass),
- .class_init = moxie_cpu_class_init,
+ .class_init = moxie_cpu_class_init,
+ },
+ DEFINE_MOXIE_CPU_TYPE("MoxieLite", moxielite_initfn),
+ DEFINE_MOXIE_CPU_TYPE("any", moxie_any_initfn),
};
-static void moxie_cpu_register_types(void)
-{
- int i;
- type_register_static(&moxie_cpu_type_info);
- for (i = 0; i < ARRAY_SIZE(moxie_cpus); i++) {
- cpu_register(&moxie_cpus[i]);
- }
-}
-
-type_init(moxie_cpu_register_types)
+DEFINE_TYPES(moxie_cpus_type_infos)
--
2.13.6
next prev parent reply other threads:[~2017-10-27 14:22 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-27 14:20 [Qemu-devel] [PULL v2 00/39] x86/cpu/numa queue, 2017-10-27 Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 01/39] alpha: cleanup cpu type name composition Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 02/39] alpha: use generic cpu_model parsing Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 03/39] cris: cleanup cpu type name composition Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 04/39] cris: use generic cpu_model parsing Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 05/39] lm32: cleanup cpu type name composition Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 06/39] lm32: milkymist: use generic cpu_model parsing Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 07/39] lm32: lm32_boards: " Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 08/39] m68k: cleanup cpu type name composition Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 09/39] m68k: an5206: use generic cpu_model parsing Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 10/39] m68k: mcf5208: " Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 11/39] moxie: fix qemu-system-moxie failing to start with CLI "-cpu MoxieLite" Eduardo Habkost
2017-10-27 14:20 ` Eduardo Habkost [this message]
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 13/39] moxie: use generic cpu_model parsing Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 14/39] openrisc: cleanup cpu type name composition Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 15/39] openrisc: use generic cpu_model parsing Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 16/39] sh4: r2d: " Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 17/39] sh4: shix: " Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 18/39] sh4: cleanup cpu type name composition Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 19/39] sh4: simplify superh_cpu_class_by_name() Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 20/39] sh4: remove SuperHCPUClass::name field Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 21/39] xtensa: cleanup cpu type name composition Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 22/39] xtensa: sim: use generic cpu_model parsing Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 23/39] xtensa: lx60/lx200/ml605/kc705: " Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 24/39] unicore32: cleanup cpu type name composition Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 25/39] unicore32: use generic cpu_model parsing Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 26/39] tricore: cleanup cpu type name composition Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 27/39] tricore: use generic cpu_model parsing Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 28/39] sparc: cleanup cpu type name composition Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 29/39] sparc: sun4u/sun4v/niagara: use generic cpu_model parsing Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 30/39] sparc: sparc: " Eduardo Habkost
2017-10-27 14:20 ` [Qemu-devel] [PULL v2 31/39] sparc: leon3: " Eduardo Habkost
2017-10-27 14:21 ` [Qemu-devel] [PULL v2 32/39] mips: use object_new() instead of gnew()+object_initialize() Eduardo Habkost
2017-10-27 14:21 ` [Qemu-devel] [PULL v2 33/39] mips: malta/boston: replace cpu_model with cpu_type Eduardo Habkost
2017-10-27 14:21 ` [Qemu-devel] [PULL v2 34/39] mips: fulong2e: " Eduardo Habkost
2017-10-27 14:21 ` [Qemu-devel] [PULL v2 35/39] mips: Magnum/Acer Pica 61: " Eduardo Habkost
2017-10-27 14:21 ` [Qemu-devel] [PULL v2 36/39] mips: mipssim: " Eduardo Habkost
2017-10-27 14:21 ` [Qemu-devel] [PULL v2 37/39] mips: r4k: " Eduardo Habkost
2017-10-27 14:21 ` [Qemu-devel] [PULL v2 38/39] numa: fixup parsed NumaNodeOptions earlier Eduardo Habkost
2017-10-27 14:21 ` [Qemu-devel] [PULL v2 39/39] x86: Skip check apic_id_limit for Xen Eduardo Habkost
2017-10-30 11:16 ` [Qemu-devel] [PULL v2 00/39] x86/cpu/numa queue, 2017-10-27 Peter Maydell
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=20171027142107.15542-13-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=peter.maydell@linaro.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).