]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
dbus-marshal-basic: Use _DBUS_ALIGNOF to compare alignments
authorSimon McVittie <smcv@collabora.com>
Wed, 14 Sep 2022 12:32:47 +0000 (13:32 +0100)
committerSimon McVittie <smcv@collabora.com>
Tue, 29 Nov 2022 22:11:07 +0000 (22:11 +0000)
This means we get the alignment comparisons even on non-gcc compilers.

Signed-off-by: Simon McVittie <smcv@collabora.com>
dbus/dbus-marshal-basic.c

index 938e29230d2c963ea6a061b3d322e6d8f94ba2b4..1f5d54a4eedc5505f9ce544d2efc43663be9ec25 100644 (file)
 
 #include <string.h>
 
-#if defined(__GNUC__) && (__GNUC__ >= 4)
-# define _DBUS_ASSERT_ALIGNMENT(type, op, val) \
-  _DBUS_STATIC_ASSERT (__extension__ __alignof__ (type) op val)
-# define _DBUS_ASSERT_CMP_ALIGNMENT(left, op, right) \
-  _DBUS_STATIC_ASSERT (__extension__ __alignof__ (left) op __extension__ __alignof__ (right))
-#else
-  /* not gcc, so probably no alignof operator: just use a no-op statement
-   * that's valid in the same contexts */
-# define _DBUS_ASSERT_ALIGNMENT(type, op, val) \
-  _DBUS_STATIC_ASSERT (TRUE)
-# define _DBUS_ASSERT_CMP_ALIGNMENT(left, op, right) \
-  _DBUS_STATIC_ASSERT (TRUE)
-#endif
+#define _DBUS_ASSERT_ALIGNMENT(type, op, val) \
+  _DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (type) op val)
+#define _DBUS_ASSERT_CMP_ALIGNMENT(left, op, right) \
+  _DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (left) op _DBUS_ALIGNOF (right))
 
 /* True by definition, but just for completeness... */
 _DBUS_STATIC_ASSERT (sizeof (char) == 1);