diff --git a/moo/lib/moo-utl.h b/moo/lib/moo-utl.h index 877487f..22e4c52 100644 --- a/moo/lib/moo-utl.h +++ b/moo/lib/moo-utl.h @@ -842,76 +842,77 @@ static MOO_INLINE moo_uint128_t moo_bswap128 (moo_uint128_t x) #if defined(MOO_ENDIAN_LITTLE) # if defined(MOO_HAVE_UINT16_T) -# define moo_ntoh16(x) moo_bswap16(x) # define moo_hton16(x) moo_bswap16(x) +# define moo_ntoh16(x) moo_bswap16(x) # define moo_htobe16(x) moo_bswap16(x) -# define moo_htole16(x) (x) # define moo_be16toh(x) moo_bswap16(x) -# define moo_le16toh(x) (x) +# define moo_htole16(x) ((moo_uint16_t)(x)) +# define moo_le16toh(x) ((moo_uint16_t)(x)) # endif # if defined(MOO_HAVE_UINT32_T) -# define moo_ntoh32(x) moo_bswap32(x) # define moo_hton32(x) moo_bswap32(x) +# define moo_ntoh32(x) moo_bswap32(x) # define moo_htobe32(x) moo_bswap32(x) -# define moo_htole32(x) (x) # define moo_be32toh(x) moo_bswap32(x) -# define moo_le32toh(x) (x) +# define moo_htole32(x) ((moo_uint32_t)(x)) +# define moo_le32toh(x) ((moo_uint32_t)(x)) # endif # if defined(MOO_HAVE_UINT64_T) -# define moo_ntoh64(x) moo_bswap64(x) # define moo_hton64(x) moo_bswap64(x) +# define moo_ntoh64(x) moo_bswap64(x) # define moo_htobe64(x) moo_bswap64(x) -# define moo_htole64(x) (x) # define moo_be64toh(x) moo_bswap64(x) -# define moo_le64toh(x) (x) +# define moo_htole64(x) ((moo_uint64_t)(x)) +# define moo_le64toh(x) ((moo_uint64_t)(x)) # endif # if defined(MOO_HAVE_UINT128_T) -# define moo_ntoh128(x) moo_bswap128(x) + # define moo_hton128(x) moo_bswap128(x) +# define moo_ntoh128(x) moo_bswap128(x) # define moo_htobe128(x) moo_bswap128(x) -# define moo_htole128(x) (x) # define moo_be128toh(x) moo_bswap128(x) -# define moo_le128toh(x) (x) +# define moo_htole128(x) ((moo_uint128_t)(x)) +# define moo_le128toh(x) ((moo_uint128_t)(x)) # endif #elif defined(MOO_ENDIAN_BIG) # if defined(MOO_HAVE_UINT16_T) -# define moo_ntoh16(x) (x) -# define moo_hton16(x) (x) -# define moo_htobe16(x) (x) +# define moo_hton16(x) ((moo_uint16_t)(x)) +# define moo_ntoh16(x) ((moo_uint16_t)(x)) +# define moo_htobe16(x) ((moo_uint16_t)(x)) +# define moo_be16toh(x) ((moo_uint16_t)(x)) # define moo_htole16(x) moo_bswap16(x) -# define moo_be16toh(x) (x) # define moo_le16toh(x) moo_bswap16(x) # endif # if defined(MOO_HAVE_UINT32_T) -# define moo_ntoh32(x) (x) -# define moo_hton32(x) (x) -# define moo_htobe32(x) (x) +# define moo_hton32(x) ((moo_uint32_t)(x)) +# define moo_ntoh32(x) ((moo_uint32_t)(x)) +# define moo_htobe32(x) ((moo_uint32_t)(x)) +# define moo_be32toh(x) ((moo_uint32_t)(x)) # define moo_htole32(x) moo_bswap32(x) -# define moo_be32toh(x) (x) # define moo_le32toh(x) moo_bswap32(x) # endif # if defined(MOO_HAVE_UINT64_T) -# define moo_ntoh64(x) (x) -# define moo_hton64(x) (x) -# define moo_htobe64(x) (x) +# define moo_hton64(x) ((moo_uint64_t)(x)) +# define moo_ntoh64(x) ((moo_uint64_t)(x)) +# define moo_htobe64(x) ((moo_uint64_t)(x)) +# define moo_be64toh(x) ((moo_uint64_t)(x)) # define moo_htole64(x) moo_bswap64(x) -# define moo_be64toh(x) (x) # define moo_le64toh(x) moo_bswap64(x) # endif # if defined(MOO_HAVE_UINT128_T) -# define moo_ntoh128(x) (x) -# define moo_hton128(x) (x) -# define moo_htobe128(x) (x) +# define moo_hton128(x) ((moo_uint128_t)(x)) +# define moo_ntoh128(x) ((moo_uint128_t)(x)) +# define moo_htobe128(x) ((moo_uint128_t)(x)) +# define moo_be128toh(x) ((moo_uint128_t)(x)) # define moo_htole128(x) moo_bswap128(x) -# define moo_be128toh(x) (x) # define moo_le128toh(x) moo_bswap128(x) # endif