mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-17 15:32:10 +08:00
librhash: Implement bswap_32 as a function even in strict C90 mode
We cannot fall back to the macro implementation because some call sites may call it with an argument like `*ptr++` that has side effects.
This commit is contained in:
@@ -103,15 +103,12 @@ static inline uint32_t bswap_32(uint32_t x) {
|
||||
# define bswap_32(x) __builtin_bswap32(x)
|
||||
#elif (_MSC_VER > 1300) && (defined(CPU_IA32) || defined(CPU_X64)) /* MS VC */
|
||||
# define bswap_32(x) _byteswap_ulong((unsigned long)x)
|
||||
#elif !defined(__STRICT_ANSI__)
|
||||
#else
|
||||
/* general bswap_32 definition */
|
||||
static inline uint32_t bswap_32(uint32_t x) {
|
||||
static uint32_t bswap_32(uint32_t x) {
|
||||
x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0x00FF00FF);
|
||||
return (x >> 16) | (x << 16);
|
||||
}
|
||||
#else
|
||||
#define bswap_32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
|
||||
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
|
||||
#endif /* bswap_32 */
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)
|
||||
|
Reference in New Issue
Block a user