Skip to content

Commit 40f3298

Browse files
committed
zstd: Update to v1.5.7 version
1 parent 2b8d9e9 commit 40f3298

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2758
-1534
lines changed

erts/emulator/zstd/common/bits.h

+92-87
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,29 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros32_fallback(U32 val)
2828
MEM_STATIC unsigned ZSTD_countTrailingZeros32(U32 val)
2929
{
3030
assert(val != 0);
31-
# if defined(_MSC_VER)
32-
# if STATIC_BMI2 == 1
33-
return (unsigned)_tzcnt_u32(val);
34-
# else
35-
if (val != 0) {
36-
unsigned long r;
37-
_BitScanForward(&r, val);
38-
return (unsigned)r;
39-
} else {
40-
/* Should not reach this code path */
41-
__assume(0);
42-
}
43-
# endif
44-
# elif defined(__GNUC__) && (__GNUC__ >= 4)
45-
return (unsigned)__builtin_ctz(val);
46-
# else
47-
return ZSTD_countTrailingZeros32_fallback(val);
48-
# endif
31+
#if defined(_MSC_VER)
32+
# if STATIC_BMI2
33+
return (unsigned)_tzcnt_u32(val);
34+
# else
35+
if (val != 0) {
36+
unsigned long r;
37+
_BitScanForward(&r, val);
38+
return (unsigned)r;
39+
} else {
40+
__assume(0); /* Should not reach this code path */
41+
}
42+
# endif
43+
#elif defined(__GNUC__) && (__GNUC__ >= 4)
44+
return (unsigned)__builtin_ctz(val);
45+
#elif defined(__ICCARM__)
46+
return (unsigned)__builtin_ctz(val);
47+
#else
48+
return ZSTD_countTrailingZeros32_fallback(val);
49+
#endif
4950
}
5051

51-
MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val) {
52+
MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val)
53+
{
5254
assert(val != 0);
5355
{
5456
static const U32 DeBruijnClz[32] = {0, 9, 1, 10, 13, 21, 2, 29,
@@ -67,86 +69,89 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val) {
6769
MEM_STATIC unsigned ZSTD_countLeadingZeros32(U32 val)
6870
{
6971
assert(val != 0);
70-
# if defined(_MSC_VER)
71-
# if STATIC_BMI2 == 1
72-
return (unsigned)_lzcnt_u32(val);
73-
# else
74-
if (val != 0) {
75-
unsigned long r;
76-
_BitScanReverse(&r, val);
77-
return (unsigned)(31 - r);
78-
} else {
79-
/* Should not reach this code path */
80-
__assume(0);
81-
}
82-
# endif
83-
# elif defined(__GNUC__) && (__GNUC__ >= 4)
84-
return (unsigned)__builtin_clz(val);
85-
# else
86-
return ZSTD_countLeadingZeros32_fallback(val);
87-
# endif
72+
#if defined(_MSC_VER)
73+
# if STATIC_BMI2
74+
return (unsigned)_lzcnt_u32(val);
75+
# else
76+
if (val != 0) {
77+
unsigned long r;
78+
_BitScanReverse(&r, val);
79+
return (unsigned)(31 - r);
80+
} else {
81+
__assume(0); /* Should not reach this code path */
82+
}
83+
# endif
84+
#elif defined(__GNUC__) && (__GNUC__ >= 4)
85+
return (unsigned)__builtin_clz(val);
86+
#elif defined(__ICCARM__)
87+
return (unsigned)__builtin_clz(val);
88+
#else
89+
return ZSTD_countLeadingZeros32_fallback(val);
90+
#endif
8891
}
8992

9093
MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
9194
{
9295
assert(val != 0);
93-
# if defined(_MSC_VER) && defined(_WIN64)
94-
# if STATIC_BMI2 == 1
95-
return (unsigned)_tzcnt_u64(val);
96-
# else
97-
if (val != 0) {
98-
unsigned long r;
99-
_BitScanForward64(&r, val);
100-
return (unsigned)r;
101-
} else {
102-
/* Should not reach this code path */
103-
__assume(0);
104-
}
105-
# endif
106-
# elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
107-
return (unsigned)__builtin_ctzll(val);
108-
# else
109-
{
110-
U32 mostSignificantWord = (U32)(val >> 32);
111-
U32 leastSignificantWord = (U32)val;
112-
if (leastSignificantWord == 0) {
113-
return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
114-
} else {
115-
return ZSTD_countTrailingZeros32(leastSignificantWord);
116-
}
96+
#if defined(_MSC_VER) && defined(_WIN64)
97+
# if STATIC_BMI2
98+
return (unsigned)_tzcnt_u64(val);
99+
# else
100+
if (val != 0) {
101+
unsigned long r;
102+
_BitScanForward64(&r, val);
103+
return (unsigned)r;
104+
} else {
105+
__assume(0); /* Should not reach this code path */
106+
}
107+
# endif
108+
#elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
109+
return (unsigned)__builtin_ctzll(val);
110+
#elif defined(__ICCARM__)
111+
return (unsigned)__builtin_ctzll(val);
112+
#else
113+
{
114+
U32 mostSignificantWord = (U32)(val >> 32);
115+
U32 leastSignificantWord = (U32)val;
116+
if (leastSignificantWord == 0) {
117+
return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
118+
} else {
119+
return ZSTD_countTrailingZeros32(leastSignificantWord);
117120
}
118-
# endif
121+
}
122+
#endif
119123
}
120124

121125
MEM_STATIC unsigned ZSTD_countLeadingZeros64(U64 val)
122126
{
123127
assert(val != 0);
124-
# if defined(_MSC_VER) && defined(_WIN64)
125-
# if STATIC_BMI2 == 1
126-
return (unsigned)_lzcnt_u64(val);
127-
# else
128-
if (val != 0) {
129-
unsigned long r;
130-
_BitScanReverse64(&r, val);
131-
return (unsigned)(63 - r);
132-
} else {
133-
/* Should not reach this code path */
134-
__assume(0);
135-
}
136-
# endif
137-
# elif defined(__GNUC__) && (__GNUC__ >= 4)
138-
return (unsigned)(__builtin_clzll(val));
139-
# else
140-
{
141-
U32 mostSignificantWord = (U32)(val >> 32);
142-
U32 leastSignificantWord = (U32)val;
143-
if (mostSignificantWord == 0) {
144-
return 32 + ZSTD_countLeadingZeros32(leastSignificantWord);
145-
} else {
146-
return ZSTD_countLeadingZeros32(mostSignificantWord);
147-
}
128+
#if defined(_MSC_VER) && defined(_WIN64)
129+
# if STATIC_BMI2
130+
return (unsigned)_lzcnt_u64(val);
131+
# else
132+
if (val != 0) {
133+
unsigned long r;
134+
_BitScanReverse64(&r, val);
135+
return (unsigned)(63 - r);
136+
} else {
137+
__assume(0); /* Should not reach this code path */
138+
}
139+
# endif
140+
#elif defined(__GNUC__) && (__GNUC__ >= 4)
141+
return (unsigned)(__builtin_clzll(val));
142+
#elif defined(__ICCARM__)
143+
return (unsigned)(__builtin_clzll(val));
144+
#else
145+
{
146+
U32 mostSignificantWord = (U32)(val >> 32);
147+
U32 leastSignificantWord = (U32)val;
148+
if (mostSignificantWord == 0) {
149+
return 32 + ZSTD_countLeadingZeros32(leastSignificantWord);
150+
} else {
151+
return ZSTD_countLeadingZeros32(mostSignificantWord);
148152
}
149-
# endif
153+
}
154+
#endif
150155
}
151156

152157
MEM_STATIC unsigned ZSTD_NbCommonBytes(size_t val)

0 commit comments

Comments
 (0)