]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
DBusMessageIter: ensure contiguous layout with 128-bit pointers
authorAlex Richardson <arichardson@FreeBSD.org>
Sun, 14 Aug 2022 16:31:10 +0000 (16:31 +0000)
committerSimon McVittie <smcv@collabora.com>
Wed, 21 Sep 2022 11:35:05 +0000 (11:35 +0000)
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).

dbus/dbus-message.c
dbus/dbus-message.h

index de355b07b09e1852c80dbeaca2b4f179d71543ec..6f2a518d473f065e1671ca858764921f14663686 100644 (file)
@@ -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
index da2f2d9dee1e1dc1c1dc4449b8bf407f5d3af49c..931917f5692065d1fb2f1ecf8bb1908f2bcbe6f5 100644 (file)
@@ -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);