fix formatting
This commit is contained in:
+92
-95
@@ -28,29 +28,29 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros32_fallback(U32 val)
|
|||||||
MEM_STATIC unsigned ZSTD_countTrailingZeros32(U32 val)
|
MEM_STATIC unsigned ZSTD_countTrailingZeros32(U32 val)
|
||||||
{
|
{
|
||||||
assert(val != 0);
|
assert(val != 0);
|
||||||
# if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# if STATIC_BMI2
|
# if STATIC_BMI2
|
||||||
return (unsigned)_tzcnt_u32(val);
|
return (unsigned)_tzcnt_u32(val);
|
||||||
# else
|
# else
|
||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
unsigned long r;
|
unsigned long r;
|
||||||
_BitScanForward(&r, val);
|
_BitScanForward(&r, val);
|
||||||
return (unsigned)r;
|
return (unsigned)r;
|
||||||
} else {
|
} else {
|
||||||
/* Should not reach this code path */
|
__assume(0); /* Should not reach this code path */
|
||||||
__assume(0);
|
}
|
||||||
}
|
# endif
|
||||||
# endif
|
#elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
return (unsigned)__builtin_ctz(val);
|
||||||
return (unsigned)__builtin_ctz(val);
|
#elif defined(__ICCARM__)
|
||||||
# elif defined(__ICCARM__)
|
return (unsigned)__builtin_ctz(val);
|
||||||
return (unsigned)__builtin_ctz(val);
|
#else
|
||||||
# else
|
return ZSTD_countTrailingZeros32_fallback(val);
|
||||||
return ZSTD_countTrailingZeros32_fallback(val);
|
#endif
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val) {
|
MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val)
|
||||||
|
{
|
||||||
assert(val != 0);
|
assert(val != 0);
|
||||||
{
|
{
|
||||||
static const U32 DeBruijnClz[32] = {0, 9, 1, 10, 13, 21, 2, 29,
|
static const U32 DeBruijnClz[32] = {0, 9, 1, 10, 13, 21, 2, 29,
|
||||||
@@ -69,92 +69,89 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val) {
|
|||||||
MEM_STATIC unsigned ZSTD_countLeadingZeros32(U32 val)
|
MEM_STATIC unsigned ZSTD_countLeadingZeros32(U32 val)
|
||||||
{
|
{
|
||||||
assert(val != 0);
|
assert(val != 0);
|
||||||
# if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# if STATIC_BMI2
|
# if STATIC_BMI2
|
||||||
return (unsigned)_lzcnt_u32(val);
|
return (unsigned)_lzcnt_u32(val);
|
||||||
# else
|
# else
|
||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
unsigned long r;
|
unsigned long r;
|
||||||
_BitScanReverse(&r, val);
|
_BitScanReverse(&r, val);
|
||||||
return (unsigned)(31 - r);
|
return (unsigned)(31 - r);
|
||||||
} else {
|
} else {
|
||||||
/* Should not reach this code path */
|
__assume(0); /* Should not reach this code path */
|
||||||
__assume(0);
|
}
|
||||||
}
|
# endif
|
||||||
# endif
|
#elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
return (unsigned)__builtin_clz(val);
|
||||||
return (unsigned)__builtin_clz(val);
|
#elif defined(__ICCARM__)
|
||||||
# elif defined(__ICCARM__)
|
return (unsigned)__builtin_clz(val);
|
||||||
return (unsigned)__builtin_clz(val);
|
#else
|
||||||
# else
|
return ZSTD_countLeadingZeros32_fallback(val);
|
||||||
return ZSTD_countLeadingZeros32_fallback(val);
|
#endif
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
|
MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
|
||||||
{
|
{
|
||||||
assert(val != 0);
|
assert(val != 0);
|
||||||
# if defined(_MSC_VER) && defined(_WIN64)
|
#if defined(_MSC_VER) && defined(_WIN64)
|
||||||
# if STATIC_BMI2
|
# if STATIC_BMI2
|
||||||
return (unsigned)_tzcnt_u64(val);
|
return (unsigned)_tzcnt_u64(val);
|
||||||
# else
|
# else
|
||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
unsigned long r;
|
unsigned long r;
|
||||||
_BitScanForward64(&r, val);
|
_BitScanForward64(&r, val);
|
||||||
return (unsigned)r;
|
return (unsigned)r;
|
||||||
} else {
|
} else {
|
||||||
/* Should not reach this code path */
|
__assume(0); /* Should not reach this code path */
|
||||||
__assume(0);
|
}
|
||||||
}
|
# endif
|
||||||
# endif
|
#elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
|
||||||
# elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
|
return (unsigned)__builtin_ctzll(val);
|
||||||
return (unsigned)__builtin_ctzll(val);
|
#elif defined(__ICCARM__)
|
||||||
# elif defined(__ICCARM__)
|
return (unsigned)__builtin_ctzll(val);
|
||||||
return (unsigned)__builtin_ctzll(val);
|
#else
|
||||||
# else
|
{
|
||||||
{
|
U32 mostSignificantWord = (U32)(val >> 32);
|
||||||
U32 mostSignificantWord = (U32)(val >> 32);
|
U32 leastSignificantWord = (U32)val;
|
||||||
U32 leastSignificantWord = (U32)val;
|
if (leastSignificantWord == 0) {
|
||||||
if (leastSignificantWord == 0) {
|
return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
|
||||||
return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
|
} else {
|
||||||
} else {
|
return ZSTD_countTrailingZeros32(leastSignificantWord);
|
||||||
return ZSTD_countTrailingZeros32(leastSignificantWord);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
# endif
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MEM_STATIC unsigned ZSTD_countLeadingZeros64(U64 val)
|
MEM_STATIC unsigned ZSTD_countLeadingZeros64(U64 val)
|
||||||
{
|
{
|
||||||
assert(val != 0);
|
assert(val != 0);
|
||||||
# if defined(_MSC_VER) && defined(_WIN64)
|
#if defined(_MSC_VER) && defined(_WIN64)
|
||||||
# if STATIC_BMI2
|
# if STATIC_BMI2
|
||||||
return (unsigned)_lzcnt_u64(val);
|
return (unsigned)_lzcnt_u64(val);
|
||||||
# else
|
# else
|
||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
unsigned long r;
|
unsigned long r;
|
||||||
_BitScanReverse64(&r, val);
|
_BitScanReverse64(&r, val);
|
||||||
return (unsigned)(63 - r);
|
return (unsigned)(63 - r);
|
||||||
} else {
|
} else {
|
||||||
/* Should not reach this code path */
|
__assume(0); /* Should not reach this code path */
|
||||||
__assume(0);
|
}
|
||||||
}
|
# endif
|
||||||
# endif
|
#elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
return (unsigned)(__builtin_clzll(val));
|
||||||
return (unsigned)(__builtin_clzll(val));
|
#elif defined(__ICCARM__)
|
||||||
# elif defined(__ICCARM__)
|
return (unsigned)(__builtin_clzll(val));
|
||||||
return (unsigned)(__builtin_clzll(val));
|
#else
|
||||||
# else
|
{
|
||||||
{
|
U32 mostSignificantWord = (U32)(val >> 32);
|
||||||
U32 mostSignificantWord = (U32)(val >> 32);
|
U32 leastSignificantWord = (U32)val;
|
||||||
U32 leastSignificantWord = (U32)val;
|
if (mostSignificantWord == 0) {
|
||||||
if (mostSignificantWord == 0) {
|
return 32 + ZSTD_countLeadingZeros32(leastSignificantWord);
|
||||||
return 32 + ZSTD_countLeadingZeros32(leastSignificantWord);
|
} else {
|
||||||
} else {
|
return ZSTD_countLeadingZeros32(mostSignificantWord);
|
||||||
return ZSTD_countLeadingZeros32(mostSignificantWord);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
# endif
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MEM_STATIC unsigned ZSTD_NbCommonBytes(size_t val)
|
MEM_STATIC unsigned ZSTD_NbCommonBytes(size_t val)
|
||||||
|
|||||||
Reference in New Issue
Block a user