Skip to content

Commit

Permalink
Pull request project-chip#765: Inet implementations assume BYTE_ORDER…
Browse files Browse the repository at this point in the history
… is defined. make sure that it is (project-chip#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 <[email protected]>
Date:   Wed May 10 09:24:21 2023 -0400

    Inet implementations assume BYTE_ORDER is defined. make sure that it is (project-chip#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 <[email protected]>

    ---------

    Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
jmartinez-silabs committed May 10, 2023
1 parent cb9221a commit a108d1e
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 a108d1e

Please sign in to comment.