Skip to content

Commit

Permalink
Explicitly truncate bswap operand to uint32_t
Browse files Browse the repository at this point in the history
There are some places in git where a long is passed to htonl/ntohl. llvm
doesn't support matching operands of different bitwidths intentionally.
This patch fixes the build with llvm-gcc (and clang) on x86_64.

Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Benjamin Kramer authored and Junio C Hamano committed Nov 25, 2009
1 parent 5d166cc commit b073b7a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compat/bswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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; })

Expand Down

0 comments on commit b073b7a

Please sign in to comment.