diff options
author | Kohei Tokunaga <ktokunaga.mail@gmail.com> | 2025-04-28 15:38:54 +0900 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-05-06 16:02:04 +0200 |
commit | 84cb7025fa9378993dbd6242ab2c3fa556ed2a2c (patch) | |
tree | f43ad1e4772776d8a29b361ff2dcb4d4066945c4 | |
parent | 44d3ec593b0afd2f8cfaf2ba2149465ee3541695 (diff) | |
download | qemu-84cb7025fa9378993dbd6242ab2c3fa556ed2a2c.zip qemu-84cb7025fa9378993dbd6242ab2c3fa556ed2a2c.tar.gz qemu-84cb7025fa9378993dbd6242ab2c3fa556ed2a2c.tar.bz2 |
target/i386/cpu.c: Fix type conflict of GLib function pointers
On Emscripten, function pointer casts can result in runtime failures due to
strict function signature checks. This affects the use of g_list_sort and
g_slist_sort, which internally perform function pointer casts that are not
supported by Emscripten. To avoid these issues, g_list_sort_with_data and
g_slist_sort_with_data should be used instead, as they do not rely on
function pointer casting.
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
Link: https://lore.kernel.org/r/8ee6c2b02c97d5db358c3eb290d00afe71d1ceb7.1745820062.git.ktokunaga.mail@gmail.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | target/i386/cpu.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6f21d5e..1ca6307 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6240,7 +6240,7 @@ static void listflags(GList *features) } /* Sort alphabetically by type name, respecting X86CPUClass::ordering. */ -static gint x86_cpu_list_compare(gconstpointer a, gconstpointer b) +static gint x86_cpu_list_compare(gconstpointer a, gconstpointer b, gpointer d) { ObjectClass *class_a = (ObjectClass *)a; ObjectClass *class_b = (ObjectClass *)b; @@ -6261,7 +6261,7 @@ static gint x86_cpu_list_compare(gconstpointer a, gconstpointer b) static GSList *get_sorted_cpu_model_list(void) { GSList *list = object_class_get_list(TYPE_X86_CPU, false); - list = g_slist_sort(list, x86_cpu_list_compare); + list = g_slist_sort_with_data(list, x86_cpu_list_compare, NULL); return list; } @@ -6318,6 +6318,11 @@ static void x86_cpu_list_entry(gpointer data, gpointer user_data) qemu_printf(" %-20s %s\n", name, desc); } +static gint strcmp_wrap(gconstpointer a, gconstpointer b, gpointer d) +{ + return strcmp(a, b); +} + /* list available CPU models and flags */ static void x86_cpu_list(void) { @@ -6340,7 +6345,7 @@ static void x86_cpu_list(void) } } - names = g_list_sort(names, (GCompareFunc)strcmp); + names = g_list_sort_with_data(names, strcmp_wrap, NULL); qemu_printf("\nRecognized CPUID flags:\n"); listflags(names); |