summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.in2
-rw-r--r--dbus/dbus-marshal-basic.h18
2 files changed, 20 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index c2c6a8c9..036679ce 100644
--- a/configure.in
+++ b/configure.in
@@ -679,6 +679,8 @@ AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)])
AC_CHECK_HEADERS(errno.h)
+AC_CHECK_HEADERS(byteswap.h)
+
AC_CHECK_HEADERS(unistd.h)
# checking for a posix version of getpwnam_r
diff --git a/dbus/dbus-marshal-basic.h b/dbus/dbus-marshal-basic.h
index bcc15ee9..f09c5208 100644
--- a/dbus/dbus-marshal-basic.h
+++ b/dbus/dbus-marshal-basic.h
@@ -26,6 +26,11 @@
#define DBUS_MARSHAL_BASIC_H
#include <config.h>
+
+#ifdef HAVE_BYTESWAP_H
+#include <byteswap.h>
+#endif
+
#include <dbus/dbus-protocol.h>
#include <dbus/dbus-types.h>
#include <dbus/dbus-arch-deps.h>
@@ -37,6 +42,11 @@
#define DBUS_COMPILER_BYTE_ORDER DBUS_LITTLE_ENDIAN
#endif
+#ifdef HAVE_BYTESWAP_H
+#define DBUS_UINT16_SWAP_LE_BE_CONSTANT(val) bswap_16(val)
+#define DBUS_UINT32_SWAP_LE_BE_CONSTANT(val) bswap_32(val)
+#else /* HAVE_BYTESWAP_H */
+
#define DBUS_UINT16_SWAP_LE_BE_CONSTANT(val) ((dbus_uint16_t) ( \
(dbus_uint16_t) ((dbus_uint16_t) (val) >> 8) | \
(dbus_uint16_t) ((dbus_uint16_t) (val) << 8)))
@@ -47,8 +57,14 @@
(((dbus_uint32_t) (val) & (dbus_uint32_t) 0x00ff0000U) >> 8) | \
(((dbus_uint32_t) (val) & (dbus_uint32_t) 0xff000000U) >> 24)))
+#endif /* HAVE_BYTESWAP_H */
+
#ifdef DBUS_HAVE_INT64
+#ifdef HAVE_BYTESWAP_H
+#define DBUS_UINT64_SWAP_LE_BE_CONSTANT(val) bswap_64(val)
+#else /* HAVE_BYTESWAP_H */
+
#define DBUS_UINT64_SWAP_LE_BE_CONSTANT(val) ((dbus_uint64_t) ( \
(((dbus_uint64_t) (val) & \
(dbus_uint64_t) DBUS_UINT64_CONSTANT (0x00000000000000ff)) << 56) | \
@@ -68,6 +84,8 @@
(dbus_uint64_t) DBUS_UINT64_CONSTANT (0xff00000000000000)) >> 56)))
#endif /* DBUS_HAVE_INT64 */
+#endif /* HAVE_BYTESWAP_H */
+
#define DBUS_UINT16_SWAP_LE_BE(val) (DBUS_UINT16_SWAP_LE_BE_CONSTANT (val))
#define DBUS_INT16_SWAP_LE_BE(val) ((dbus_int16_t)DBUS_UINT16_SWAP_LE_BE_CONSTANT (val))