From: Alex Richardson Date: Sun, 14 Aug 2022 16:31:10 +0000 (+0000) Subject: DBusMessageIter: ensure contiguous layout with 128-bit pointers X-Git-Tag: dbus-1.15.0~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5686f0c24886f7c05be6ce415053a39c9053080;p=thirdparty%2Fdbus.git DBusMessageIter: ensure contiguous layout with 128-bit pointers I am building DBus targeting the Arm Morello board and the "no padding" layout assertion fails here since pointers require 16-byte alignment, and therefore we have to add two additional ints to the DBusMessageIter struct. As this is a new architecture, where DBus previously failed to compiled we do not have any layout backwards compatibility requirements, so we can simplify the DBusMessageIter structure to allocate space for 16 pointers (which should give us a lot of space for any further changes). --- diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index de355b07b..6f2a518d4 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -2090,8 +2090,12 @@ _dbus_message_iter_init_common (DBusMessage *message, /* If this static assertion fails, it means the DBusMessageIter struct * is not "packed", which might result in "iter = other_iter" not copying * every byte. */ +#if DBUS_SIZEOF_VOID_P > 8 + _DBUS_STATIC_ASSERT (sizeof (DBusMessageIter) == 16 * sizeof (void *)); +#else _DBUS_STATIC_ASSERT (sizeof (DBusMessageIter) == 4 * sizeof (void *) + sizeof (dbus_uint32_t) + 9 * sizeof (int)); +#endif /* Since the iterator will read or write who-knows-what from the * message, we need to get in the right byte order diff --git a/dbus/dbus-message.h b/dbus/dbus-message.h index da2f2d9de..931917f56 100644 --- a/dbus/dbus-message.h +++ b/dbus/dbus-message.h @@ -59,7 +59,10 @@ typedef struct DBusMessageIter DBusMessageIter; * DBusMessageIter struct; contains no public fields. */ struct DBusMessageIter -{ +{ +#if DBUS_SIZEOF_VOID_P > 8 + void *dummy[16]; /**< Don't use this */ +#else void *dummy1; /**< Don't use this */ void *dummy2; /**< Don't use this */ dbus_uint32_t dummy3; /**< Don't use this */ @@ -74,12 +77,24 @@ struct DBusMessageIter int pad1; /**< Don't use this */ void *pad2; /**< Don't use this */ void *pad3; /**< Don't use this */ +#endif }; /** * A message iterator for which dbus_message_iter_abandon_container_if_open() * is the only valid operation. */ +#if DBUS_SIZEOF_VOID_P > 8 +#define DBUS_MESSAGE_ITER_INIT_CLOSED \ +{ \ + { \ + NULL, NULL, NULL, NULL, \ + NULL, NULL, NULL, NULL, \ + NULL, NULL, NULL, NULL, \ + NULL, NULL, NULL, NULL \ + } \ +} +#else #define DBUS_MESSAGE_ITER_INIT_CLOSED \ { \ NULL, /* dummy1 */ \ @@ -97,6 +112,7 @@ struct DBusMessageIter NULL, /* pad2 */ \ NULL /* pad3 */ \ } +#endif DBUS_EXPORT DBusMessage* dbus_message_new (int message_type);