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

@@ -1175,7 +1175,7 @@ g_signal_type_cclosure_new (GType itype,
g_return_val_if_fail (G_TYPE_IS_CLASSED (itype) || G_TYPE_IS_INTERFACE (itype), NULL);
g_return_val_if_fail (struct_offset >= sizeof (GTypeClass), NULL);
closure = g_closure_new_simple (sizeof (GClosure), (gpointer) itype);
closure = g_closure_new_simple (sizeof (GClosure), GTYPE_TO_POINTER (itype));
if (G_TYPE_IS_INTERFACE (itype))
{
g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_iface_meta_marshal);