Changeset View
Changeset View
Standalone View
Standalone View
contrib/zstd/lib/common/bitstream.h
Show First 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | |||||
* Internal functions | * Internal functions | ||||
****************************************************************/ | ****************************************************************/ | ||||
MEM_STATIC unsigned BIT_highbit32 (register U32 val) | MEM_STATIC unsigned BIT_highbit32 (register U32 val) | ||||
{ | { | ||||
# if defined(_MSC_VER) /* Visual */ | # if defined(_MSC_VER) /* Visual */ | ||||
unsigned long r=0; | unsigned long r=0; | ||||
_BitScanReverse ( &r, val ); | _BitScanReverse ( &r, val ); | ||||
return (unsigned) r; | return (unsigned) r; | ||||
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */ | # elif defined(__GNUC__) && (__GNUC__ >= 3) && __has_builtin(__builtin_clz) /* Use GCC Intrinsic */ | ||||
imp: related? seems like a separate patch that could easily be upstreamed. | |||||
Done Inline ActionsThis is required for this code to compile on sparc64. I attempted to upstream this and then realized that GCC doesn't have __has_builtin(), we just get on on FreeBSD via a clang compatibility .h file we have (and it just always returns false). allanjude: This is required for this code to compile on sparc64.
I attempted to upstream this and then… | |||||
return 31 - __builtin_clz (val); | return 31 - __builtin_clz (val); | ||||
# else /* Software version */ | # else /* Software version */ | ||||
static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, | static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, | ||||
11, 14, 16, 18, 22, 25, 3, 30, | 11, 14, 16, 18, 22, 25, 3, 30, | ||||
8, 12, 20, 28, 15, 17, 24, 7, | 8, 12, 20, 28, 15, 17, 24, 7, | ||||
19, 27, 23, 6, 26, 5, 4, 31 }; | 19, 27, 23, 6, 26, 5, 4, 31 }; | ||||
U32 v = val; | U32 v = val; | ||||
v |= v >> 1; | v |= v >> 1; | ||||
▲ Show 20 Lines • Show All 275 Lines • Show Last 20 Lines |
related? seems like a separate patch that could easily be upstreamed.