diff --git a/src/util/compat/endian.h b/src/util/compat/endian.h index 8857dbe..f326815 100644 --- a/src/util/compat/endian.h +++ b/src/util/compat/endian.h @@ -2,11 +2,22 @@ // Licensed under the MIT Licence. See LICENSE for details #pragma once -#include #include #include "../atrb.h" +#if __has_include() +#include +#elif defined(__GNUC__) || defined(__clang__) +#define bswap_16 __builtin_bswap16 +#define bswap_32 __builtin_bswap32 +#define bswap_64 __builtin_bswap64 +#else +// TODO: use custom bswap bacros +#error WIP, no support +#endif + + /* little endian */ atrb_const static inline uint16_t le16ton(uint16_t); // converts little-endian (LE) encoding to native for a 16 bit integer. (NOOP if native is LE) atrb_const static inline uint32_t le32ton(uint32_t); // converts little-endian (LE) encoding to native for a 32 bit integer. (NOOP if native is LE)