]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
dbus-message.c: skip 1.10 layout compatibility test on new architectures
authorAlex Richardson <arichardson@FreeBSD.org>
Sun, 14 Aug 2022 16:28:56 +0000 (16:28 +0000)
committerSimon McVittie <smcv@collabora.com>
Wed, 21 Sep 2022 11:35:05 +0000 (11:35 +0000)
These static assertions fail on CHERI-enabled architectures such as Arm
Morello, where pointers are 128 bits. Architectures with 128-bit pointers
were not supported in DBus 1.10, so we can skip the checks for DBus 1.10
structure layout compatibility for architectures with pointer size > 64 bit.

CMakeLists.txt
cmake/ConfigureChecks.cmake
configure.ac
dbus/dbus-arch-deps.h.in
dbus/dbus-message.c
meson.build

index 58ed3d89c0ca106a5ae77166c9593480a187307b..28017a4ec72f00d813b91bb4a8bb95e2c5bf87de 100644 (file)
@@ -735,6 +735,7 @@ message("        cxxflags release:         ${CMAKE_CXX_FLAGS_RELEASE}          "
 message("        64-bit int:               ${DBUS_INT64_TYPE}                  ")
 message("        32-bit int:               ${DBUS_INT32_TYPE}                  ")
 message("        16-bit int:               ${DBUS_INT16_TYPE}                  ")
+message("        pointer size:             ${DBUS_SIZEOF_VOID_P}               ")
 message("        Doxygen:                  ${DOXYGEN}                          ")
 message("        Docbook Generator:        ${DOCBOOK_GENERATOR_NAME}           ")
 
index bb2f021e655e1814784974bb4edc9b8a94b41895..172db213f8e8670e5b83e67097d23e1d6d5a6074 100644 (file)
@@ -84,6 +84,8 @@ int main() {
 }
 " DBUS_USE_SYNC)
 
+set(DBUS_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
+
 check_type_size("short"     SIZEOF_SHORT)
 check_type_size("int"       SIZEOF_INT)
 check_type_size("long"      SIZEOF_LONG)
index 033a1f8ee5ef511fdd0bd35f969b35daf877702c..aee08dc74e660caa30ea8702c328b6df6aa40f63 100644 (file)
@@ -429,13 +429,17 @@ winsock2.h
 ws2tcpip.h
 ])
 
+#### Pointer size
+AC_CHECK_SIZEOF(void *)
+DBUS_SIZEOF_VOID_P=$ac_cv_sizeof_void_p
+AC_SUBST(DBUS_SIZEOF_VOID_P)
+
 #### Integer sizes
 
 AC_CHECK_SIZEOF(char)
 AC_CHECK_SIZEOF(short)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(void *)
 AC_CHECK_SIZEOF(long long)
 AC_CHECK_SIZEOF(__int64)
 
@@ -1706,6 +1710,7 @@ echo "
        64-bit int:               ${DBUS_INT64_TYPE}
        32-bit int:               ${DBUS_INT32_TYPE}
        16-bit int:               ${DBUS_INT16_TYPE}
+       pointer size:             ${DBUS_SIZEOF_VOID_P}
         Doxygen:                  ${DOXYGEN:-not found}
         xmlto:                    ${XMLTO:-not found}
         ducktype:                 ${DUCKTYPE:-not found}
index 2dc5894537a382d06f70cecb615773d735dd994f..7b6328bc785aac754284810fac848f9790760222 100644 (file)
@@ -46,6 +46,8 @@ typedef unsigned @DBUS_INT32_TYPE@ dbus_uint32_t;
 typedef @DBUS_INT16_TYPE@ dbus_int16_t;
 typedef unsigned @DBUS_INT16_TYPE@ dbus_uint16_t;
 
+#define DBUS_SIZEOF_VOID_P @DBUS_SIZEOF_VOID_P@
+
 /* This is not really arch-dependent, but it's not worth
  * creating an additional generated header just for this
  */
index a87043e38a8ec046d713520df45d0fbe4cfa5be3..de355b07b09e1852c80dbeaca2b4f179d71543ec 100644 (file)
@@ -136,6 +136,15 @@ struct DBusMessageRealIter
   } u; /**< the type writer or reader that does all the work */
 };
 
+#if DBUS_SIZEOF_VOID_P > 8
+/*
+ * Architectures with 128-bit pointers were not supported in DBus 1.10, so we
+ * do no check for DBus 1.10 structure layout compatibility for such
+ * architectures (e.g. Arm Morello).
+ */
+#define CHECK_DBUS_1_10_BINARY_COMPATIBILITY 0
+#else
+#define CHECK_DBUS_1_10_BINARY_COMPATIBILITY 1
 /**
  * Layout of a DBusMessageIter on the stack in dbus 1.10.0. This is no
  * longer used, but for ABI compatibility we need to assert that the
@@ -158,6 +167,7 @@ typedef struct
   int pad2;
   void *pad3;
 } DBusMessageIter_1_10_0;
+#endif
 
 static void
 get_const_signature (DBusHeader        *header,
@@ -2069,12 +2079,14 @@ _dbus_message_iter_init_common (DBusMessage         *message,
   _DBUS_STATIC_ASSERT (sizeof (DBusMessageRealIter) <= sizeof (DBusMessageIter));
   _DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (DBusMessageRealIter) <=
       _DBUS_ALIGNOF (DBusMessageIter));
+#if CHECK_DBUS_1_10_BINARY_COMPATIBILITY
   /* A failure of these two assertions would indicate that we've broken
    * ABI on this platform since 1.10.0. */
   _DBUS_STATIC_ASSERT (sizeof (DBusMessageIter_1_10_0) ==
       sizeof (DBusMessageIter));
   _DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (DBusMessageIter_1_10_0) ==
       _DBUS_ALIGNOF (DBusMessageIter));
+#endif
   /* If this static assertion fails, it means the DBusMessageIter struct
    * is not "packed", which might result in "iter = other_iter" not copying
    * every byte. */
index 9103bb0e1bd956493c02f4d5b51df5f47e5c5821..31c6df51ea89a4c389136f0831cdd9e727cf96ff 100644 (file)
@@ -276,6 +276,8 @@ foreach type : int_types
     endif
 endforeach
 
+arch_config.set('DBUS_SIZEOF_VOID_P', cc.sizeof('void *'))
+
 ###############################################################################
 # Dependencies
 
@@ -1195,6 +1197,7 @@ summary_dict += {
     '64-bit int':               arch_config.get('DBUS_INT64_TYPE'),
     '32-bit int':               arch_config.get('DBUS_INT32_TYPE'),
     '16-bit int':               arch_config.get('DBUS_INT16_TYPE'),
+    'pointer size':             arch_config.get('DBUS_SIZEOF_VOID_P'),
     'xsltproc':                 xsltproc.found() ? xsltproc.full_path() : '',
     'Doxygen':                  doxygen.found() ? doxygen.full_path() : '',
     'ducktype':                 ducktype.found() ? ducktype.full_path() : '',