compat: make gcc bswap an inline function
Without this change, gcc -pedantic warns: cache.h: In function 'ce_to_dtype': cache.h:270:21: warning: ISO C forbids braced-groups within expressions [-pedantic] An inline function is more readable anyway. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Mar 16, 2011 at 02:00 UTC
c6c8d0b797e33ce1f22d50b46d9c6eba91ed2cbc
1 file changed
+10
-8
compat/bswap.h
+10
-8
@@ -21,14 +21,16 @@ static inline uint32_t default_swab32(uint32_t val)
21
22
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
23
24
-#define bswap32(x) ({ \
25
- uint32_t __res; \
26
- if (__builtin_constant_p(x)) { \
27
- __res = default_swab32(x); \
28
- } else { \
29
- __asm__("bswap %0" : "=r" (__res) : "0" ((uint32_t)(x))); \
30
- } \
31
- __res; })
24
+#define bswap32 git_bswap32
25
+static inline uint32_t git_bswap32(uint32_t x)
26
+{
27
+ uint32_t result;
28
+ if (__builtin_constant_p(x))
29
+ result = default_swab32(x);
30
+ else
31
+ __asm__("bswap %0" : "=r" (result) : "0" (x));
32
+ return result;
33
+}
34
35
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
36