summaryrefslogtreecommitdiff
path: root/dbus
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2022-08-14 16:31:10 +0000
committerSimon McVittie <smcv@collabora.com>2022-09-21 11:35:05 +0000
commitc5686f0c24886f7c05be6ce415053a39c9053080 (patch)
tree791d45d5f3983157d19d98d05075e815764811d5 /dbus
parent6933a9263e30e2dbfb36a038660b9387ee632d32 (diff)
downloaddbus-c5686f0c24886f7c05be6ce415053a39c9053080.tar.gz
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).
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-message.c4
-rw-r--r--dbus/dbus-message.h18
2 files changed, 21 insertions, 1 deletions
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index de355b07..6f2a518d 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 da2f2d9d..931917f5 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);