fundamental: prefer byte swap builtins over byte swapping manually

This builtin reduces complexity and GCC/Clang have supported these builtins for a long time.
This commit is contained in:
Rose
2024-01-03 15:11:55 +09:00
committed by Yu Watanabe
parent 12fb1fc5dd
commit cb924b9b6a
+2 -9
View File
@@ -34,16 +34,9 @@
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define SWAP(n) \
(((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
__builtin_bswap32(n)
# define SWAP64(n) \
(((n) << 56) \
| (((n) & 0xff00) << 40) \
| (((n) & 0xff0000) << 24) \
| (((n) & 0xff000000) << 8) \
| (((n) >> 8) & 0xff000000) \
| (((n) >> 24) & 0xff0000) \
| (((n) >> 40) & 0xff00) \
| ((n) >> 56))
__builtin_bswap64(n)
#else
# define SWAP(n) (n)
# define SWAP64(n) (n)