diff options
Diffstat (limited to 'compat/bswap.h')
-rw-r--r-- | compat/bswap.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/compat/bswap.h b/compat/bswap.h index 5cc4acbfcc..f3b8c44181 100644 --- a/compat/bswap.h +++ b/compat/bswap.h @@ -24,10 +24,20 @@ static inline uint32_t default_swab32(uint32_t val) if (__builtin_constant_p(x)) { \ __res = default_swab32(x); \ } else { \ - __asm__("bswap %0" : "=r" (__res) : "0" (x)); \ + __asm__("bswap %0" : "=r" (__res) : "0" ((uint32_t)(x))); \ } \ __res; }) +#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) + +#include <stdlib.h> + +#define bswap32(x) _byteswap_ulong(x) + +#endif + +#ifdef bswap32 + #undef ntohl #undef htonl #define ntohl(x) bswap32(x) |