From 93ef9cb5b73de23ec595718094dd091c0c0719c4 Mon Sep 17 00:00:00 2001 From: Shawn Silverman Date: Thu, 4 Apr 2024 06:17:05 -0700 Subject: [PATCH] Add checks to determine if built-in byte swap functions exist --- src/arch/cc.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/arch/cc.h b/src/arch/cc.h index 24a9cd39..d8ed3382 100644 --- a/src/arch/cc.h +++ b/src/arch/cc.h @@ -42,9 +42,19 @@ void qnethernet_hal_stdio_flush(int file); alignas(MEM_ALIGNMENT) u8_t variable_name[(size)] #endif // !QNETHERNET_LWIP_MEMORY_IN_RAM1 +// Byte swapping #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) +#if defined(__has_builtin) + +#if __has_builtin(__builtin_bswap16) #define lwip_htons(x) __builtin_bswap16(x) +#endif // __has_builtin(__builtin_bswap16) + +#if __has_builtin(__builtin_bswap32) #define lwip_htonl(x) __builtin_bswap32(x) +#endif // __has_builtin(__builtin_bswap32) + +#endif // defined(__has_builtin) #endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #ifdef __cplusplus