From: Yann Collet Date: Mon, 11 Sep 2017 22:17:31 +0000 (-0700) Subject: fix #820 : GCC v3.x 32-bits doesn't define 64-bits intrinsic X-Git-Tag: fuzz-corpora2~14^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F837%2Fhead;p=thirdparty%2Fzstd.git fix #820 : GCC v3.x 32-bits doesn't define 64-bits intrinsic resulting in undefined symbol error. Push the requirement to GCC 4 for now. Another solution, proposed by @NWilson, is to use __LONG_MAX__ instead. __LONG_MAX__ is a GCC-specific constant, which value is supposed to depend on underlying target hardware (32/64 bits) Might be better, but seems also more complex, hence more prone to side effects. Keeping the simple solution for now (just rely on __GNUC__) --- diff --git a/lib/compress/zstd_compress.h b/lib/compress/zstd_compress.h index 4da0317a7..d8813782c 100644 --- a/lib/compress/zstd_compress.h +++ b/lib/compress/zstd_compress.h @@ -168,7 +168,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t val) unsigned long r = 0; _BitScanForward64( &r, (U64)val ); return (unsigned)(r>>3); -# elif defined(__GNUC__) && (__GNUC__ >= 3) +# elif defined(__GNUC__) && (__GNUC__ >= 4) return (__builtin_ctzll((U64)val) >> 3); # else static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, @@ -202,7 +202,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t val) unsigned long r = 0; _BitScanReverse64( &r, val ); return (unsigned)(r>>3); -# elif defined(__GNUC__) && (__GNUC__ >= 3) +# elif defined(__GNUC__) && (__GNUC__ >= 4) return (__builtin_clzll(val) >> 3); # else unsigned r;