[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 36/40] ppc: replace inter-function cyclic dependency/re
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 36/40] ppc: replace inter-function cyclic dependency/recurssion with 2 simple lookups |
Date: |
Fri, 8 Sep 2017 20:35:54 +1000 |
From: Igor Mammedov <address@hidden>
previous patches cleaned up cpu model/alias naming which
allows to simplify cpu model/alias to cpu type lookup a bit
byt removing recurssion and dependency of ppc_cpu_class_by_name() /
ppc_cpu_class_by_alias() on each other.
Besides of simplifying code it reduces it by ~15LOC.
Signed-off-by: Igor Mammedov <address@hidden>
Reviewed-by: David Gibson <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
target/ppc/translate_init.c | 43 +++++++++++++------------------------------
1 file changed, 13 insertions(+), 30 deletions(-)
diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c
index f392fa6ea9..4092310c83 100644
--- a/target/ppc/translate_init.c
+++ b/target/ppc/translate_init.c
@@ -10252,22 +10252,6 @@ PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t
pvr)
return pcc;
}
-static gint ppc_cpu_compare_class_name(gconstpointer a, gconstpointer b)
-{
- ObjectClass *oc = (ObjectClass *)a;
- const char *name = b;
- PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
-
- if (strncasecmp(name, object_class_get_name(oc), strlen(name)) == 0 &&
- ppc_cpu_is_valid(pcc) &&
- strcmp(object_class_get_name(oc) + strlen(name),
- POWERPC_CPU_TYPE_SUFFIX) == 0) {
- return 0;
- }
- return -1;
-}
-
-
static ObjectClass *ppc_cpu_class_by_name(const char *name);
static ObjectClass *ppc_cpu_class_by_alias(PowerPCCPUAlias *alias)
@@ -10292,8 +10276,8 @@ static ObjectClass
*ppc_cpu_class_by_alias(PowerPCCPUAlias *alias)
static ObjectClass *ppc_cpu_class_by_name(const char *name)
{
- GSList *list, *item;
- ObjectClass *ret = NULL;
+ char *cpu_model, *typename;
+ ObjectClass *oc;
const char *p;
int i, len;
@@ -10314,21 +10298,20 @@ static ObjectClass *ppc_cpu_class_by_name(const char
*name)
}
}
- list = object_class_get_list(TYPE_POWERPC_CPU, false);
- item = g_slist_find_custom(list, name, ppc_cpu_compare_class_name);
- if (item != NULL) {
- ret = OBJECT_CLASS(item->data);
+ cpu_model = g_ascii_strdown(name, -1);
+ p = ppc_cpu_lookup_alias(cpu_model);
+ if (p) {
+ g_free(cpu_model);
+ cpu_model = g_strdup(p);
}
- g_slist_free(list);
- if (ret) {
- return ret;
- }
+ typename = g_strdup_printf("%s" POWERPC_CPU_TYPE_SUFFIX, cpu_model);
+ oc = object_class_by_name(typename);
+ g_free(typename);
+ g_free(cpu_model);
- for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
- if (strcasecmp(ppc_cpu_aliases[i].alias, name) == 0) {
- return ppc_cpu_class_by_alias(&ppc_cpu_aliases[i]);
- }
+ if (oc && ppc_cpu_is_valid(POWERPC_CPU_CLASS(oc))) {
+ return oc;
}
return NULL;
--
2.13.5
- [Qemu-ppc] [PULL 21/40] spapr_iommu: Realloc guest visible TCE table when hot(un)plugging vfio-pci, (continued)
- [Qemu-ppc] [PULL 21/40] spapr_iommu: Realloc guest visible TCE table when hot(un)plugging vfio-pci, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 16/40] ppc: spapr: Make VCPU ID handling private to SPAPR, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 23/40] ppc4xx: Make MAL emulation more generic, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 13/40] spapr: add pseries-2.11 machine type, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 29/40] hw/nvram/spapr_nvram: Device can not be created by the users, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 27/40] ppc4xx: Export ECB and PLB emulation, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 28/40] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 24/40] ppc4xx: Split off 4xx I2C emulation from ppc405_uc to its own file, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 26/40] ppc4xx_i2c: Move to hw/i2c, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 25/40] ppc4xx_i2c: QOMify, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 36/40] ppc: replace inter-function cyclic dependency/recurssion with 2 simple lookups,
David Gibson <=
- [Qemu-ppc] [PULL 40/40] ppc: spapr: Move VCPU ID calculation into sPAPR, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 31/40] PPC: KVM: Support machine option to set VSMT mode, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 33/40] ppc: use macros to make cpu type name from string literal, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 32/40] target/ppc: Remove old STATUS file, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 39/40] ppc: remove non implemented cpu models, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 30/40] spapr: fallback to raw mode if best compat mode cannot be set during CAS, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 37/40] ppc: simplify cpu model lookup by PVR, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 35/40] ppc: make cpu alias point only to real cpu models, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 38/40] ppc: drop caching ObjectClass from PowerPCCPUAlias, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 22/40] ppc4xx: Move MAL from ppc405_uc to ppc4xx_devs, David Gibson, 2017/09/08