GType: introduce GTYPE_TO_POINTER/GPOINTER_TO_TYPE

On CHERI-enabled systems we use uintptr_t as the underlying storage for
GType and therefore casting to gsize strips the upper bits from a pointer.
Fix this by casting via uintptr_t instead and introduce a new set of
macros to convert between GType and pointers.
This commit is contained in:
Alex Richardson
2022-12-14 23:55:19 +00:00
committed by Philip Withnall
parent 4b111f1650
commit d0e03f0930
9 changed files with 53 additions and 16 deletions

View File

@@ -422,7 +422,7 @@ type_node_any_new_W (TypeNode *pnode,
#endif
}
else
type = (GType) node;
type = GPOINTER_TO_TYPE (node);
g_assert ((type & TYPE_ID_MASK) == 0);
@@ -497,7 +497,7 @@ type_node_any_new_W (TypeNode *pnode,
node->global_gdata = NULL;
g_hash_table_insert (static_type_nodes_ht,
(gpointer) g_quark_to_string (node->qname),
(gpointer) type);
GTYPE_TO_POINTER (type));
g_atomic_int_inc ((gint *)&type_registration_serial);
@@ -3444,7 +3444,7 @@ g_type_from_name (const gchar *name)
g_return_val_if_fail (name != NULL, 0);
G_READ_LOCK (&type_rw_lock);
type = (GType) g_hash_table_lookup (static_type_nodes_ht, name);
type = GPOINTER_TO_TYPE (g_hash_table_lookup (static_type_nodes_ht, name));
G_READ_UNLOCK (&type_rw_lock);
return type;