diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2021-02-15 19:10:05 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2021-02-15 19:10:05 +0200 |
commit | ef038b9db55bba73e2574ae451d62e16ce9c0ef9 (patch) | |
tree | dcbe581efd708a0322b9e675c21c31a0e2772d67 /linux/lib/xz | |
parent | 82078b6109122ede1f76b76e75e54dcea7fc8d25 (diff) | |
download | xz-embedded-ef038b9db55bba73e2574ae451d62e16ce9c0ef9.tar.gz |
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.
Diffstat (limited to 'linux/lib/xz')
-rw-r--r-- | linux/lib/xz/xz_crc64.c | 6 |
1 files changed, 5 insertions, 1 deletions
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; |