target-arm: Avoid g_hash_table_get_keys()
PATCH 1/1 target-arm: Avoid g_hash_table_get_keys()
g_hash_table_get_keys() was only introduced in glib 2.14, and we're still targeting a minimum version of 2.12. Rewrite the offending code (introduced in commit 721fae1) to use g_hash_table_foreach() to build the list of keys.
--- target-arm/helper.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
target-arm/helper.c +10 -2
@@ -222,15 +222,23 @@ static gint cpreg_key_compare(gconstpointer a, gconstpointer b)return aidx - bidx; } +static void cpreg_make_keylist (gpointer key,gpointer value,gpointer udata) +{ +GList **plist = udata; + + *plist =g_list_prepend (*plist, key); +} +void init_cpreg_list (ARMCPU *cpu) {/* Initialise the cpreg_tuples[] array based on the cp_regs hash. * Note that we require cpreg_tuples[] to be sorted by key ID. */ -GList *keys; +GList *keys =NULL ;int arraylen; - keys =g_hash_table_get_keys (cpu->cp_regs); +g_hash_table_foreach (cpu->cp_regs, cpreg_make_keylist, &keys); + keys =g_list_sort (keys, cpreg_key_compare); cpu->cpreg_array_len =0 ;
Signature · 1 line
1.7.9.5
Quoted 6 lines · Peter Maydell
g_hash_table_get_keys()was only introduced in glib 2.14, and we're still targeting a minimum version of 2.12. Rewrite the offending code (introduced in commit 721fae1) to useg_hash_table_foreach()to build the list of keys.Signed-off-by Peter Maydell <[email protected]>
Thanks,
Laurent
Quoted 38 lines
--- target-arm/helper.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)target-arm/helper.c +10
-3@@ -222,15 +222,23 @@ static gint cpreg_key_compare(gconstpointer a, gconstpointer b)return aidx - bidx; } +static void cpreg_make_keylist (gpointer key,gpointer value,gpointer udata) +{ +GList **plist = udata; + + *plist =g_list_prepend (*plist, key); +} +void init_cpreg_list (ARMCPU *cpu) {/* Initialise the cpreg_tuples[] array based on the cp_regs hash. * Note that we require cpreg_tuples[] to be sorted by key ID. */ -GList *keys; +GList *keys =NULL ;int arraylen; - keys =g_hash_table_get_keys (cpu->cp_regs); +g_hash_table_foreach (cpu->cp_regs, cpreg_make_keylist, &keys); + keys =g_list_sort (keys, cpreg_key_compare); cpu->cpreg_array_len =0 ; --1.7.9.5
Quoted 6 lines · Peter Maydell
g_hash_table_get_keys()was only introduced in glib 2.14, and we're still targeting a minimum version of 2.12. Rewrite the offending code (introduced in commit 721fae1) to useg_hash_table_foreach()to build the list of keys.Signed-off-by Peter Maydell <[email protected]>
Quoted 38 lines
--- target-arm/helper.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)target-arm/helper.c +10
-3@@ -222,15 +222,23 @@ static gint cpreg_key_compare(gconstpointer a, gconstpointer b)return aidx - bidx; } +static void cpreg_make_keylist (gpointer key,gpointer value,gpointer udata) +{ +GList **plist = udata; + + *plist =g_list_prepend (*plist, key); +} +void init_cpreg_list (ARMCPU *cpu) {/* Initialise the cpreg_tuples[] array based on the cp_regs hash. * Note that we require cpreg_tuples[] to be sorted by key ID. */ -GList *keys; +GList *keys =NULL ;int arraylen; - keys =g_hash_table_get_keys (cpu->cp_regs); +g_hash_table_foreach (cpu->cp_regs, cpreg_make_keylist, &keys); + keys =g_list_sort (keys, cpreg_key_compare); cpu->cpreg_array_len =0 ; --1.7.9.5