Fix: use the correct endian compat macros
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 16 Mar 2022 15:40:52 +0000 (11:40 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 17 Mar 2022 17:15:50 +0000 (13:15 -0400)
Document which variant of the endian macros our compat header guarantees
across all platforms and fix incorrect uses.

This was discovered with -Wundef on macOS.

Change-Id: Iaf442fe5887063661273ac2a00c9fa4015e83d5c
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/compat/endian.h
src/common/hashtable/utils.cpp
src/vendor/msgpack/lttng-config.h

index 752d8a7316a09631318f5940d22ffe009c923303..ff383763461f19e32d76439275755f27524ea5a3 100644 (file)
@@ -5,6 +5,35 @@
  *
  */
 
+/*
+ * This compat header provides the following defines:
+ *
+ *  LITTLE_ENDIAN
+ *  BIG_ENDIAN
+ *  BYTE_ORDER
+ *
+ * And functions / macros :
+ *
+ *  bswap_16()
+ *  bswap_32()
+ *  bswap_64()
+ *
+ *  htobe16()
+ *  htole16()
+ *  be16toh()
+ *  le16toh()
+ *
+ *  htobe32()
+ *  htole32()
+ *  be32toh()
+ *  le32toh()
+ *
+ *  htobe64()
+ *  htole64()
+ *  be64toh()
+ *  le64toh()
+ */
+
 #ifndef _COMPAT_ENDIAN_H
 #define _COMPAT_ENDIAN_H
 
 
 #define LITTLE_ENDIAN  __LITTLE_ENDIAN
 #define BIG_ENDIAN     __BIG_ENDIAN
-#define PDP_ENDIAN     __PDP_ENDIAN
 #define BYTE_ORDER     __BYTE_ORDER
 
 #define betoh16(x) BE_16(x)
index ae34767f0b4020ec466f85555bef4c4fca01b72e..4c6a5d13ec47bd26b7d1d427278937b6829a860e 100644 (file)
  * My best guess at if you are big-endian or little-endian.  This may
  * need adjustment.
  */
-#if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \
-     __BYTE_ORDER == __LITTLE_ENDIAN) || \
+#if (defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && \
+     BYTE_ORDER == LITTLE_ENDIAN) || \
     (defined(i386) || defined(__i386__) || defined(__i486__) || \
      defined(__i586__) || defined(__i686__) || defined(vax) || defined(MIPSEL))
 # define HASH_LITTLE_ENDIAN 1
 # define HASH_BIG_ENDIAN 0
-#elif (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && \
-       __BYTE_ORDER == __BIG_ENDIAN) || \
+#elif (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && \
+       BYTE_ORDER == BIG_ENDIAN) || \
       (defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel))
 # define HASH_LITTLE_ENDIAN 0
 # define HASH_BIG_ENDIAN 1
index 62258233df24ef6d12348141afee8ecfdaaff74e..54b14682e4f24419d67faa0201171a0673aea052 100644 (file)
@@ -11,9 +11,9 @@
 #include <limits.h>
 #include <common/compat/endian.h>
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
 #define MSGPACK_ENDIAN_LITTLE_BYTE 1
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#elif BYTE_ORDER == BIG_ENDIAN
 #define MSGPACK_ENDIAN_BIG_BYTE 1
 #endif
 
This page took 0.027174 seconds and 4 git commands to generate.