Skip to content

Commit

Permalink
Add checks to determine if built-in byte swap functions exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ssilverman committed Apr 5, 2024
1 parent 3a148bd commit 93ef9cb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/arch/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 93ef9cb

Please sign in to comment.