]> git.ipfire.org Git - thirdparty/zstd.git/log
thirdparty/zstd.git
3 years agoUsing `module.modulemap` replace symbol link for public header 2858/head
Lvv.me [Mon, 15 Nov 2021 05:23:50 +0000 (13:23 +0800)] 
Using `module.modulemap` replace symbol link for public header

3 years agoSupport Swift Package Manager
Lvv.me [Sun, 14 Nov 2021 09:29:33 +0000 (17:29 +0800)] 
Support Swift Package Manager

3 years agoMerge pull request #2847 from Svetlitski-FB/improve-verbose-output-2
Yann Collet [Sat, 13 Nov 2021 02:51:18 +0000 (18:51 -0800)] 
Merge pull request #2847 from Svetlitski-FB/improve-verbose-output-2

Display command line parameters with concrete values in verbose mode

3 years agoIntegrate verbose mode tests into playTests.sh 2847/head
Kevin Svetlitski [Fri, 12 Nov 2021 22:10:21 +0000 (14:10 -0800)] 
Integrate verbose mode tests into playTests.sh

3 years agoSuppress spurious unused parameter warning
Kevin Svetlitski [Thu, 11 Nov 2021 22:37:02 +0000 (14:37 -0800)] 
Suppress spurious unused parameter warning

3 years agoEnsure formatting directives for displaying size_t are portable
Kevin Svetlitski [Thu, 11 Nov 2021 21:17:30 +0000 (13:17 -0800)] 
Ensure formatting directives for displaying size_t are portable

3 years agoEnsure print*CParams functions are only defined when used
Kevin Svetlitski [Thu, 11 Nov 2021 20:14:56 +0000 (12:14 -0800)] 
Ensure print*CParams functions are only defined when used

3 years agoAdd test case for detailed compression parameter verbose output
Kevin Svetlitski [Thu, 11 Nov 2021 19:57:55 +0000 (11:57 -0800)] 
Add test case for detailed compression parameter verbose output

3 years agoMerge pull request #2836 from animalize/copy16
Yann Collet [Thu, 11 Nov 2021 15:53:08 +0000 (07:53 -0800)] 
Merge pull request #2836 from animalize/copy16

ZSTD_copy16() uses ZSTD_memcpy()

3 years agoFix const-ness of FIO_displayCompressionParameters
Kevin Svetlitski [Thu, 11 Nov 2021 01:25:27 +0000 (17:25 -0800)] 
Fix const-ness of FIO_displayCompressionParameters

3 years agoDisplay --zstd= subparameters in command-line ready form in verbose mode
Kevin Svetlitski [Fri, 5 Nov 2021 19:48:13 +0000 (12:48 -0700)] 
Display --zstd= subparameters in command-line ready form in verbose mode

3 years agoMerge pull request #2850 from felixhandte/oss-fuzz-fix-40829-for-real-this-time
Felix Handte [Wed, 10 Nov 2021 17:00:43 +0000 (12:00 -0500)] 
Merge pull request #2850 from felixhandte/oss-fuzz-fix-40829-for-real-this-time

Fix Determinism Bug: Avoid Reducing Indices to Reserved Values

3 years agoFix fullbench CI failure (#2851)
binhdvo [Tue, 9 Nov 2021 20:15:35 +0000 (15:15 -0500)] 
Fix fullbench CI failure (#2851)

3 years agoRewrite Fix to Still Auto-Vectorize 2850/head
W. Felix Handte [Tue, 9 Nov 2021 17:15:18 +0000 (12:15 -0500)] 
Rewrite Fix to Still Auto-Vectorize

3 years agoAvoid Reducing Indices to Reserved Values
W. Felix Handte [Tue, 9 Nov 2021 01:03:52 +0000 (20:03 -0500)] 
Avoid Reducing Indices to Reserved Values

Previously, if an index was equal to `reducerValue + 1`, it would get remapped
during index reduction to 1 i.e. `ZSTD_DUBT_UNSORTED_MARK`. This can affect the
parsing of the input slightly, by causing tree nodes to be nullified when they
otherwise wouldn't be. This hardly matters from a correctness or efficiency
perspective, but it does impact determinism.

So this commit changes index reduction to avoid mapping indices to collide with
`ZSTD_DUBT_UNSORTED_MARK`.

3 years agoMerge pull request #2849 from terrelln/linux-kernel-backport
Nick Terrell [Fri, 5 Nov 2021 22:02:37 +0000 (15:02 -0700)] 
Merge pull request #2849 from terrelln/linux-kernel-backport

Backport zstd patch from LKML

3 years agoBackport zstd patch from LKML 2849/head
Nick Terrell [Fri, 5 Nov 2021 21:09:49 +0000 (14:09 -0700)] 
Backport zstd patch from LKML

Credit to Nathan Chancellor for the bug fix and Nick Desaulniers for the
bug report.

Link: https://github.com/ClangBuiltLinux/linux/issues/1486
Link: https://lore.kernel.org/all/20211021202353.2356400-1-nathan@kernel.org/
3 years agoMerge pull request #2846 from senhuang42/fix_appveyor
sen [Fri, 5 Nov 2021 20:24:25 +0000 (23:24 +0300)] 
Merge pull request #2846 from senhuang42/fix_appveyor

Use unused functions to appease Visual Studio

3 years agoDisplay command line parameters with concrete values in verbose mode
Kevin Svetlitski [Fri, 5 Nov 2021 19:01:20 +0000 (12:01 -0700)] 
Display command line parameters with concrete values in verbose mode

3 years agoMerge pull request #2839 from Svetlitski-FB/improve-verbose-output
Yann Collet [Fri, 5 Nov 2021 01:26:42 +0000 (18:26 -0700)] 
Merge pull request #2839 from Svetlitski-FB/improve-verbose-output

Improvements to verbose mode output - decompression memory usage

3 years agoReport memory required to decompress while compressing in verbose mode 2839/head
Kevin Svetlitski [Mon, 1 Nov 2021 20:31:03 +0000 (13:31 -0700)] 
Report memory required to decompress while compressing in verbose mode

3 years agoVoid out unused functions 2846/head
senhuang42 [Wed, 3 Nov 2021 14:06:21 +0000 (17:06 +0300)] 
Void out unused functions

3 years agoZSTD_copy16() uses SSE2 instructions 2836/head
Ma Lin [Thu, 28 Oct 2021 10:53:12 +0000 (18:53 +0800)] 
ZSTD_copy16() uses SSE2 instructions

This accelerates the decompression speed of MSVC build.

3 years agoMove mingw tests from appveyor to github actions (#2838)
binhdvo [Tue, 2 Nov 2021 17:17:55 +0000 (13:17 -0400)] 
Move mingw tests from appveyor to github actions (#2838)

3 years agoFix oss fuzz test error (#2837)
binhdvo [Fri, 29 Oct 2021 14:29:50 +0000 (10:29 -0400)] 
Fix oss fuzz test error (#2837)

3 years agominor improvements to benchmark display
Yann Collet [Wed, 27 Oct 2021 06:23:30 +0000 (23:23 -0700)] 
minor improvements to benchmark display

3 years agoMerge pull request #2829 from facebook/ZSTD_DECODER_INTERNAL_BUFFER
Yann Collet [Tue, 26 Oct 2021 17:48:16 +0000 (10:48 -0700)] 
Merge pull request #2829 from facebook/ZSTD_DECODER_INTERNAL_BUFFER

minor : change build macro to ZSTD_DECODER_INTERNAL_BUFFER

3 years agofix minor cast warning 2829/head
Yann Collet [Tue, 26 Oct 2021 15:38:17 +0000 (08:38 -0700)] 
fix minor cast warning

3 years agoadded minimum for decoder buffer
Yann Collet [Tue, 26 Oct 2021 15:21:31 +0000 (08:21 -0700)] 
added minimum for decoder buffer

also : introduced macro BOUNDED()

3 years agoMerge pull request #2830 from facebook/clevels
Yann Collet [Mon, 25 Oct 2021 20:35:54 +0000 (13:35 -0700)] 
Merge pull request #2830 from facebook/clevels

separate compression level tables into their own file

3 years agoMerge pull request #2828 from terrelln/lazy-compile
Nick Terrell [Mon, 25 Oct 2021 17:22:23 +0000 (10:22 -0700)] 
Merge pull request #2828 from terrelln/lazy-compile

[lazy] Speed up compilation times

3 years agoseparate compression level tables into their own files 2830/head
Yann Collet [Mon, 25 Oct 2021 15:49:54 +0000 (08:49 -0700)] 
separate compression level tables into their own files

that's clearer than finding the tables somewhere in the middle of `compress.c`.

Also, down the line, it may potentially allows zstd to feature adjusted tables depending on target cpu.

3 years agobuild macro ZSTD_DECODER_INTERNAL_BUFFER
Yann Collet [Mon, 25 Oct 2021 15:09:04 +0000 (08:09 -0700)] 
build macro ZSTD_DECODER_INTERNAL_BUFFER

just to make the topic more accessible for potential users.

3 years agoReduce size of dctx by reutilizing dst buffer (#2751)
binhdvo [Mon, 25 Oct 2021 14:38:01 +0000 (10:38 -0400)] 
Reduce size of dctx by reutilizing dst buffer (#2751)

* Reduce size of dctx by reutilizing dst buffer

Co-authored-by: Binh Vo <binhvo@fb.com>
3 years agoMerge pull request #2822 from marxin/fix-zstd-thread-pool-documentation
Yann Collet [Fri, 22 Oct 2021 23:46:08 +0000 (16:46 -0700)] 
Merge pull request #2822 from marxin/fix-zstd-thread-pool-documentation

Support thread pool section in HTML documentation.

3 years ago[lazy] Speed up compilation times 2828/head
Nick Terrell [Thu, 21 Oct 2021 19:52:26 +0000 (12:52 -0700)] 
[lazy] Speed up compilation times

Speed up compilation times by moving each specialized search function
into its own function. This is faster because compilers can handle many
smaller functions much faster than one gigantic function. The previous
approach generated one giant function with `switch` statements and
inlining to select the implementation.

| Compiler | Flags                               | Dev Time (s) | PR Time (s) | Delta |
|----------|-------------------------------------|--------------|-------------|-------|
| gcc      | -O3                                 |         16.5 |         5.6 |  -66% |
| gcc      | -O3 -g -fsanitize=address,undefined |        158.9 |        38.2 |  -75% |
| clang    | -O3                                 |         36.5 |         5.5 |  -85% |
| clang    | -O3 -g -fsanitize=address,undefined |         27.8 |        17.5 |  -37% |

This also reduces the binary size because the search functions are no
longer inlined into the main body.

| Compiler | Dev libzstd.a Size (B) | PR libzstd.a Size (B) | Delta |
|----------|------------------------|-----------------------|-------|
| gcc      |                1563868 |               1308844 |  -16% |
| clang    |                1924372 |               1376020 |  -28% |

Finally, the performance is not impacted significantly by this change,
in fact we generally see a small speed boost.

| Compiler | Level | Dev Speed (MB/s) | PR Speed (MB/s) | Delta |
|----------|-------|------------------|-----------------|-------|
| gcc      |     5 |            110.6 |           110.0 | -0.5% |
| gcc      |     7 |             70.4 |            72.2 | +2.5% |
| gcc      |     9 |             53.2 |            53.5 | +0.5% |
| gcc      |    13 |             12.7 |            12.9 | +1.5% |
| clang    |     5 |            113.9 |           110.4 | -3.0% |
| clang    |     7 |             67.7 |            70.6 | +4.2% |
| clang    |     9 |             51.9 |            52.2 | +0.5% |
| clang    |    13 |             12.4 |            13.3 | +7.2% |

The compression strategy is unmodified in this PR, so the compressed size
should be exactly the same. I may have a follow up PR to slightly improve
the compression ratio, if it doesn't cost too much speed.

3 years agoMerge pull request #2825 from terrelln/huf-asm-comments
Nick Terrell [Thu, 21 Oct 2021 01:06:37 +0000 (18:06 -0700)] 
Merge pull request #2825 from terrelln/huf-asm-comments

[asm] Switch to C style comments

3 years ago[asm] Switch to C style comments 2825/head
Nick Terrell [Wed, 20 Oct 2021 18:37:05 +0000 (11:37 -0700)] 
[asm] Switch to C style comments

Switch to C style comments for increased portability, and consistency.

3 years agoMerge pull request #2800 from animalize/fix_c89
Yann Collet [Mon, 18 Oct 2021 21:32:04 +0000 (14:32 -0700)] 
Merge pull request #2800 from animalize/fix_c89

Fix a C89 error in msvc

3 years agoSupport thread pool section in HTML documentation. 2822/head
Martin Liska [Fri, 15 Oct 2021 15:55:08 +0000 (17:55 +0200)] 
Support thread pool section in HTML documentation.

3 years agoMerge pull request #2774 from felixhandte/zstd-dfast-pipelined-single
Felix Handte [Wed, 13 Oct 2021 20:38:43 +0000 (16:38 -0400)] 
Merge pull request #2774 from felixhandte/zstd-dfast-pipelined-single

Pipelined Implementation of ZSTD_dfast

3 years agoConvert Outer Control Structure to Loop 2774/head
W. Felix Handte [Mon, 11 Oct 2021 19:57:29 +0000 (15:57 -0400)] 
Convert Outer Control Structure to Loop

3 years agoMerge pull request #2813 from marxin/streaming-compress-enhance
sen [Tue, 12 Oct 2021 17:05:54 +0000 (13:05 -0400)] 
Merge pull request #2813 from marxin/streaming-compress-enhance

Enhance streaming_compression examples.

3 years agoEnhance streaming_compression examples. 2813/head
Martin Liska [Mon, 4 Oct 2021 06:23:57 +0000 (08:23 +0200)] 
Enhance streaming_compression examples.

Add level argument to the first test and be more verbose about
used compression level and number of threads.

3 years agoMerge pull request #2820 from terrelln/nb-compares
Nick Terrell [Mon, 11 Oct 2021 16:59:57 +0000 (09:59 -0700)] 
Merge pull request #2820 from terrelln/nb-compares

[binary-tree] Fix underflow of nbCompares

3 years agoMerge pull request #2819 from terrelln/ldm-hash-rate-log
Nick Terrell [Fri, 8 Oct 2021 21:58:29 +0000 (14:58 -0700)] 
Merge pull request #2819 from terrelln/ldm-hash-rate-log

[ldm] Fix ZSTD_c_ldmHashRateLog bounds check

3 years agoMerge pull request #2818 from terrelln/indentation-fix
Nick Terrell [Fri, 8 Oct 2021 21:57:52 +0000 (14:57 -0700)] 
Merge pull request #2818 from terrelln/indentation-fix

[nit] Fix buggy indentation

3 years agoMerge pull request #2817 from terrelln/multiple-ddict-fix
Nick Terrell [Fri, 8 Oct 2021 21:57:29 +0000 (14:57 -0700)] 
Merge pull request #2817 from terrelln/multiple-ddict-fix

[multiple-ddicts] Fix NULL checks

3 years ago[binary-tree] Fix underflow of nbCompares 2820/head
Nick Terrell [Fri, 8 Oct 2021 18:45:30 +0000 (11:45 -0700)] 
[binary-tree] Fix underflow of nbCompares

Fix underflow of `nbCompares` by switching to an `int` and comparing
`nbCompares > 0`. This is a minimal fix, because I don't want to change
the logic. These loops seem to be doing `nbCompares + 1` comparisons.

The bug was reported by Dan Carpenter and found by Smatch static
checker.

https://lore.kernel.org/all/20211008063704.GA5370@kili/

3 years ago[multiple-ddicts] Fix NULL checks 2817/head
Nick Terrell [Fri, 8 Oct 2021 18:05:58 +0000 (11:05 -0700)] 
[multiple-ddicts] Fix NULL checks

The bug was reported by Dan Carpenter and found by Smatch static
checker.

https://lore.kernel.org/all/20211008063704.GA5370@kili/

3 years ago[ldm] Fix ZSTD_c_ldmHashRateLog bounds check 2819/head
Nick Terrell [Fri, 8 Oct 2021 18:17:40 +0000 (11:17 -0700)] 
[ldm] Fix ZSTD_c_ldmHashRateLog bounds check

There is no minimum value check, so the parameter could be negative.
Switch to the standard pattern of using `BOUNDCHECK()`.

The bug was reported by Dan Carpenter and found by Smatch static
checker.

https://lore.kernel.org/all/20211008063704.GA5370@kili/

3 years ago[nit] Fix buggy indentation 2818/head
Nick Terrell [Fri, 8 Oct 2021 18:13:11 +0000 (11:13 -0700)] 
[nit] Fix buggy indentation

The bug was reported by Dan Carpenter and found by Smatch static
checker.

https://lore.kernel.org/all/20211008063704.GA5370@kili/

3 years agoStyle: Add Comments to Variables and Move a Couple into the Loop
W. Felix Handte [Tue, 5 Oct 2021 18:53:45 +0000 (14:53 -0400)] 
Style: Add Comments to Variables and Move a Couple into the Loop

3 years agoFix Flaky Test
W. Felix Handte [Mon, 13 Sep 2021 20:35:58 +0000 (16:35 -0400)] 
Fix Flaky Test

This test depended on `_extDict` and `_noDict` compressing identically, which
is not a guarantee we make, AFAIK.

3 years agoUpdate results.csv
W. Felix Handte [Thu, 9 Sep 2021 21:17:46 +0000 (17:17 -0400)] 
Update results.csv

3 years agoSimplify DMS Implementation by Removing noDict Support
W. Felix Handte [Thu, 9 Sep 2021 21:01:31 +0000 (17:01 -0400)] 
Simplify DMS Implementation by Removing noDict Support

3 years agoFall Back in _extDict to New _noDict Rather than Old Merged Impl
W. Felix Handte [Thu, 9 Sep 2021 20:42:13 +0000 (16:42 -0400)] 
Fall Back in _extDict to New _noDict Rather than Old Merged Impl

3 years agoNit: Rename Function
W. Felix Handte [Thu, 9 Sep 2021 20:39:29 +0000 (16:39 -0400)] 
Nit: Rename Function

3 years agoNit: Unnest Blocks that Don't Declare Anything
W. Felix Handte [Wed, 8 Sep 2021 20:47:26 +0000 (16:47 -0400)] 
Nit: Unnest Blocks that Don't Declare Anything

3 years agoSearch One Last Position
W. Felix Handte [Wed, 8 Sep 2021 20:41:43 +0000 (16:41 -0400)] 
Search One Last Position

3 years agoAdvance Long Index Lookup (+0.5% Speed)
W. Felix Handte [Wed, 8 Sep 2021 20:15:01 +0000 (16:15 -0400)] 
Advance Long Index Lookup (+0.5% Speed)

This lookup can be advanced to before the short match check because either way
we will use it (in the next loop iter or in `_search_next_long`).

3 years agoWrite Back Advanced Hash in Long Matches as Well (+Ratio)
W. Felix Handte [Wed, 8 Sep 2021 16:45:42 +0000 (12:45 -0400)] 
Write Back Advanced Hash in Long Matches as Well (+Ratio)

Since we're now hashing the position ahead even if we find a long match and
don't search that next position, we can write it back into the hashtable even
in long matches. This seems to cost us no speed, and improves compression
ratio slightly!

3 years agoUse Look-Ahead Hash for Next Long Check after Short Match (+0.5% Speed)
W. Felix Handte [Wed, 8 Sep 2021 16:41:15 +0000 (12:41 -0400)] 
Use Look-Ahead Hash for Next Long Check after Short Match (+0.5% Speed)

This costs a little ratio, unfortunately.

3 years agoHash Long One Position Ahead (+2.5% Speed)
W. Felix Handte [Thu, 2 Sep 2021 16:25:08 +0000 (12:25 -0400)] 
Hash Long One Position Ahead (+2.5% Speed)

Aside from maybe a latency win in the loop, this means that when we find a
short match, we've already done the hash we need to check the next long match.

3 years agoPull Match Found Stuff Out of the Loop
W. Felix Handte [Thu, 2 Sep 2021 16:15:58 +0000 (12:15 -0400)] 
Pull Match Found Stuff Out of the Loop

3 years agoExtract Working Variables
W. Felix Handte [Thu, 2 Sep 2021 16:03:49 +0000 (12:03 -0400)] 
Extract Working Variables

3 years agoTrack Step Rather than Recalculating (+0.5% Speed)
W. Felix Handte [Wed, 1 Sep 2021 21:50:53 +0000 (17:50 -0400)] 
Track Step Rather than Recalculating (+0.5% Speed)

3 years agoExtract Single-Segment Variant of ZSTD_dfast
W. Felix Handte [Wed, 1 Sep 2021 21:26:19 +0000 (17:26 -0400)] 
Extract Single-Segment Variant of ZSTD_dfast

3 years agoLimit train samples (#2809)
stanjo74 [Tue, 5 Oct 2021 00:47:52 +0000 (17:47 -0700)] 
Limit train samples (#2809)

* Limit training samples size to 2GB

* simplified DISPLAYLEVEL() macro to use global vqriable instead of local.

* refactored training samples loading

* fixed compiler warning

* addressed comments from the pull request

* addressed @terrelln comments

* missed some fixes

* fixed type mismatch

* Fixed bug passing estimated number of samples rather insted of the loaded number of samples.
Changed unit conversion not to use bit-shifts.

* fixed a declaration after code

* fixed type conversion compile errors

* fixed more type castting

* fixed more type mismatching

* changed sizes type to size_t

* move type casting

* more type cast fixes

3 years agoMerge pull request #2747 from Helflym/dev
Yann Collet [Fri, 1 Oct 2021 15:13:39 +0000 (08:13 -0700)] 
Merge pull request #2747 from Helflym/dev

Add AIX support in Makefile

3 years agoMerge pull request #2803 from terrelln/linux-kernel-ci
Nick Terrell [Wed, 29 Sep 2021 16:48:47 +0000 (09:48 -0700)] 
Merge pull request #2803 from terrelln/linux-kernel-ci

[contrib][linux-kernel] Add standard warnings and -Werror to CI

3 years agoMerge pull request #2802 from solbjorn/fix-kernel-wundef
Nick Terrell [Wed, 29 Sep 2021 16:48:17 +0000 (09:48 -0700)] 
Merge pull request #2802 from solbjorn/fix-kernel-wundef

[contrib][linux] Fix -Wundef inside Linux kernel tree

3 years agoMerge pull request #2810 from 3nids/patch-1
Nick Terrell [Wed, 29 Sep 2021 16:47:17 +0000 (09:47 -0700)] 
Merge pull request #2810 from 3nids/patch-1

add missing BUNDLE DESTINATION

3 years agoMerge pull request #2755 from senhuang42/skip_long_matches_lazy
sen [Wed, 29 Sep 2021 16:44:07 +0000 (12:44 -0400)] 
Merge pull request #2755 from senhuang42/skip_long_matches_lazy

Skip most long matches in lazy hash table update

3 years agoadd missing BUNDLE DESTINATION 2810/head
Denis Rouzaud [Wed, 29 Sep 2021 05:09:08 +0000 (07:09 +0200)] 
add missing BUNDLE DESTINATION

fixes build on iOS

3 years agoFix ZSTD_countTrailingZeros() bug 2800/head
Ma Lin [Tue, 28 Sep 2021 01:14:19 +0000 (09:14 +0800)] 
Fix ZSTD_countTrailingZeros() bug

`>> 3` is wrong.

3 years agoUpdate regression test 2755/head
Sen Huang [Tue, 28 Sep 2021 15:29:11 +0000 (08:29 -0700)] 
Update regression test

3 years agoPull hot loop into its own function
Sen Huang [Tue, 28 Sep 2021 14:48:56 +0000 (07:48 -0700)] 
Pull hot loop into its own function

3 years agoTry beginning and end of match
Sen Huang [Thu, 23 Sep 2021 14:08:56 +0000 (07:08 -0700)] 
Try beginning and end of match

3 years agoSkip most long matches in lazy hash table update
Sen Huang [Wed, 18 Aug 2021 13:52:17 +0000 (06:52 -0700)] 
Skip most long matches in lazy hash table update

3 years agoMerge pull request #2808 from terrelln/huf-oss-fuzz-fix
Nick Terrell [Mon, 27 Sep 2021 22:00:52 +0000 (15:00 -0700)] 
Merge pull request #2808 from terrelln/huf-oss-fuzz-fix

[huf] Fix OSS-Fuzz assert

3 years agoMerge pull request #2805 from nolange/smaller_code_with_disabled_features
Felix Handte [Mon, 27 Sep 2021 21:43:21 +0000 (17:43 -0400)] 
Merge pull request #2805 from nolange/smaller_code_with_disabled_features

Smaller code with disabled features

3 years ago[huf] Fix OSS-Fuzz assert 2808/head
Nick Terrell [Mon, 27 Sep 2021 20:56:07 +0000 (13:56 -0700)] 
[huf] Fix OSS-Fuzz assert

PR #2784 introduced a bug in the decompressor that caused some valid
inputs to fail to decompress. The bitstream isn't reloaded after the 4X*
loop if the number of elements remaining is small enough, causing us to
read more bits than are available in the bitcontainer.

This was caught by the MSAN fuzzer in OSS-Fuzz because the assembly
implementation isn't used in the MSAN build.

Credit to OSS-Fuzz.

3 years agoUse __assume(0) for unreachable code path in msvc
Ma Lin [Sun, 26 Sep 2021 02:41:39 +0000 (10:41 +0800)] 
Use __assume(0) for unreachable code path in msvc

msvc will optimize away the condition check.

3 years agominor : fix comment
Yann Collet [Sun, 26 Sep 2021 15:44:18 +0000 (08:44 -0700)] 
minor : fix comment

provide correct reasons to include zstd_internal.h

3 years agoadded link to RFC
Yann Collet [Sun, 26 Sep 2021 13:58:10 +0000 (06:58 -0700)] 
added link to RFC

3 years agominor : makes the "stable" property of Zstandard format more prominent
Yann Collet [Sun, 26 Sep 2021 13:48:52 +0000 (06:48 -0700)] 
minor : makes the "stable" property of Zstandard format more prominent

3 years agozstd_decompress: use a helper function for context create 2805/head
Norbert Lange [Sun, 26 Sep 2021 08:59:05 +0000 (10:59 +0200)] 
zstd_decompress: use a helper function for context create

Multiple ZSTD_createDCtx* functions call other (public)
ZSTD_createDCtx* functions, this makes it harder for humans
and compilers to throw out code that is not used.

This farms out the logic into a static function, if a program
only uses a single ZSTD_createDCtx variant, all others can be easily
dropped and the remaining implementation can be specialized.

3 years agodecompress: conditionally remove bmi2 from context
Norbert Lange [Sun, 26 Sep 2021 09:14:35 +0000 (11:14 +0200)] 
decompress: conditionally remove bmi2 from context

Use an helper function, which will just return 0 in case
the feature is disabled.
Allows constant propagation and removal of dead code.

3 years agodecompress: conditionally remove legacy members from context
Norbert Lange [Fri, 24 Sep 2021 23:19:11 +0000 (01:19 +0200)] 
decompress: conditionally remove legacy members from context

Remove the then unneeded variables from the struct,
and all accesses to them.

3 years ago[contrib][linux] Fix -Wundef inside Linux kernel tree 2802/head
Alexander Lobakin [Fri, 24 Sep 2021 19:50:37 +0000 (21:50 +0200)] 
[contrib][linux] Fix -Wundef inside Linux kernel tree

Commit d7ef97a013b5
("[build] Fix oss-fuzz build with the dataflow sanitizer") broke
build inside Linux-kernel after 'import', as it no longer can
conditionally remove ZSTD_MEMORY_SANITIZER definition from
the #if DEF_A || DEF_B block. This emits -Wundef warning which
can be treated as error.
Split this preprocessor condition into two separate conditions
to fix this.

Fixes: d7ef97a013b5 ("[build] Fix oss-fuzz build with the dataflow sanitizer")
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
3 years agoDon't initialize the first parameter of _BitScanForward* functions
Ma Lin [Fri, 24 Sep 2021 11:40:24 +0000 (19:40 +0800)] 
Don't initialize the first parameter of _BitScanForward* functions

Like the document example, no need to initialize `r` to 0.
https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64

3 years agoDon't initialize the first parameter of _BitScanReverse* functions
Ma Lin [Fri, 24 Sep 2021 11:24:29 +0000 (19:24 +0800)] 
Don't initialize the first parameter of _BitScanReverse* functions

Like the document example, no need to initialize `r` to 0.
https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanreverse-bitscanreverse64

3 years agoFix a C89 error in msvc
Ma Lin [Fri, 24 Sep 2021 00:57:16 +0000 (08:57 +0800)] 
Fix a C89 error in msvc

Variables (r) must be declared at the beginning of a code block.
This causes msvc2012 to fail to compile 64-bit build.

3 years ago[contrib][linux-kernel] Add standard warnings and -Werror to CI 2803/head
Nick Terrell [Fri, 24 Sep 2021 21:46:45 +0000 (14:46 -0700)] 
[contrib][linux-kernel] Add standard warnings and -Werror to CI

Test the kernel build with the standard warnings enabled so that we
don't miss issues like fixed in PR #2802.

Stacked on top of PR #2802 so CI passes, so it includes the fix. But, I
won't merge until it is merged, so @solbjorn gets the credit for the
fix.

3 years agoMerge pull request #2790 from solbjorn/huf-asm-kernel
Nick Terrell [Fri, 24 Sep 2021 19:42:03 +0000 (12:42 -0700)] 
Merge pull request #2790 from solbjorn/huf-asm-kernel

[contrib][linux] Fix build after introducing ASM HUF implementation

3 years agoMerge pull request #2796 from terrelln/linux-fixes
Nick Terrell [Thu, 23 Sep 2021 23:11:53 +0000 (16:11 -0700)] 
Merge pull request #2796 from terrelln/linux-fixes

[lib] Make lib compatible with `-Wfall-through` excepting legacy

3 years agoMerge pull request #2799 from terrelln/oss-fuzz-build
Nick Terrell [Thu, 23 Sep 2021 22:55:10 +0000 (15:55 -0700)] 
Merge pull request #2799 from terrelln/oss-fuzz-build

[build] Fix oss-fuzz build with the dataflow sanitizer

3 years agoMerge pull request #2798 from abxhr/typo-fix
Nick Terrell [Thu, 23 Sep 2021 20:11:45 +0000 (13:11 -0700)] 
Merge pull request #2798 from abxhr/typo-fix

Fix typo

3 years ago[build] Fix oss-fuzz build with the dataflow sanitizer 2799/head
Nick Terrell [Thu, 23 Sep 2021 18:48:39 +0000 (11:48 -0700)] 
[build] Fix oss-fuzz build with the dataflow sanitizer

The dataflow sanitizer requires all code to be instrumented. We can't
instrument the ASM function, so we have to disable it.