Use __has_builtin() to ensure clz and clzll builtins are available

The existing check of the GCC version number is not sufficient

This fixes the build on sparc64 in preparation for integrating ZSTD into
the kernel for ZFS and Crash Dumps.
This commit is contained in:
Allan Jude 2017-12-04 01:16:26 +00:00
parent 02cfd60482
commit 90edb2ac5b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=326506
3 changed files with 4 additions and 4 deletions

View File

@ -175,7 +175,7 @@ MEM_STATIC unsigned BIT_highbit32 (register U32 val)
unsigned long r=0;
_BitScanReverse ( &r, val );
return (unsigned) r;
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */
# elif defined(__GNUC__) && (__GNUC__ >= 3) && __has_builtin(__builtin_clz) /* Use GCC Intrinsic */
return 31 - __builtin_clz (val);
# else /* Software version */
static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29,

View File

@ -327,7 +327,7 @@ MEM_STATIC U32 ZSTD_highbit32(U32 val)
unsigned long r=0;
_BitScanReverse(&r, val);
return (unsigned)r;
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* GCC Intrinsic */
# elif defined(__GNUC__) && (__GNUC__ >= 3) && __has_builtin(__builtin_clz) /* GCC Intrinsic */
return 31 - __builtin_clz(val);
# else /* Software version */
static const int DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };

View File

@ -203,7 +203,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t val)
unsigned long r = 0;
_BitScanReverse64( &r, val );
return (unsigned)(r>>3);
# elif defined(__GNUC__) && (__GNUC__ >= 4)
# elif defined(__GNUC__) && (__GNUC__ >= 4) && __has_builtin(__builtin_clzll)
return (__builtin_clzll(val) >> 3);
# else
unsigned r;
@ -218,7 +218,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t val)
unsigned long r = 0;
_BitScanReverse( &r, (unsigned long)val );
return (unsigned)(r>>3);
# elif defined(__GNUC__) && (__GNUC__ >= 3)
# elif defined(__GNUC__) && (__GNUC__ >= 3) && __has_builtin(__builtin_clz)
return (__builtin_clz((U32)val) >> 3);
# else
unsigned r;