]> git.ipfire.org Git - thirdparty/zstd.git/log
thirdparty/zstd.git
2 years agofixed incorrect assert 3248/head
Yann Collet [Thu, 29 Dec 2022 01:23:40 +0000 (17:23 -0800)] 
fixed incorrect assert

commented Fweight instead

2 years agojust add some comments to zstd_opt for improved clarity
Yann Collet [Fri, 19 Aug 2022 23:04:28 +0000 (16:04 -0700)] 
just add some comments to zstd_opt for improved clarity

2 years agoMerge pull request #3400 from danlark1/dev
Yann Collet [Wed, 28 Dec 2022 23:50:26 +0000 (15:50 -0800)] 
Merge pull request #3400 from danlark1/dev

Move deprecated annotation before static to allow C++ compilation for clang

2 years agoMerge pull request #3395 from terrelln/2022-12-21-deprecated-test
Yann Collet [Wed, 28 Dec 2022 23:49:50 +0000 (15:49 -0800)] 
Merge pull request #3395 from terrelln/2022-12-21-deprecated-test

[tests] Remove deprecated function from longmatch.c test

2 years agoupdate ZSTD_CCts_setCParams() inline documentation
Yann Collet [Wed, 28 Dec 2022 23:08:18 +0000 (15:08 -0800)] 
update ZSTD_CCts_setCParams() inline documentation

specify behavior when changing compression parameters during MT compression,
reported by @embg

2 years agoMerge pull request #3403 from facebook/setCParams
Yann Collet [Wed, 28 Dec 2022 22:07:13 +0000 (14:07 -0800)] 
Merge pull request #3403 from facebook/setCParams

ZSTD_CCtx_setCParams

2 years agoExternal matchfinder API (#3333)
Elliot Gorokhovsky [Wed, 28 Dec 2022 21:45:14 +0000 (16:45 -0500)] 
External matchfinder API (#3333)

* First building commit with sample matchfinder

* Set up ZSTD_externalMatchCtx struct

* move seqBuffer to ZSTD_Sequence*

* support non-contiguous dictionary

* clean up parens

* add clearExternalMatchfinder, handle allocation errors

* Add useExternalMatchfinder cParam

* validate useExternalMatchfinder cParam

* Disable LDM + external matchfinder

* Check for static CCtx

* Validate mState and mStateDestructor

* Improve LDM check to cover both branches

* Error API with optional fallback

* handle RLE properly for external matchfinder

* nit

* Move to a CDict-like model for resource ownership

* Add hidden useExternalMatchfinder bool to CCtx_params_s

* Eliminate malloc, move to cwksp allocation

* Handle CCtx reset properly

* Ensure seqStore has enough space for external sequences

* fix capitalization

* Add DEBUGLOG statements

* Add compressionLevel param to matchfinder API

* fix c99 issues and add a param combination error code

* nits

* Test external matchfinder API

* C90 compat for simpleExternalMatchFinder

* Fix some @nocommits and an ASAN bug

* nit

* nit

* nits

* forward declare copySequencesToSeqStore functions in zstd_compress_internal.h

* nit

* nit

* nits

* Update copyright headers

* Fix CMake zstreamtest build

* Fix copyright headers (again)

* typo

* Add externalMatchfinder demo program to make contrib

* Reduce memory consumption for small blockSize

* ZSTD_postProcessExternalMatchFinderResult nits

* test sum(matchlen) + sum(litlen) == srcSize in debug builds

* refExternalMatchFinder -> registerExternalMatchFinder

* C90 nit

* zstreamtest nits

* contrib nits

* contrib nits

* allow block splitter + external matchfinder, refactor

* add windowSize param

* add contrib/externalMatchfinder/README.md

* docs

* go back to old RLE heuristic because of the first block issue

* fix initializer element is not a constant expression

* ref contrib from zstd.h

* extremely pedantic compiler warning fix, meson fix, typo fix

* Additional docs on API limitations

* minor nits

* Refactor maxNbSeq calculation into a helper function

* Fix copyright

2 years agoSignal parameter change during MT compression 3403/head
Yann Collet [Wed, 28 Dec 2022 21:14:58 +0000 (13:14 -0800)] 
Signal parameter change during MT compression

2 years agoNew xp library symbol : ZSTD_CCtx_setCParams()
Yann Collet [Wed, 28 Dec 2022 07:40:34 +0000 (23:40 -0800)] 
New xp library symbol : ZSTD_CCtx_setCParams()

Inspired by #3395,
offer a new capability to set all parameters defined in a ZSTD_compressionParameters structure
with a single symbol invocation
to improve user code brevity.

2 years agoMerge pull request #3394 from terrelln/issue-3010
Yann Collet [Wed, 28 Dec 2022 00:20:05 +0000 (16:20 -0800)] 
Merge pull request #3394 from terrelln/issue-3010

[cli-tests] Test file stat read/write

2 years agocmake build: fix nit
Yann Collet [Fri, 23 Dec 2022 22:18:11 +0000 (14:18 -0800)] 
cmake build: fix nit

reported by @jaimeMF in https://github.com/facebook/zstd/pull/3392#discussion_r1056643794

2 years agoMove deprecated annotation before static to allow C++ compilation for clang 3400/head
Daniel Kutenin [Fri, 23 Dec 2022 12:07:31 +0000 (12:07 +0000)] 
Move deprecated annotation before static to allow C++ compilation for clang

This fixes last 2 instances of https://github.com/facebook/zstd/issues/3250

2 years agoMerge pull request #3398 from facebook/fix3316
Yann Collet [Fri, 23 Dec 2022 00:57:05 +0000 (16:57 -0800)] 
Merge pull request #3398 from facebook/fix3316

spec update : require minimum nb of literals for 4-streams mode

2 years agospec update : require minimum nb of literals for 4-streams mode 3398/head
Yann Collet [Thu, 22 Dec 2022 19:30:15 +0000 (11:30 -0800)] 
spec update : require minimum nb of literals for 4-streams mode

Reported by @shulib :
the specification for 4-streams mode
doesn't work when the amount of literals to compress is 5 bytes.
Extending it, it also doesn't work for sizes 1 or 2.

This patch updates the specification and the implementation
to require a minimum of 6 literals to trigger or accept the 4-streams mode.

The impact is expected to be a no-op :
the 4-streams mode is never triggered for such small quantity of literals anyway,
since it would be wasteful (it costs ~7.3 bytes more than single-stream mode).
An informal lower limit is set at ~256 bytes,
so the technical minimum is very far from this limit.

This is just meant for completeness of the specification.

2 years agoMerge pull request #3399 from facebook/fix2577
Yann Collet [Thu, 22 Dec 2022 22:05:36 +0000 (14:05 -0800)] 
Merge pull request #3399 from facebook/fix2577

Support decompression of compressed blocks of size ZSTD_BLOCKSIZE_MAX

2 years agoSupport decompression of compressed blocks of size ZSTD_BLOCKSIZE_MAX exactly 3399/head
Yann Collet [Thu, 22 Dec 2022 20:40:27 +0000 (12:40 -0800)] 
Support decompression of compressed blocks of size ZSTD_BLOCKSIZE_MAX exactly

2 years agoMerge pull request #3397 from felixhandte/man-page-tweaks
Felix Handte [Thu, 22 Dec 2022 19:49:59 +0000 (14:49 -0500)] 
Merge pull request #3397 from felixhandte/man-page-tweaks

Man Page Tweaks, Edits, Formatting Fixes

2 years ago`make man` 3397/head
W. Felix Handte [Thu, 22 Dec 2022 19:13:24 +0000 (14:13 -0500)] 
`make man`

2 years agoMan Page Tweaks, Edits, Formatting Fixes
W. Felix Handte [Thu, 22 Dec 2022 19:04:36 +0000 (14:04 -0500)] 
Man Page Tweaks, Edits, Formatting Fixes

This started as an application of the edits suggested in #3201 and expanded
from there.

2 years ago[cli-tests] Add tests that use --trace-file-stat 3394/head
Nick Terrell [Thu, 22 Dec 2022 01:36:27 +0000 (17:36 -0800)] 
[cli-tests] Add tests that use --trace-file-stat

Basic tests for (de)compressing in the following modes:
* file to file
* file to stdout
* stdin to file
* stdin to stdout

These are basic tests, and aren't testing more advanced scenarios, but
it adds the groundwork for more complex tests as needed.

Fixes #3010.

2 years ago[tests] Remove deprecated function from longmatch.c test 3395/head
Nick Terrell [Thu, 22 Dec 2022 01:48:24 +0000 (17:48 -0800)] 
[tests] Remove deprecated function from longmatch.c test

Thanks to @eli-schwartz for pointing it out!

We should maybe consider adding a helper function for applying
`ZSTD_parameters` and `ZSTD_compressionParameters` to a context.
That would aid the transition to the new API in situations like this.

2 years agoFix `make clangbuild` & add CI
Nick Terrell [Thu, 22 Dec 2022 00:09:25 +0000 (16:09 -0800)] 
Fix `make clangbuild` & add CI

Fix the errors for:
* `-Wdocumentation`
* `-Wconversion` except `-Wsign-conversion`

2 years ago[cmake] Add noexecstack to compiler/linker flags
Nick Terrell [Wed, 21 Dec 2022 23:02:27 +0000 (15:02 -0800)] 
[cmake] Add noexecstack to compiler/linker flags

2 years ago[cli-tests] Add --set-exact-output to update the expected output
Nick Terrell [Thu, 22 Dec 2022 01:21:09 +0000 (17:21 -0800)] 
[cli-tests] Add --set-exact-output to update the expected output

`./run.py --set-exact-output` will update `stdout.expect` and
`stderr.expect` to match the expected output. This doesn't apply to
outputs which use `.glob` or `.ignore`.

2 years ago[util] Add traces enabled by --trace-file-stat
Nick Terrell [Thu, 22 Dec 2022 01:00:44 +0000 (17:00 -0800)] 
[util] Add traces enabled by --trace-file-stat

Print traces to stderr when --trace-file-stat is passed.
We trace all functions that read and write file metadata.

2 years agoMerge pull request #3385 from jonpalmisc/improve_help
Yann Collet [Wed, 21 Dec 2022 18:56:09 +0000 (10:56 -0800)] 
Merge pull request #3385 from jonpalmisc/improve_help

Improve help/usage (`-h`, `-H`) formatting

2 years agoMerge pull request #3386 from felixhandte/pin-other-action-commit-hashes
Felix Handte [Wed, 21 Dec 2022 16:24:23 +0000 (11:24 -0500)] 
Merge pull request #3386 from felixhandte/pin-other-action-commit-hashes

Pin Remaining Action Dependencies (Except OSS-Fuzz)

2 years agoUpdate tests to expect new CLI help output 3385/head
Jon Palmisciano [Wed, 21 Dec 2022 01:11:37 +0000 (20:11 -0500)] 
Update tests to expect new CLI help output

2 years agoClean up welcome message
Jon Palmisciano [Wed, 21 Dec 2022 01:11:23 +0000 (20:11 -0500)] 
Clean up welcome message

2 years agoRewrite help output to improve readability
Jon Palmisciano [Tue, 20 Dec 2022 20:34:02 +0000 (15:34 -0500)] 
Rewrite help output to improve readability

2 years agoPin Remaining Action Dependencies (Except OSS-Fuzz) 3386/head
W. Felix Handte [Tue, 20 Dec 2022 22:10:01 +0000 (17:10 -0500)] 
Pin Remaining Action Dependencies (Except OSS-Fuzz)

The one that isn't pinned is the OSS-Fuzz builder and runner. They don't
offer tagged releases. I could pin to the current master commit, but I'm not
sure how desirable that is.

2 years agoMerge pull request #3384 from felixhandte/pin-checkout-action-commit-hash
Felix Handte [Tue, 20 Dec 2022 21:08:03 +0000 (16:08 -0500)] 
Merge pull request #3384 from felixhandte/pin-checkout-action-commit-hash

Pin actions/checkout Dependency to Specific Commit Hash

2 years ago[build][cmake] Fix cmake with custom assembler
Nick Terrell [Tue, 20 Dec 2022 02:54:22 +0000 (18:54 -0800)] 
[build][cmake] Fix cmake with custom assembler

Tell CMake to explicitly compile our assembly as C code, because we
require it is compiled by a C compiler, and it is only enabled for
clang/gcc.

Fixes #3193.

2 years agoPin actions/checkout Dependency to Specific Commit Hash 3384/head
W. Felix Handte [Tue, 20 Dec 2022 19:17:59 +0000 (14:17 -0500)] 
Pin actions/checkout Dependency to Specific Commit Hash

It's a bit silly, because if we can't trust GitHub, what are we doing here?
But OSSF complains about it, so let's fix it.

2 years agoMerge pull request #3378 from facebook/dependabot/github_actions/github/codeql-action...
Felix Handte [Tue, 20 Dec 2022 19:17:33 +0000 (14:17 -0500)] 
Merge pull request #3378 from facebook/dependabot/github_actions/github/codeql-action-2.1.37

Bump github/codeql-action from 1.0.26 to 2.1.37

2 years agoMerge pull request #3377 from facebook/dependabot/github_actions/ossf/scorecard-actio...
Felix Handte [Tue, 20 Dec 2022 19:16:10 +0000 (14:16 -0500)] 
Merge pull request #3377 from facebook/dependabot/github_actions/ossf/scorecard-action-2.1.0

Bump ossf/scorecard-action from 2.0.6 to 2.1.0

2 years agoMerge pull request #3340 from facebook/dependabot/github_actions/actions/upload-artif...
Felix Handte [Tue, 20 Dec 2022 19:15:43 +0000 (14:15 -0500)] 
Merge pull request #3340 from facebook/dependabot/github_actions/actions/upload-artifact-3

Bump actions/upload-artifact from 1 to 3

2 years ago[docs] Clarify dictionary loading documentation
Nick Terrell [Tue, 20 Dec 2022 02:08:35 +0000 (18:08 -0800)] 
[docs] Clarify dictionary loading documentation

Reinforce that loading a new dictionary clears the current dictionary.
Except for the multiple-ddict mode.

2 years agoMerge pull request #3173 from felixhandte/update-copyright-company
Felix Handte [Tue, 20 Dec 2022 18:51:01 +0000 (13:51 -0500)] 
Merge pull request #3173 from felixhandte/update-copyright-company

Update Copyright Comments

2 years agoCoalesce Almost All Copyright Notices to Standard Phrasing 3173/head
W. Felix Handte [Tue, 20 Dec 2022 17:49:47 +0000 (12:49 -0500)] 
Coalesce Almost All Copyright Notices to Standard Phrasing

```
for f in $(find . \( -path ./.git -o -path ./tests/fuzz/corpora -o -path ./tests/regression/data-cache -o -path ./tests/regression/cache \) -prune -o -type f); do sed -i '/Copyright .* \(Yann Collet\)\|\(Meta Platforms\)/ s/Copyright .*/Copyright (c) Meta Platforms, Inc. and affiliates./' $f; done

git checkout HEAD -- build/VS2010/libzstd-dll/libzstd-dll.rc build/VS2010/zstd/zstd.rc tests/test-license.py contrib/linux-kernel/test/include/linux/xxhash.h examples/streaming_compression_thread_pool.c lib/legacy/zstd_v0*.c lib/legacy/zstd_v0*.h
nano ./programs/windres/zstd.rc
nano ./build/VS2010/zstd/zstd.rc
nano ./build/VS2010/libzstd-dll/libzstd-dll.rc
```

2 years agoRewrite Copyright Date Ranges from `-present` to `-2022`
W. Felix Handte [Tue, 20 Dec 2022 17:44:56 +0000 (12:44 -0500)] 
Rewrite Copyright Date Ranges from `-present` to `-2022`

Apparently it's better. Somehow.

```
for f in $(find . \( -path ./.git -o -path ./tests/fuzz/corpora -o -path ./tests/regression/data-cache -o -path ./tests/regression/cache \) -prune -o -type f); do echo $f; sed -i 's/\-present/-2022/' $f; done

g co HEAD -- build/meson/
```

2 years agoUpdate test-license.py
W. Felix Handte [Tue, 21 Jun 2022 16:11:22 +0000 (12:11 -0400)] 
Update test-license.py

2 years agoUpdate Copyright Year ('2021' -> 'present')
W. Felix Handte [Tue, 20 Dec 2022 17:42:50 +0000 (12:42 -0500)] 
Update Copyright Year ('2021' -> 'present')

```
for f in $(find . \( -path ./.git -o -path ./tests/fuzz/corpora -o -path ./tests/regression/data-cache -o -path ./tests/regression/cache \) -prune -o -type f);
do
  sed -i 's/\-2021/-present/' $f;
done

g co HEAD -- .github/workflows/dev-short-tests.yml # fix bad match
```

2 years agoUpdate Copyright Headers 'Facebook' -> 'Meta Platforms'
W. Felix Handte [Tue, 20 Dec 2022 17:37:57 +0000 (12:37 -0500)] 
Update Copyright Headers 'Facebook' -> 'Meta Platforms'

```
for f in $(find . \( -path ./.git -o -path ./tests/fuzz/corpora \) -prune -o -type f);
do
  sed -i 's/Facebook, Inc\./Meta Platforms, Inc. and affiliates./' $f;
done
```

2 years agoManually Update VS Code Copyright Definitions
W. Felix Handte [Tue, 21 Jun 2022 15:54:13 +0000 (11:54 -0400)] 
Manually Update VS Code Copyright Definitions

2 years agoMerge pull request #3289 from nmoinvaz/cmake/playtest-win
Yann Collet [Tue, 20 Dec 2022 00:39:38 +0000 (16:39 -0800)] 
Merge pull request #3289 from nmoinvaz/cmake/playtest-win

Don't attempt playTests.sh cmake test if running on Windows.

2 years agoMerge pull request #3364 from yoniko/fix-windows-mt-thread-resize-bug
Yonatan Komornik [Mon, 19 Dec 2022 23:54:01 +0000 (15:54 -0800)] 
Merge pull request #3364 from yoniko/fix-windows-mt-thread-resize-bug

Windows MT layer bug fixes

2 years agoCR fixes 3364/head
Yonatan Komornik [Mon, 19 Dec 2022 21:22:34 +0000 (13:22 -0800)] 
CR fixes

2 years ago[pzstd] Fixes for Windows build
Nick Terrell [Mon, 19 Dec 2022 20:23:29 +0000 (12:23 -0800)] 
[pzstd] Fixes for Windows build

* Add `Portability.h` to fix min/max issues.
* Fix conversion warnings
* Assert that windowLog <= 23, which is currently always the case.
  This could be loosened, but we aren't looking to add new functionality.

Fixes on top of PR #3375 by @eli-schwartz, which added Windows CI for contrib & programs.

2 years agoCI: build contrib directory on meson-windows
Eli Schwartz [Sun, 18 Dec 2022 02:24:31 +0000 (21:24 -0500)] 
CI: build contrib directory on meson-windows

2 years agoCI: build programs on meson-windows too
Eli Schwartz [Sun, 18 Dec 2022 02:09:48 +0000 (21:09 -0500)] 
CI: build programs on meson-windows too

2 years agoMerge pull request #3376 from facebook/split2
Yann Collet [Mon, 19 Dec 2022 21:00:27 +0000 (13:00 -0800)] 
Merge pull request #3376 from facebook/split2

Block splitter : minor reformatting

2 years agoBump github/codeql-action from 1.0.26 to 2.1.37 3378/head
dependabot[bot] [Mon, 19 Dec 2022 05:07:15 +0000 (05:07 +0000)] 
Bump github/codeql-action from 1.0.26 to 2.1.37

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1.0.26 to 2.1.37.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/5f532563584d71fdef14ee64d17bafb34f751ce5...959cbb7472c4d4ad70cdfe6f4976053fe48ab394)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years agoBump ossf/scorecard-action from 2.0.6 to 2.1.0 3377/head
dependabot[bot] [Mon, 19 Dec 2022 05:07:09 +0000 (05:07 +0000)] 
Bump ossf/scorecard-action from 2.0.6 to 2.1.0

Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.0.6 to 2.1.0.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/99c53751e09b9529366343771cc321ec74e9bd3d...937ffa90d79c7d720498178154ad4c7ba1e4ad8c)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years agominor reformatting 3376/head
Yann Collet [Sun, 18 Dec 2022 12:12:32 +0000 (04:12 -0800)] 
minor reformatting

and minor reliability and maintenance changes

2 years agomeson: zstreamtests should now pass on Windows
Yonatan Komornik [Sat, 17 Dec 2022 02:33:49 +0000 (18:33 -0800)] 
meson: zstreamtests should now pass on Windows

2 years agoFix race condition in the Windows thread / pthread translation layer
Yonatan Komornik [Sat, 17 Dec 2022 02:24:02 +0000 (18:24 -0800)] 
Fix race condition in the Windows thread / pthread translation layer

When spawning a Windows thread we have small worker wrapper function that translates
between the interfaces of Windows and POSIX threads.
This wrapper is given a pointer that might get stale before the worker starts running,
resulting in UB and crashes.
This commit adds synchronization so that we know the wrapper has finished reading the data
it needs before we allow the main thread to resume execution.

2 years agoFixes two bugs in the Windows thread / pthread translation layer
Yonatan Komornik [Fri, 16 Dec 2022 00:11:56 +0000 (16:11 -0800)] 
Fixes two bugs in the Windows thread / pthread translation layer

1. If threads are resized the threads' `ZSTD_pthread_t` might move
while the worker still holds a pointer into it (see more details in #3120).
2. The join operation was waiting for a thread and then return its `thread.arg`
as a return value, but since the `ZSTD_pthread_t thread` was passed by value it
would have a stale `arg` that wouldn't match the thread's actual return value.

This fix changes the `ZSTD_pthread_join` API and removes support for returning
a value. This means that we are diverging from the `pthread_join` API and this
is no longer just an alias.
In the future, if needed, we could return a Windows thread's return value using
`GetExitCodeThread`, but as this path wouldn't be excised in any case, it's
preferable to not add it right now.

2 years agoMerge pull request #3374 from yoniko/fix-meson-ci-dependancy
Yonatan Komornik [Sat, 17 Dec 2022 21:36:56 +0000 (13:36 -0800)] 
Merge pull request #3374 from yoniko/fix-meson-ci-dependancy

Fix Meson-Windows CI test by pulling a more recent version msvc-dev-cmd

2 years agomeson: Fix Windows CI test by pulling a more recent version msvc-dev-cmd 3374/head
Yonatan Komornik [Sat, 17 Dec 2022 18:33:49 +0000 (10:33 -0800)] 
meson: Fix Windows CI test by pulling a more recent version msvc-dev-cmd

2 years agoMerge pull request #3120 from eli-schwartz/meson-fixup
Yonatan Komornik [Sat, 17 Dec 2022 02:28:54 +0000 (18:28 -0800)] 
Merge pull request #3120 from eli-schwartz/meson-fixup

Meson test fixups

2 years agoMerge pull request #3373 from facebook/decompressBound
Yann Collet [Sat, 17 Dec 2022 00:55:30 +0000 (16:55 -0800)] 
Merge pull request #3373 from facebook/decompressBound

decompressBound tests and fix

2 years agomake ZSTD_DECOMPRESSBOUND() compatible with input size 0 3373/head
Yann Collet [Fri, 16 Dec 2022 23:58:25 +0000 (15:58 -0800)] 
make ZSTD_DECOMPRESSBOUND() compatible with input size 0

for environments with stringent compilation warnings.

2 years agodecompressBound() tests
Yann Collet [Fri, 16 Dec 2022 23:32:19 +0000 (15:32 -0800)] 
decompressBound() tests

fixed an overflow in an intermediate result on 32-bit platform.
Checked that the new test catch this bug in 32-bit mode.

2 years agoMerge pull request #3362 from facebook/compressBound
Yann Collet [Fri, 16 Dec 2022 22:22:22 +0000 (14:22 -0800)] 
Merge pull request #3362 from facebook/compressBound

check potential overflow of compressBound()

2 years ago[zdict] Fix static linking only include guards
Nick Terrell [Fri, 16 Dec 2022 20:04:50 +0000 (12:04 -0800)] 
[zdict] Fix static linking only include guards

Fix `zdict.h` static linking only section so if you include it twice it
still exposes the static linking only symbols. E.g. this pattern:

```
```

This can easily happen when a header you include includes `zdict.h`.

2 years ago[build] Fix ZSTD_LIB_MINIFY build option
Nick Terrell [Fri, 16 Dec 2022 00:40:04 +0000 (16:40 -0800)] 
[build] Fix ZSTD_LIB_MINIFY build option

`ZSTD_LIB_MINIFY` broke in 8bf699aa59372d7c2bb4216bcf8037cab7dae51e.

This commit fixes the macro and the static library shrinks from ~600K to 324K
with ZSTD_LIB_MINIFY set.

Fixes #3066.

2 years ago[api][visibility] Make the visibility macros more consistent
Nick Terrell [Thu, 15 Dec 2022 23:46:34 +0000 (15:46 -0800)] 
[api][visibility] Make the visibility macros more consistent

1. Follow the scheme introduced in PR #2501 for both `zdict.h` and `zstd_errors.h`.
2. If the `*_VISIBLE` macro isn't set, but the `*_VISIBILITY` macro is, use that.
   Also make this change for `zstd.h`, since we probably shouldn't have changed
   that macro name without backward compatibility in the first place.
3. Change all references to `*_VISIBILITY` to `*_VISIBLE`.

Fixes #3359.

2 years agoadded unit tests for compressBound() 3362/head
Yann Collet [Fri, 16 Dec 2022 20:28:26 +0000 (12:28 -0800)] 
added unit tests for compressBound()

and rephrased the code documentation, as suggested by @terrelln

2 years ago[CI] Re-enable versions-test
Nick Terrell [Fri, 16 Dec 2022 18:33:38 +0000 (10:33 -0800)] 
[CI] Re-enable versions-test

It seems like with the deletion of Travis CI we didn't successfully transfer the
version compatibility test. Attempt to enable the version compatibility test.

2 years agomeson: mark a known test failure on Windows 3120/head
Eli Schwartz [Wed, 20 Apr 2022 01:08:02 +0000 (21:08 -0400)] 
meson: mark a known test failure on Windows

2 years agomeson: add Windows CI
Eli Schwartz [Thu, 15 Dec 2022 02:57:59 +0000 (21:57 -0500)] 
meson: add Windows CI

There are a couple of oddities here. We don't attempt to build e.g.
contrib, because that doesn't seem to work at the moment. Also notice
that each command is its own step. This happens because github actions
runs in powershell, which doesn't seem to let you abort on the first
failure.

2 years agomeson: add Linux CI
Eli Schwartz [Thu, 15 Dec 2022 02:46:09 +0000 (21:46 -0500)] 
meson: add Linux CI

Travis is no longer run, but this wasn't ported to something else.

2 years agomeson: add support for running both fast and slow version of tests
Eli Schwartz [Thu, 15 Dec 2022 02:10:41 +0000 (21:10 -0500)] 
meson: add support for running both fast and slow version of tests

playTests.sh has an option to run really slow tests. This is enabled by
default in Meson, but what we really want is to do like the Makefile,
and run the fast ones by default, but with an option to run the slow
ones instead.

2 years agomeson: don't require valgrind tests
Eli Schwartz [Wed, 20 Apr 2022 00:58:33 +0000 (20:58 -0400)] 
meson: don't require valgrind tests

It's entirely possible some people don't have valgrind installed, but
still want to run the tests. If they don't have it installed, then they
probably don't intend to run those precise test targets anyway.

Also, this solves an error when running the tests in an automated
environment. The valgrind tests have a hard dependency on behavior such
as `./zstd` erroring out with the message "stdin is a console, aborting"
which does not work if the automated environment doesn't have a console.
As a rough heuristic, automated environments lacking a console will
*probably* also not have valgrind, so avoiding that test definition
neatly sidesteps the issue.

Also, valgrind is not easily installable on macOS, at least homebrew
says it isn't available there. This makes it needlessly hard to
enable the testsuite on macOS.

2 years ago[circleci] Try to re-enable aarch64build
Nick Terrell [Fri, 16 Dec 2022 00:55:31 +0000 (16:55 -0800)] 
[circleci] Try to re-enable aarch64build

Update CircleCI to focal and try to re-enable aarch64build.

Fixes #2785 if it works.

2 years agoMerge pull request #3368 from eli-schwartz/meson-execinfo-bool
Yonatan Komornik [Fri, 16 Dec 2022 17:14:53 +0000 (09:14 -0800)] 
Merge pull request #3368 from eli-schwartz/meson-execinfo-bool

meson: fix broken commit that broke the build

2 years agoAdd missing parens around macro definition
Nick Terrell [Fri, 16 Dec 2022 00:22:26 +0000 (16:22 -0800)] 
Add missing parens around macro definition

Fixes #3301.

2 years agomeson: fix warning for using too-new features 3368/head
Eli Schwartz [Fri, 16 Dec 2022 00:34:25 +0000 (19:34 -0500)] 
meson: fix warning for using too-new features

In commit 031de3c69ccbf3282ed02fb49369b476730aeca8 a feature of Meson
0.50.0 was added, but the minimum specified version of Meson is 0.48.0.
Meson therefore emitted a warning:

WARNING: Project targets '>=0.48.0' but uses feature introduced in '0.50.0': required arg in compiler.has_header.

And if anyone actually used Meson 0.48.0 to build with, it would error
out with mysterious claims that the build file itself is invalid, rather
than telling the user to install a newer version of Meson.

Solve this by bumping the minimum version to align with reality. This
e.g. drops support for Debian oldstable (buster)'s packaged version of
Meson, but still works if backports are enabled, or if the user can
`pip install` a newer version.

2 years agomeson: fix broken commit that broke the build
Eli Schwartz [Fri, 16 Dec 2022 00:48:22 +0000 (19:48 -0500)] 
meson: fix broken commit that broke the build

In commit 031de3c69ccbf3282ed02fb49369b476730aeca8 some code was added
that returned a boolean, but was treated as if it returned a dependency
object. This wasn't tested and could not work. Moreover, zstd no longer
built at all unless the entire programs directory was disabled and not
even evaluated.

Fix the return type checking.

2 years agoMerge branch 'dev' of github.com:facebook/zstd into dev
Yann Collet [Thu, 15 Dec 2022 23:58:42 +0000 (15:58 -0800)] 
Merge branch 'dev' of github.com:facebook/zstd into dev

2 years agoUpdate documentation link to html format
Yann Collet [Thu, 15 Dec 2022 23:56:11 +0000 (15:56 -0800)] 
Update documentation link to html format

fix #3319

2 years agomeson: partial fix for building pzstd on MSVC
Eli Schwartz [Wed, 14 Dec 2022 22:23:24 +0000 (17:23 -0500)] 
meson: partial fix for building pzstd on MSVC

It uses non-portable compiler options unconditionally. Elsewhere, we
check the compiler ID and only add the right ones, globally. Do the same
here.

NDEBUG can actually be handled by a core option, so while we are moving
things around, do so.

Unfortunately, this doesn't fix things entirely. The remaining issue is
not Meson's issue though -- MSVC simply does not like this source code
and somehow chokes on innocent code with the inscrutable "syntax error"
and "illegal token".

2 years agocheck potential overflow of compressBound()
Yann Collet [Thu, 15 Dec 2022 23:23:15 +0000 (15:23 -0800)] 
check potential overflow of compressBound()

fixed #3323, reported by @nigeltao

Completed documentation around this risk
(which is largely theoretical,
I can't see that happening in any "real world" scenario,
but an erroneous @srcSize value could indeed trigger it).

2 years agoFix corruption that rarely occurs in 32-bit mode with wlog=25
Nick Terrell [Thu, 15 Dec 2022 21:43:27 +0000 (13:43 -0800)] 
Fix corruption that rarely occurs in 32-bit mode with wlog=25

Fix an off-by-one error in the compressor that emits corrupt blocks if:

* Zstd is compiled in 32-bit mode
* The windowLog == 25 exactly
* An offset of 2^25-3, 2^25-2, 2^25-1, or 2^25 is emitted
* The bitstream had 7 bits leftover before writing the offset

This bug has been present since before v1.0, but wasn't able to easily
be triggered, since until somewhat recently zstd wasn't able to find
matches that were within 128KB of the window size.

Add a test case, and fix 2 bugs in `ZSTD_compressSequences()`:
* The `ZSTD_isRLE()` check was incorrect. It wouldn't produce
  corruption, but it could waste CPU and not emit RLE even if the block
  was RLE
* One windowSize was `1 << windowLog`, not `1u << windowLog`

Thanks to @tansy for finding the issue, and giving us a reproducer!

Fixes Issue #3350.

2 years agoadded mention of compilation flags
Yann Collet [Thu, 15 Dec 2022 18:46:47 +0000 (10:46 -0800)] 
added mention of compilation flags

2 years agoMerge pull request #3352 from daniellerozenblit/http-to-https
daniellerozenblit [Thu, 15 Dec 2022 16:25:55 +0000 (11:25 -0500)] 
Merge pull request #3352 from daniellerozenblit/http-to-https

Convert references to https from http

2 years agoMerge branch 'dev' into http-to-https 3352/head
daniellerozenblit [Thu, 15 Dec 2022 15:46:13 +0000 (10:46 -0500)] 
Merge branch 'dev' into http-to-https

2 years ago[legacy] Remove FORCE_MEMORY_ACCESS and only use memcpy
Nick Terrell [Thu, 15 Dec 2022 00:07:22 +0000 (16:07 -0800)] 
[legacy] Remove FORCE_MEMORY_ACCESS and only use memcpy

Delete unaligned memory access code from the legacy codebase by removing all the
non-memcpy functions. We don't care about speed at all for this codebase, only
simplicity.

2 years ago[decompress] Fix nullptr addition & improve fuzzer
Nick Terrell [Thu, 15 Dec 2022 01:00:54 +0000 (17:00 -0800)] 
[decompress] Fix nullptr addition & improve fuzzer

Fix an instance of `NULL + 0` in `ZSTD_decompressStream()`. Also, improve our
`stream_decompress` fuzzer to pass `NULL` in/out buffers to
`ZSTD_decompressStream()`, and fix 2 issues that were immediately surfaced.

Fixes #3351

2 years ago[fileio] Separate parameter adaption from display update rate
Nick Terrell [Wed, 14 Dec 2022 23:17:05 +0000 (15:17 -0800)] 
[fileio] Separate parameter adaption from display update rate

Split the logic for parameter adaption from the logic to update the display rate.
This decouples the two updates, so changes to display updates don't affect
parameter adaption.

Also add a test case that checks that parameter adaption actually happens.

This fixes Issue #3353, where --adapt is broken when --no-progress is passed.

2 years agoUse proper unaligned access attributes
Alex Xu (Hello71) [Mon, 29 Nov 2021 02:54:24 +0000 (21:54 -0500)] 
Use proper unaligned access attributes

Instead of using packed attribute hack, just use aligned attribute. It
improves code generation on armv6 and armv7, and slightly improves code
generation on aarch64. GCC generates identical code to regular aligned
access on ARMv6 for all versions between 4.5 and trunk, except GCC 5
which is buggy and generates the same (bad) code as packed access:
https://gcc.godbolt.org/z/hq37rz7sb

2 years agoRefactor progress bar & summary line logic
Nick Terrell [Fri, 7 Jan 2022 23:07:28 +0000 (15:07 -0800)] 
Refactor progress bar & summary line logic

* Centralize the logic about whether to print the progress bar or not in
  the `*_PROGRESS()` macros.
* Centralize the logc about whether to print the summary line or not in
  `FIO_shouldDisplayFileSummary()` and
  `FIO_shouldDisplayMultipleFileSummary()`.
* Make `--progress` work for non-zstd (de)compressors.
* Clean up several edge cases in compression and decompression progress
  printing along the way. E.g. wrong log level, or missing summary line.

One thing I don't like about stdout mode, which sets the display level
to 1, is that warnings aren't displayed. After this PR, we could change
stdout mode from lowering the display level, to defaulting to implied
`--no-progress`. But, I think that deserves a separate PR.

2 years agoAllow tests to fake stdin/stdout/stderr is a console
Nick Terrell [Fri, 14 Jan 2022 20:37:32 +0000 (12:37 -0800)] 
Allow tests to fake stdin/stdout/stderr is a console

We've been unable to effectively test cases where stdin/stdout/stderr
are consoles, because in our test cases they generally aren't. Allow the
command line flags `--fake-std{in,out,err}-is-console` to tell the CLI
to pretend that std{in,out,err} is a console.

2 years agomeson: make backtrace dependency on execinfo
Rosen Penev [Wed, 28 Sep 2022 23:17:53 +0000 (16:17 -0700)] 
meson: make backtrace dependency on execinfo

musl libc for example has no such header.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2 years agoMerge pull request #3346 from daniellerozenblit/seekable-format-empty-string
daniellerozenblit [Wed, 14 Dec 2022 19:28:32 +0000 (14:28 -0500)] 
Merge pull request #3346 from daniellerozenblit/seekable-format-empty-string

Seekable format empty string

2 years agoMerge pull request #3349 from embg/frame_header_fields
Elliot Gorokhovsky [Wed, 14 Dec 2022 15:58:35 +0000 (10:58 -0500)] 
Merge pull request #3349 from embg/frame_header_fields

Reserve two fields in ZSTD_frameHeader

2 years agoConvert references to https from http
Danielle Rozenblit [Wed, 14 Dec 2022 14:58:35 +0000 (06:58 -0800)] 
Convert references to https from http

2 years agoFix C90 compat 3349/head
Elliot Gorokhovsky [Wed, 14 Dec 2022 02:01:32 +0000 (18:01 -0800)] 
Fix C90 compat

2 years agoReserve two fields in ZSTD_frameHeader
Elliot Gorokhovsky [Wed, 14 Dec 2022 01:45:05 +0000 (17:45 -0800)] 
Reserve two fields in ZSTD_frameHeader