Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inet implementations assume BYTE_ORDER is defined. make sure that it is #26460

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/inet/arpa-inet-compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@
#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 @@ -49,6 +56,26 @@

#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT

#ifndef BYTE_ORDER
#if defined(__LITTLE_ENDIAN__)
#define BYTE_ORDER LITTLE_ENDIAN
jmartinez-silabs marked this conversation as resolved.
Show resolved Hide resolved
#elif defined(__BIG_ENDIAN__)
#define BYTE_ORDER BIG_ENDIAN
#elif defined(__BYTE_ORDER__)
#define BYTE_ORDER __BYTE_ORDER__
jmartinez-silabs marked this conversation as resolved.
Show resolved Hide resolved
#else
#error Endianness not defined is not defined
jmartinez-silabs marked this conversation as resolved.
Show resolved Hide resolved
#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
#ifndef htons
#define htons(x) (x)
Expand Down