From a108d1e308bd5e0b8846a4c5d8ffac8a451b73f0 Mon Sep 17 00:00:00 2001 From: Junior Martinez Date: Wed, 10 May 2023 15:22:41 +0000 Subject: [PATCH] Pull request #765: Inet implementations assume BYTE_ORDER is defined. make sure that it is (#26460) Merge in WMN_TOOLS/matter from cherry-pick/Fix_multicast_addr_endianness to RC_2.0.0-1.1 Squashed commit of the following: commit 50f8a0590cfbfb2c0d69798efb641c4d4de1a7c2 Author: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Wed May 10 09:24:21 2023 -0400 Inet implementations assume BYTE_ORDER is defined. make sure that it is (#26460) * BYTE_ORDER must be defined in the project * fix typo * Remove BYTE_ORDER from the file. Only use __BYTE_ORDER__ and relative checks * Apply suggestions from code review Co-authored-by: Boris Zbarsky --------- Co-authored-by: Boris Zbarsky --- src/inet/arpa-inet-compatibility.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/inet/arpa-inet-compatibility.h b/src/inet/arpa-inet-compatibility.h index 25f9792893ecd8..56d9121e40d5ae 100644 --- a/src/inet/arpa-inet-compatibility.h +++ b/src/inet/arpa-inet-compatibility.h @@ -26,7 +26,6 @@ #else // !CHIP_SYSTEM_CONFIG_USE_SOCKETS #if CHIP_SYSTEM_CONFIG_USE_LWIP - #include #include @@ -49,7 +48,11 @@ #if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT -#if BYTE_ORDER == BIG_ENDIAN +#ifndef __BYTE_ORDER__ +#error Endianness is not defined +#endif // BYTE_ORDER + +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #ifndef htons #define htons(x) (x) #endif @@ -63,7 +66,7 @@ #define ntohl(x) (x) #endif -#else // BYTE_ORDER != BIG_ENDIAN +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #ifndef htons #define htons(x) ((u16_t)((((x) & (u16_t) 0x00ffU) << 8) | (((x) & (u16_t) 0xff00U) >> 8))) #endif @@ -78,7 +81,10 @@ #ifndef ntohl #define ntohl(x) htonl(x) #endif -#endif // BYTE_ORDER == BIG_ENDIAN + +#else +#error __BYTE_ORDER__ value not recognized +#endif // __BYTE_ORDER__ == #endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT