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 19/39] sh4: simplify superh_cpu_class_by_name()
Date: Fri, 27 Oct 2017 16:20:47 +0200 [thread overview]
Message-ID: <20171027142107.15542-20-ehabkost@redhat.com> (raw)
In-Reply-To: <20171027142107.15542-1-ehabkost@redhat.com>
From: Igor Mammedov <imammedo@redhat.com>
currently for sh4 cpu_model argument for '-cpu' option
could be either 'cpu model' name or cpu_typename.
however typically '-cpu' takes 'cpu model' name and
cpu type for sh4 target isn't advertised publicly
('-cpu help' prints only 'cpu model' names) so we
shouldn't care about this use case (it's more of a bug).
1. Drop '-cpu cpu_typename' to align with the rest of
targets.
2. Compose searched for typename from cpu model and use
it with object_class_by_name() directly instead of
over-complicated
object_class_get_list()
g_slist_find_custom() + superh_cpu_name_compare()
With #1 droped, #2 could be used for both lookups which
simplifies superh_cpu_class_by_name() quite a bit.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1507211474-188400-23-git-send-email-imammedo@redhat.com>
[ehabkost: Include fixup sent by Igor]
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
linux-user/main.c | 2 +-
target/sh4/cpu.c | 34 ++++++++++++----------------------
2 files changed, 13 insertions(+), 23 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 28353f1a75..aa02f25b85 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4331,7 +4331,7 @@ int main(int argc, char **argv, char **envp)
cpu_model = "750";
# endif
#elif defined TARGET_SH4
- cpu_model = TYPE_SH7785_CPU;
+ cpu_model = "sh7785";
#elif defined TARGET_S390X
cpu_model = "qemu";
#else
diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
index ec6db61bdf..972c809d8c 100644
--- a/target/sh4/cpu.c
+++ b/target/sh4/cpu.c
@@ -120,36 +120,26 @@ void sh4_cpu_list(FILE *f, fprintf_function cpu_fprintf)
g_slist_free(list);
}
-static gint superh_cpu_name_compare(gconstpointer a, gconstpointer b)
-{
- const SuperHCPUClass *scc = SUPERH_CPU_CLASS(a);
- const char *name = b;
-
- return strcasecmp(scc->name, name);
-}
-
static ObjectClass *superh_cpu_class_by_name(const char *cpu_model)
{
ObjectClass *oc;
- GSList *list, *item;
+ char *s, *typename = NULL;
- if (strcasecmp(cpu_model, "any") == 0) {
- return object_class_by_name(TYPE_SH7750R_CPU);
+ s = g_ascii_strdown(cpu_model, -1);
+ if (strcmp(s, "any") == 0) {
+ oc = object_class_by_name(TYPE_SH7750R_CPU);
+ goto out;
}
- oc = object_class_by_name(cpu_model);
- if (oc != NULL && object_class_dynamic_cast(oc, TYPE_SUPERH_CPU) != NULL
- && !object_class_is_abstract(oc)) {
- return oc;
+ typename = g_strdup_printf(SUPERH_CPU_TYPE_NAME("%s"), s);
+ oc = object_class_by_name(typename);
+ if (oc != NULL && object_class_is_abstract(oc)) {
+ oc = NULL;
}
- oc = NULL;
- list = object_class_get_list(TYPE_SUPERH_CPU, false);
- item = g_slist_find_custom(list, cpu_model, superh_cpu_name_compare);
- if (item != NULL) {
- oc = item->data;
- }
- g_slist_free(list);
+out:
+ g_free(s);
+ g_free(typename);
return oc;
}
--
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 ` [Qemu-devel] [PULL v2 12/39] moxie: cleanup cpu type name composition Eduardo Habkost
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 ` Eduardo Habkost [this message]
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-20-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).