From ef038b9db55bba73e2574ae451d62e16ce9c0ef9 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Mon, 15 Feb 2021 19:10:05 +0200 Subject: Make xz_crc64.c compatible with -std=gnu89 on 32-bit platforms. When "unsigned long" is 32 bits and GCC or Clang is in gnu89 mode, the 64-bit constant doesn't become "unsigned long long" like it would in C99. This is because in gnu89 mode "unsigned long long" is a GNU extension to C89 and isn't considered when selecting the type of the integer constant. The CRC64 support was added in 2013 and the code has been broken on 32-bit platforms unless one modified the Makefile to set C99 or a newer C standard. I didn't want to omit -std=gnu89 because Linux still uses it and xz_crc64.c (which isn't in Linux) was the only place that wasn't compatible with -std=gnu89. Thanks to bzt for reporting the problem. --- linux/lib/xz/xz_crc64.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'linux/lib/xz') diff --git a/linux/lib/xz/xz_crc64.c b/linux/lib/xz/xz_crc64.c index 215e04d..60c40f6 100644 --- a/linux/lib/xz/xz_crc64.c +++ b/linux/lib/xz/xz_crc64.c @@ -20,7 +20,11 @@ STATIC_RW_DATA uint64_t xz_crc64_table[256]; XZ_EXTERN void xz_crc64_init(void) { - const uint64_t poly = 0xC96C5795D7870F42; + /* + * The ULL suffix is needed for -std=gnu89 compatibility + * on 32-bit platforms. + */ + const uint64_t poly = 0xC96C5795D7870F42ULL; uint32_t i; uint32_t j; -- cgit v1.2.3