Skip to content
Snippets Groups Projects
Commit fc2cb74f authored by Brad King's avatar Brad King
Browse files

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.
parent 0bd333bc
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment