--- util.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/util.h b/util.h index 7315ce2..a6ad4ad 100644 --- a/util.h +++ b/util.h @@ -91,7 +91,16 @@ #define MAC_ZERO ((uint8_t [ETH_ALEN]){ 0 }) #define MAC_IS_ZERO(addr) (!memcmp((addr), MAC_ZERO, ETH_ALEN)) -#if defined(__GLIBC__) || defined(__UCLIBC__) +#ifndef __bswap_constant_16 +#define __bswap_constant_16(x) \ + ((unsigned short int) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) +#endif + +#ifndef __bswap_constant_32 +#define __bswap_constant_32(x) \ + ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) +#endif #if __BYTE_ORDER == __BIG_ENDIAN #define htons_constant(x) (x) @@ -101,14 +110,6 @@ #define htonl_constant(x) (__bswap_constant_32(x)) #endif -#else - -/* mainly musl fallback */ - -#define htons_constant(x) (x) -#define htonl_constant(x) (x) - -#endif #define IN4_IS_ADDR_UNSPECIFIED(a) \ ((a)->s_addr == htonl(INADDR_ANY)) -- 2.38.4