Make GVariantBuilder and GVariantDict layout compatible with CHERI

Use guinptr instead if gsize. While this increases the structure size
for Morello, it is still only 256 bytes which should not matter for a
type where we expect few instances to exist at any given time.
This does not increase the size for existing architectures since gsize
is the same as guintptr for all of them.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
This commit is contained in:
Alex Richardson 2022-12-14 23:55:18 +00:00
parent 2aed76fc94
commit 5d8ecac1ec
2 changed files with 6 additions and 6 deletions

View File

@ -3220,7 +3220,7 @@ struct heap_builder
/* Just to make sure that by adding a union to GVariantBuilder, we
* didn't accidentally change ABI. */
G_STATIC_ASSERT (sizeof (GVariantBuilder) == sizeof (gsize[16]));
G_STATIC_ASSERT (sizeof (GVariantBuilder) == sizeof (guintptr[16]));
static gboolean
ensure_valid_builder (GVariantBuilder *builder)
@ -3907,7 +3907,7 @@ struct heap_dict
/* Just to make sure that by adding a union to GVariantDict, we didn't
* accidentally change ABI. */
G_STATIC_ASSERT (sizeof (GVariantDict) == sizeof (gsize[16]));
G_STATIC_ASSERT (sizeof (GVariantDict) == sizeof (guintptr[16]));
static gboolean
ensure_valid_dict (GVariantDict *dict)

View File

@ -304,9 +304,9 @@ struct _GVariantBuilder {
struct {
gsize partial_magic;
const GVariantType *type;
gsize y[14];
guintptr y[14];
} s;
gsize x[16];
guintptr x[16];
} u;
};
@ -453,9 +453,9 @@ struct _GVariantDict {
struct {
GVariant *asv;
gsize partial_magic;
gsize y[14];
guintptr y[14];
} s;
gsize x[16];
guintptr x[16];
} u;
};