qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-ppc] [Qemu-devel] [PATCH qom-cpu 3/4] target-ppc: Slim convers


From: Andreas Färber
Subject: Re: [Qemu-ppc] [Qemu-devel] [PATCH qom-cpu 3/4] target-ppc: Slim conversion of model definitions to QOM subclasses
Date: Wed, 19 Dec 2012 03:46:10 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

Am 18.12.2012 08:53, schrieb Andreas Färber:
> +static gint ppc_cpu_compare_class_name(gconstpointer a, gconstpointer b)
> +{
> +    ObjectClass *oc = (ObjectClass *)a;
> +    const char *name = b;
>  
> -    return NULL;
> +    if (strncasecmp(name, object_class_get_name(oc), strlen(name)) == 0 &&
> +        strcmp(object_class_get_name(oc) + strlen(name),
> +               "-" TYPE_POWERPC_CPU) == 0) {
> +        return 0;
> +    }
> +    return -1;
>  }
>  
>  #include <ctype.h>
>  
> -const ppc_def_t *cpu_ppc_find_by_name (const char *name)
> +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);
>      }
> +    g_slist_free(list);
>  
>      return ret;
>  }
[...]
> +static void ppc_cpu_register_model(const ppc_def_t *def)
> +{
> +    TypeInfo type_info = {
> +        .name = def->name,
> +        .parent = TYPE_POWERPC_CPU,
> +        .class_init = ppc_cpu_def_class_init,
> +        .class_data = (void *)def,
> +    };
> +
> +    type_register(&type_info);
>  }

Err, needs the following fix:

diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 908a558..ad0763e 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -10446,13 +10446,14 @@ static void ppc_cpu_def_class_init(ObjectClass
*oc, void *data)
 static void ppc_cpu_register_model(const ppc_def_t *def)
 {
     TypeInfo type_info = {
-        .name = def->name,
         .parent = TYPE_POWERPC_CPU,
         .class_init = ppc_cpu_def_class_init,
         .class_data = (void *)def,
     };

+    type_info.name = g_strdup_printf("%s-" TYPE_POWERPC_CPU, def->name),
     type_register(&type_info);
+    g_free((gpointer)type_info.name);
 }

 /* CPUClass::reset() */

Not sure how I managed to screw this up so badly, seems I tested corner
cases and -cpu host too much...

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]