From: Michael Jeanson Date: Wed, 16 Mar 2022 15:40:52 +0000 (-0400) Subject: Fix: use the correct endian compat macros X-Git-Tag: v2.13.5~3 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=be7cb59d8b60a2b9172b37ed0ece3f6f7920ed5d;p=lttng-tools.git Fix: use the correct endian compat macros 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 Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/compat/endian.h b/src/common/compat/endian.h index 752d8a731..ff3837634 100644 --- a/src/common/compat/endian.h +++ b/src/common/compat/endian.h @@ -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 @@ -128,7 +157,6 @@ #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) diff --git a/src/common/hashtable/utils.c b/src/common/hashtable/utils.c index ef0807e6e..c119770b4 100644 --- a/src/common/hashtable/utils.c +++ b/src/common/hashtable/utils.c @@ -57,14 +57,14 @@ * 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 diff --git a/src/vendor/msgpack/lttng-config.h b/src/vendor/msgpack/lttng-config.h index 62258233d..54b14682e 100644 --- a/src/vendor/msgpack/lttng-config.h +++ b/src/vendor/msgpack/lttng-config.h @@ -11,9 +11,9 @@ #include #include -#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