Fix crasher on encountering SHA1-like non-note in notes tree
[gitweb.git] / compat / bswap.h
index 5cc4acbfccef771769974b9f7cd8f6bca9321354..f3b8c44181776a99c3eb79e15542104d67001c9d 100644 (file)
@@ -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)