summaryrefslogtreecommitdiff
path: root/compat/bswap.h
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2011-03-16 07:00:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-03-16 19:44:59 (GMT)
commitc6c8d0b797e33ce1f22d50b46d9c6eba91ed2cbc (patch)
tree1130feebbf16b3bb00360fa0935af720c6460344 /compat/bswap.h
parentc9b6782a08a728908bac8dc51def3607b3daa2a9 (diff)
downloadgit-c6c8d0b797e33ce1f22d50b46d9c6eba91ed2cbc.zip
git-c6c8d0b797e33ce1f22d50b46d9c6eba91ed2cbc.tar.gz
git-c6c8d0b797e33ce1f22d50b46d9c6eba91ed2cbc.tar.bz2
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>
Diffstat (limited to 'compat/bswap.h')
-rw-r--r--compat/bswap.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/compat/bswap.h b/compat/bswap.h
index 54756db..5061214 100644
--- a/compat/bswap.h
+++ b/compat/bswap.h
@@ -21,14 +21,16 @@ static inline uint32_t default_swab32(uint32_t val)
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
-#define bswap32(x) ({ \
- uint32_t __res; \
- if (__builtin_constant_p(x)) { \
- __res = default_swab32(x); \
- } else { \
- __asm__("bswap %0" : "=r" (__res) : "0" ((uint32_t)(x))); \
- } \
- __res; })
+#define bswap32 git_bswap32
+static inline uint32_t git_bswap32(uint32_t x)
+{
+ uint32_t result;
+ if (__builtin_constant_p(x))
+ result = default_swab32(x);
+ else
+ __asm__("bswap %0" : "=r" (result) : "0" (x));
+ return result;
+}
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))