Modify bswap.h to allow compiling on older GCC

This commit is contained in:
Jasmine Iwanek
2022-11-17 22:50:37 -05:00
committed by GitHub
parent 0d48606e39
commit 7896e5dcfe

View File

@@ -73,6 +73,7 @@
)
#endif /*HAVE_BYTESWAP_H*/
#if __GNUC__ >= 10
#if defined __has_builtin && __has_builtin(__builtin_bswap16)
#define bswap16(x) __builtin_bswap16(x)
#else
@@ -81,7 +82,14 @@ static __inline uint16_t bswap16(uint16_t x)
return bswap_16(x);
}
#endif
#else
static __inline uint16_t bswap16(uint16_t x)
{
return bswap_16(x);
}
#endif
#if __GNUC__ >= 10
#if defined __has_builtin && __has_builtin(__builtin_bswap32)
#define bswap32(x) __builtin_bswap32(x)
#else
@@ -90,7 +98,14 @@ static __inline uint32_t bswap32(uint32_t x)
return bswap_32(x);
}
#endif
#else
static __inline uint32_t bswap32(uint32_t x)
{
return bswap_32(x);
}
#endif
#if __GNUC__ >= 10
#if defined __has_builtin && __has_builtin(__builtin_bswap64)
#define bswap64(x) __builtin_bswap64(x)
#else
@@ -99,6 +114,12 @@ static __inline uint64_t bswap64(uint64_t x)
return bswap_64(x);
}
#endif
#else
static __inline uint64_t bswap64(uint64_t x)
{
return bswap_64(x);
}
#endif
static __inline void bswap16s(uint16_t *s)
{