From 1d0bffb20acf156621b40f0337f384704495b896 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 19 Mar 2019 19:58:42 +0800 Subject: [PATCH] lwip, wpa_supplicant: use endianness macros from libc if possible --- components/lwip/port/esp32/include/arch/cc.h | 2 ++ components/wpa_supplicant/port/include/byteswap.h | 8 ++++++++ components/wpa_supplicant/port/include/endian.h | 1 + 3 files changed, 11 insertions(+) diff --git a/components/lwip/port/esp32/include/arch/cc.h b/components/lwip/port/esp32/include/arch/cc.h index cba0b365e..1841e3f45 100644 --- a/components/lwip/port/esp32/include/arch/cc.h +++ b/components/lwip/port/esp32/include/arch/cc.h @@ -41,7 +41,9 @@ #include "arch/sys_arch.h" +#ifndef BYTE_ORDER #define BYTE_ORDER LITTLE_ENDIAN +#endif // BYTE_ORDER typedef uint8_t u8_t; typedef int8_t s8_t; diff --git a/components/wpa_supplicant/port/include/byteswap.h b/components/wpa_supplicant/port/include/byteswap.h index 1a8bb8fd1..d65503ba3 100644 --- a/components/wpa_supplicant/port/include/byteswap.h +++ b/components/wpa_supplicant/port/include/byteswap.h @@ -5,7 +5,10 @@ #ifndef BYTESWAP_H #define BYTESWAP_H +#include + /* Swap bytes in 16 bit value. */ +#ifndef __bswap_16 #ifdef __GNUC__ # define __bswap_16(x) \ (__extension__ \ @@ -18,8 +21,10 @@ __bswap_16 (unsigned short int __bsx) return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); } #endif +#endif // __bswap_16 /* Swap bytes in 32 bit value. */ +#ifndef __bswap_32 #ifdef __GNUC__ # define __bswap_32(x) \ (__extension__ \ @@ -34,7 +39,9 @@ __bswap_32 (unsigned int __bsx) (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); } #endif +#endif // __bswap_32 +#ifndef __bswap_64 #if defined __GNUC__ && __GNUC__ >= 2 /* Swap bytes in 64 bit value. */ # define __bswap_constant_64(x) \ @@ -61,5 +68,6 @@ __bswap_32 (unsigned int __bsx) } \ __r.__ll; })) #endif +#endif // __bswap_64 #endif /* BYTESWAP_H */ diff --git a/components/wpa_supplicant/port/include/endian.h b/components/wpa_supplicant/port/include/endian.h index 1e2453f16..655bc3013 100644 --- a/components/wpa_supplicant/port/include/endian.h +++ b/components/wpa_supplicant/port/include/endian.h @@ -30,6 +30,7 @@ #define _ENDIAN_H_ #include +#include #include "byteswap.h" #ifndef BIG_ENDIAN