Skip to content

Commit

Permalink
Remove BYTE_ORDER from the file. Only use __BYTE_ORDER__ and relative…
Browse files Browse the repository at this point in the history
… checks
  • Loading branch information
jmartinez-silabs committed May 10, 2023
1 parent 58d9277 commit 7d09a84
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions src/inet/arpa-inet-compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,12 @@
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS
#include <arpa/inet.h>

#ifndef BYTE_ORDER
#error Endianness not defined
#endif

#else // !CHIP_SYSTEM_CONFIG_USE_SOCKETS

#if CHIP_SYSTEM_CONFIG_USE_LWIP
#include <lwip/def.h>
#include <lwip/opt.h>

#ifndef BYTE_ORDER
#error Endianness not defined
#endif

#if defined(LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS)
#ifndef htons
#define htons(x) lwip_htons(x)
Expand All @@ -56,27 +48,11 @@

#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT

#ifndef BYTE_ORDER
#if defined(__LITTLE_ENDIAN__)
#define BYTE_ORDER LITTLE_ENDIAN
#elif defined(__BIG_ENDIAN__)
#define BYTE_ORDER BIG_ENDIAN
#elif defined(__BYTE_ORDER__)
#define BYTE_ORDER __BYTE_ORDER__
#else
#ifndef __BYTE_ORDER__
#error Endianness not defined is not defined
#endif
#endif // BYTE_ORDER

#ifndef BIG_ENDIAN
#define BIG_ENDIAN __ORDER_BIG_ENDIAN__
#endif

#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
#endif

#if BYTE_ORDER == BIG_ENDIAN
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#ifndef htons
#define htons(x) (x)
#endif
Expand All @@ -90,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
Expand All @@ -105,7 +81,10 @@
#ifndef ntohl
#define ntohl(x) htonl(x)
#endif
#endif // BYTE_ORDER == BIG_ENDIAN

#else
#error Unknown endiannes set to _BYTE_ORDER__
#endif // _BYTE_ORDER__ ==

#endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT

Expand Down

0 comments on commit 7d09a84

Please sign in to comment.