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

@@ -1208,7 +1208,7 @@ g_value_set_gtype (GValue *value,
{
g_return_if_fail (G_VALUE_HOLDS_GTYPE (value));
value->data[0].v_pointer = GSIZE_TO_POINTER (v_gtype);
value->data[0].v_pointer = GTYPE_TO_POINTER (v_gtype);
}
@@ -1227,7 +1227,7 @@ g_value_get_gtype (const GValue *value)
{
g_return_val_if_fail (G_VALUE_HOLDS_GTYPE (value), 0);
return GPOINTER_TO_SIZE (value->data[0].v_pointer);
return GPOINTER_TO_TYPE (value->data[0].v_pointer);
}
/**