mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
qom: introduce object_class_get_list_sorted
Unify half a dozen copies of very similar code (the only difference being whether comparisons were case-sensitive) and use it also in Tricore, which did not do any sorting of CPU model names. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
819fd4699c
commit
47c66009ab
8 changed files with 30 additions and 65 deletions
|
@ -32,18 +32,6 @@ static void lm32_cpu_set_pc(CPUState *cs, vaddr value)
|
|||
cpu->env.pc = value;
|
||||
}
|
||||
|
||||
/* Sort alphabetically by type name. */
|
||||
static gint lm32_cpu_list_compare(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
ObjectClass *class_a = (ObjectClass *)a;
|
||||
ObjectClass *class_b = (ObjectClass *)b;
|
||||
const char *name_a, *name_b;
|
||||
|
||||
name_a = object_class_get_name(class_a);
|
||||
name_b = object_class_get_name(class_b);
|
||||
return strcmp(name_a, name_b);
|
||||
}
|
||||
|
||||
static void lm32_cpu_list_entry(gpointer data, gpointer user_data)
|
||||
{
|
||||
ObjectClass *oc = data;
|
||||
|
@ -65,8 +53,7 @@ void lm32_cpu_list(FILE *f, fprintf_function cpu_fprintf)
|
|||
};
|
||||
GSList *list;
|
||||
|
||||
list = object_class_get_list(TYPE_LM32_CPU, false);
|
||||
list = g_slist_sort(list, lm32_cpu_list_compare);
|
||||
list = object_class_get_list_sorted(TYPE_LM32_CPU, false);
|
||||
(*cpu_fprintf)(f, "Available CPUs:\n");
|
||||
g_slist_foreach(list, lm32_cpu_list_entry, &s);
|
||||
g_slist_free(list);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue