Skip to content

Commit

Permalink
Inet implementations assume BYTE_ORDER is defined. make sure that it …
Browse files Browse the repository at this point in the history
…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 <bzbarsky@apple.com>

---------

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
  • Loading branch information
2 people authored and pull[bot] committed Oct 18, 2023
1 parent 063f4d9 commit 1966354
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/inet/arpa-inet-compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#else // !CHIP_SYSTEM_CONFIG_USE_SOCKETS

#if CHIP_SYSTEM_CONFIG_USE_LWIP

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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 1966354

Please sign in to comment.