X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=compat%2Fbswap.h;h=54756dbb05ba99ab1679f17a50f04c3f1cede8e6;hb=ed40ec551d4517323c6a46aa555b83cc7651ddbc;hp=5cc4acbfccef771769974b9f7cd8f6bca9321354;hpb=a07b10c8f930e88386d3b7424f25190af554275e;p=git.git diff --git a/compat/bswap.h b/compat/bswap.h index 5cc4acbfc..54756dbb0 100644 --- a/compat/bswap.h +++ b/compat/bswap.h @@ -17,6 +17,8 @@ static inline uint32_t default_swab32(uint32_t val) ((val & 0x000000ff) << 24)); } +#undef bswap32 + #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) #define bswap32(x) ({ \ @@ -24,10 +26,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 + +#define bswap32(x) _byteswap_ulong(x) + +#endif + +#ifdef bswap32 + #undef ntohl #undef htonl #define ntohl(x) bswap32(x)