From 4db378a739095ff47fb9535f4221a3abbeed4aac Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 30 Sep 2024 11:37:44 -0700 Subject: [PATCH] gvariant: Add portable alignment fix for GVariant suffix We want to keep the suffix aligned to 8 bytes on 32-bit too. This makes sure we do that in a way that is portable across our supported compilers. Fixes: #3486 --- glib/gvariant-core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/glib/gvariant-core.c b/glib/gvariant-core.c index f530fa311..4ee62889b 100644 --- a/glib/gvariant-core.c +++ b/glib/gvariant-core.c @@ -76,13 +76,12 @@ struct _GVariant gatomicrefcount ref_count; gsize depth; -#if g_macro__has_attribute(aligned) - guint8 suffix[] __attribute__((aligned(8))); -#elif defined _MSC_VER - __declspec(align (8)) guint8 suffix[]; -#else - guint8 suffix[]; +#if GLIB_SIZEOF_VOID_P == 4 + /* Keep suffix aligned to 8 bytes */ + guint _padding; #endif + + guint8 suffix[]; }; /* Ensure our suffix data aligns to largest guaranteed offset