Commit Graph

829 Commits

Author SHA1 Message Date
Yann Collet
3215069741 Merge branch 'dev' of github.com:Cyan4973/lz4 into dev 2019-04-13 15:55:33 -07:00
Yann Collet
749c3400bd fixed incorrect assertion condition
output can use the full length of output buffer
2019-04-13 15:55:06 -07:00
Yann Collet
dd43b913a2 fix minor visual warning
yet some overly cautious overflow risk flag,
while it's actually impossible, due to previous test just one line above.
Changing the cast position, just to be please the thing.
2019-04-12 16:56:22 -07:00
Yann Collet
f8b7605034 fixed minor Visual warnings
since Visual 2017,
worries about potential overflow, which are actually impossible.
Replaced (c * a) by (c ? a : 0).
Will likely replaced a * by a cmov.
Probably harmless for performance.
2019-04-12 16:49:01 -07:00
Yann Collet
21ff1a839a updated doc to underline difference between block and frame
as this is a very frequent source of confusion for new users.
2019-04-12 11:27:44 -07:00
Yann Collet
bcb26565a7 improved documentation for LZ4 dictionary compression 2019-04-11 15:20:46 -07:00
Yann Collet
8d76c8a44a introduce LZ4_DISTANCE_MAX build macro
make it possible to generate LZ4-compressed block
with a controlled maximum offset (necessarily <= 65535).

This could be useful for compatibility with decoders
using a very limited memory budget (<64 KB).

Answer #154
2019-04-11 14:15:33 -07:00
Yann Collet
5580f4333a
Merge pull request #663 from lz4/headerSize
made LZ4F_getHeaderSize() public
2019-04-09 21:30:14 -07:00
Yann Collet
db60ed19b1 added versions in comments 2019-04-09 18:23:32 -07:00
Yann Collet
9e501702bd made LZ4F_getHeaderSize() public 2019-04-09 18:10:58 -07:00
Yann Collet
d8d5f14138 fixed loadDictHC
by making a full initialization
instead of a fast reset.
2019-04-09 15:37:59 -07:00
Yann Collet
887e8a4d01 re-enable LZ4_resetStreamHC()
towards deprecation, but still available and fully supported
2019-04-09 14:00:30 -07:00
Yann Collet
14c71dfa9c modified LZ4_initStreamHC() to look like LZ4_initStream()
it is now a pure initializer, for statically allocated states.
It can initialize any memory area, and because of this, requires size.
2019-04-09 13:55:42 -07:00
Yann Collet
5ef4f3ce91 check some more initialization result
ensure it's not NULL.
2019-04-08 16:51:22 -07:00
Yann Collet
111df0fa45 removed LZ4_stream_t alignment test on Visual
it fails on x86 32-bit mode :
Visual reports an alignment of 8-bytes (even with alignof())
but actually only align LZ4_stream_t on 4 bytes.
The alignment check then fails, resulting in missed initialization.
2019-04-08 16:47:21 -07:00
Yann Collet
c198a39a66 LZ4_initStream() checks alignment restriction
updated associated documentation
2019-04-08 12:49:54 -07:00
Yann Collet
34f0004a5e added comment on initStream + _extState_
as suggested by @felixhandte
2019-04-05 15:35:19 -07:00
Yann Collet
2ece0d8380 created LZ4_initStream()
- promoted LZ4_resetStream_fast() to stable
- moved LZ4_resetStream() into deprecate, but without triggering a compiler warning
- update all sources to no longer rely on LZ4_resetStream()

note : LZ4_initStream() proposal is slightly different :
it's able to initialize any buffer, provided that it's large enough.
To this end, it accepts a void*, and returns an LZ4_stream_t*.
2019-04-05 12:56:26 -07:00
Yann Collet
c3f8928f87 fixed strict iso C90 2019-04-05 10:41:26 -07:00
Yann Collet
c491df54ec created LZ4_initStreamHC()
- promoted LZ4_resetStreamHC_fast() to stable
- moved LZ4_resetStreamHC() to deprecated (but do not generate a warning yet)
- Updated doc, to highlight difference between init and reset
- switched all invocations of LZ4_resetStreamHC() onto LZ4_initStreamHC()
- misc: ensure `make all` also builds /tests
2019-04-04 17:05:11 -07:00
Yann Collet
7a39fb8fb6 make _fast*() decoder generate a deprecation warning
updated modification
2019-04-04 12:47:36 -07:00
Yann Collet
ab91300509 moved LZ4_decompress_fast*() into deprecated section 2019-04-04 12:24:46 -07:00
Yann Collet
b5bedefabe fixed an old bug in LZ4F_flush()
which remained undetected so far,
as it requires a fairly large number of conditions to be triggered,
starting with enabling Block checksum, which is disabled by default,
and which usage is known to be extremely rare.
2019-04-03 16:28:42 -07:00
Yann Collet
50f01d881d fixed doc
and bumped version number fo v1.9.0
2019-04-03 14:27:21 -07:00
Yann Collet
25da6cc967 moved _destSize() into "stable API" status
as requested in #642
2019-04-03 14:18:00 -07:00
Yann Collet
f2755c9887 minor comments and reformatting 2019-04-03 08:59:29 -07:00
Yann Collet
753076bfa4 fixed minor conversion warnings 2019-04-02 17:16:43 -07:00
Yann Collet
2589c4424f created LZ4_FAST_DEC_LOOP build macro 2019-04-02 16:22:11 -07:00
Yann Collet
7d9d00f4df fixed a few minor conversion warnings 2019-04-02 16:06:37 -07:00
Yann Collet
c438548312
Merge pull request #652 from vtorri/dev
Allow installation of lz4 for Windows 10 with MSYS2
2019-03-03 13:40:45 -08:00
Vincent Torri
0360981f68 Allow installation of lz4 for Windows 10 with MSYS2 2019-03-03 22:06:38 +01:00
Yann Collet
d85bdb4ff2
Merge pull request #645 from djwatson/optimize_decompress_generic
Optimize decompress generic
2019-02-11 16:58:53 -08:00
Dave Watson
5d7d1166cb decompress_generic: Limit fastpath to x86
New fastpath currently shows a regression on qualcomm
arm chips.  Restrict it to x86 for now
2019-02-11 11:44:51 -08:00
Dave Watson
75fb878a90 decompress_generic: Add fastpath for small offsets
For small offsets of size 1, 2, 4 and 8, we can set a single uint64_t,
and then use it to do a memset() variation.  In particular, this makes
the somewhat-common RLE (offset 1) about 2-4x faster than the previous
implementation - we avoid not only the load blocked by store, but also
avoid the loads entirely.
2019-02-08 13:57:23 -08:00
Dave Watson
faac110e20 decompress_generic: Unroll loops a bit more
Generally we want our wildcopy loops to look like the
memcpy loops from our libc, but without the final byte copy checks.
We can unroll a bit to make long copies even faster.

The only catch is that this affects the value of FASTLOOP_SAFE_DISTANCE.
2019-02-08 13:57:23 -08:00
Dave Watson
1fbaf84306 decompress_generic: remove msan write
This store is also causing load-blocked-by-store issues, remove it.
The msan warning will have to be fixed another way if it is still an issue.
2019-02-08 13:57:23 -08:00
Dave Watson
28b824921d decompress_generic: re-add fastpath
This is the remaineder of the original 'shortcut'.  If true, we can avoid
the loop in LZ4_wildCopy, and directly copy instead.
2019-02-08 13:57:23 -08:00
Dave Watson
232f1e261f decompress_generic: drop partial copy check in fast loop
We've already checked that we are more than FASTLOOP_SAFE_DISTANCE
away from the end, so this branch can never be true, we will have
already jumped to the second decode loop.
2019-02-08 13:57:23 -08:00
Dave Watson
59332a3026 decompress_generic: Optimize literal copies
Use LZ4_wildCopy16 for variable-length literals.  For literal counts that
fit in the flag byte, copy directly.  We can also omit oend checks for
roughly the same reason as the previous shortcut:  We check once that both
match length and literal length fit in FASTLOOP_SAFE_DISTANCE, including
wildcopy distance.
2019-02-08 13:57:23 -08:00
Dave Watson
5dfa7d422b decompress_generic: optimize match copy
Add an LZ4_wildCopy16, that will wildcopy, potentially smashing up
to 16 bytes, and use it for match copy.  On x64, this avoids many
blocked loads due to store forwarding, similar to issue #411.
2019-02-08 13:57:23 -08:00
Dave Watson
28356e02ad decompress_generic: Add a loop fastpath
Copy the main loop, and change checks such that op is always less
than oend-SAFE_DISTANCE.  Currently these are added for the literal
copy length check, and for the match copy length check.

Otherwise the first loop is exactly the same as the second.  Follow on
diffs will optimize the first copy loop based on this new requirement.

I also tried instead making a separate inlineable function for the copy
loop (similar to existing partialDecode flags, etc), but I think the
changes might be significant enough to warrent doubling the code, instead
pulling out common functionality to separate functions.

This is the basic transformation that will allow several following optimisations.
2019-02-08 13:57:19 -08:00
Dave Watson
4da336062e decompress_generic: Refactor variable length fields
Make a helper function to read variable lengths for literals and
match length.
2019-02-08 13:42:42 -08:00
Jeremy Maitin-Shepard
26e7635a0e Eliminate optimize attribute warning with clang on PPC64LE 2019-02-04 12:22:56 -08:00
Tim Zakian
81441e2462 Make fact that certain variables that are passed into LZ4HC_encodeSequence are changed by the function call 2019-01-09 13:42:12 -08:00
Yann Collet
c750cbe5c1
Merge pull request #631 from qiuyangs/dev
lz4hc.c: change (length >> 8) to (length / 255)
2019-01-09 12:21:39 -08:00
Tim Zakian
8193742251 Make LZ4F_getBlockSize public and publis in experimental section 2019-01-09 10:49:49 -08:00
qiuyangs
660d21272e
lz4hc.c: change (length >> 8) to (length / 255)
Every 0xff byte in the compressed block corresponds to a length of 255 (not 256) in the input data. For long repeating sequences, using (length >> 8) may generate bad compressed blocks.
2019-01-06 16:29:30 +08:00
W. Felix Handte
4e3accccb2 Fix Dict Size Test in LZ4_compress_fast_continue()
Dictionaries don't need to be > 4 bytes, they need to be >= 4 bytes. This test
was overly conservative.

Also removes the test in `LZ4_attach_dictionary()`.
2018-12-05 11:24:33 -08:00
W. Felix Handte
535636ff5c Don't Attach Very Small Dictionaries
Fixes a mismatch in behavior between loading into the context (via
`LZ4_loadDict()`) a very small (<= 4 bytes) non-contiguous dictionary, versus
attaching it with `LZ4_attach_dictionary()`.

Before this patch, this divergence could be reproduced by running

```
make -C tests fuzzer MOREFLAGS="-m32"
tests/fuzzer -v -s1239 -t3146
```

Making sure these two paths behave exactly identically is an easy way to test
the correctness of the attach path, so it's desirable that this remain an
unpolluted, high signal test.
2018-12-04 14:05:11 -08:00
Vincent Torri
9021648ba7 Merge remote-tracking branch 'upstream/dev' into dev 2018-12-02 19:42:38 +01:00
Vincent Torri
b03714dc80 Windows: create import library with gcc directly, remove now useless def file 2018-12-02 18:50:18 +01:00
Yann Collet
6689dae33b
Merge pull request #610 from antinucleon/bootcamp
[amalgamation] lz4frame.c
2018-11-26 12:14:27 -08:00
Bing Xu
b192c86ba4 [amalgamation] lz4frame.c 2018-11-26 11:30:15 -08:00
Vincent Torri
bd2b259760 Uninstall DLL and import lib 2018-11-21 09:07:26 +01:00
Vincent Torri
8e8b658bde Add explanation for the installation of the DLL in the bin directory 2018-11-21 08:40:51 +01:00
Vincent Torri
0314027051 Allow installation of lz4 for Windows (MSYS2 or when cross-compiling) 2018-11-20 21:08:23 +01:00
Vincent Torri
e057e94215 update lib/README.md 2018-11-18 21:03:27 +01:00
Vincent Torri
d966844a95 Add documentation about DLLTOOL variable 2018-11-18 13:22:10 +01:00
Vincent Torri
b5e106220b Add DLLTOOL variable so that one can override dlltool binary
This fix cross compilation on linux for Windows
2018-11-17 14:17:15 +01:00
Vincent Torri
31ce8b56e5 Use / instead of \ when accessing files in the dll subdirectory.
This allow cross-compilation for Windows on Linux
2018-11-17 07:44:23 +01:00
Bing Xu
17f5071e72 Enable amalgamation of lz4hc.c and lz4.c 2018-11-15 22:24:25 -08:00
Yann Collet
1b819bfd63
Merge pull request #593 from felixhandte/lz4hc-publish-static
Extend Macro to Allow Publishing Experimental LZ4HC Functions in Dynamic Libraries
2018-10-16 15:33:58 -07:00
W. Felix Handte
6a2da13cb7 Make LZ4HC Experimental Functions Dynamically Publishable 2018-10-15 17:23:06 -07:00
W. Felix Handte
45dc195f84 Change Comment and Make LZ4LIB_STATIC_API Available to LZ4HC 2018-10-15 17:22:37 -07:00
Yann Collet
bf9bf80f8d updated code documentation
to clarify #589
2018-10-15 11:14:30 -07:00
Oleg Khabinov
f27ea0774e Adding information about dirty context for _HC_ family of functions 2018-10-10 10:33:04 -07:00
Yann Collet
df6d00ede5
Merge pull request #592 from lz4/compressEnd
fix LZ4F_compressEnd()
2018-10-09 15:37:55 -07:00
Yann Collet
6902fa4892 fixed #589
following recommendations by @raggi.

The fix is slightly different, but achieves the same goal,
and is backed by a test tool which proves that it works
(generates the error before the patch, no longer after the patch).
2018-10-09 14:37:51 -07:00
Yann Collet
e07a37d712 added a test for LZ4F_compressEnd()
which actively tries to make it write out of bound.
For this scenario to be possible,
it's necessary to set dstCapacity < LZ4F_compressBound()

When a compression operation fails,
the CCtx context is left in an undefined state,
therefore compression cannot resume.
As a consequence :
- round trip tests must be aborted, since there is nothing valid to decompress
- most users avoid this situation, by ensuring that dstCapacity >= LZ4F_compressBound()

For these reasons, this use case was poorly tested up to now.
2018-10-09 14:25:18 -07:00
Oleg Khabinov
28eb88d988 Some followups and renamings 2018-10-01 15:19:45 -07:00
Yann Collet
b18b6e53e1
Merge pull request #587 from lz4/hintbug
fixed improper hint
2018-09-28 16:58:01 -07:00
Yann Collet
21120549a7 fixed improper hint
when LZ4F_decompress() decodes an uncompressed block,
it provides an incorrect hint for next block
when frame checksum is enabled and block checksum is not.

Impact is low : the hint is just an hint,
the decoder works whatever the amount of input provided.

But the assumption that each call to LZ4F_decompress()
would generate just one complete block if input size hint was respected
was broken by this error.
2018-09-28 14:57:50 -07:00
Oleg Khabinov
f2ae385c2f Rename initCheck to dirtyContext and use it in LZ4_resetStream_fast() to check if full reset is needed. 2018-09-28 14:55:05 -07:00
Yann Collet
cb917827f9
Merge pull request #578 from lz4/support128bit
Support for 128bit pointers like AS400
2018-09-26 13:57:09 -07:00
Yann Collet
c4c19c74b8 changed LZ4_streamDecode member order
to reduce memory usage on 128-bits systems
2018-09-25 14:43:19 -07:00
Yann Collet
b2215f2a89 tried to clean another bunch of cppcheck warnings
so "funny" thing with cppcheck
is that no 2 versions give the same list of warnings.

On Mac, I'm using v1.81, which had all warnings fixed.
On Travis CI, it's v1.61, and it complains about a dozen more/different things.
On Linux, it's v1.72, and it finds a completely different list of a half dozen warnings.

Some of these seems to be bugs/limitations in cppcheck itself.
The TravisCI version v1.61 seems unable to understand %zu correctly, and seems to assume it means %u.
2018-09-19 12:12:49 -07:00
Yann Collet
8bea19d57c fixed minor cppcheck warnings in lib 2018-09-18 15:51:26 -07:00
Yann Collet
c3397520a1 updated xxhash to latest version 2018-09-18 12:14:26 -07:00
Yann Collet
6381d828fd increase size of LZ4 contexts for 128-bit systems 2018-09-17 17:31:57 -07:00
Yann Collet
7b9edd60a0 Merge branch 'dev' into support128bit 2018-09-17 17:07:00 -07:00
Yann Collet
dea044a485
Merge pull request #575 from lz4/apiDoc
unpublish static-only functions
2018-09-17 17:06:34 -07:00
Yann Collet
cb2fb479ef increase lz4hc context size as constant for 128-bit systems 2018-09-17 17:05:17 -07:00
Yann Collet
6103b4c9b4 use byU32 mode for any pointer > 32-bit
including 128-bit, like IBM AS-400
2018-09-14 15:27:48 -07:00
Yann Collet
c820480e12
Merge pull request #574 from lz4/enumComma
avoid final trailing comma for enum lists
2018-09-14 13:51:43 -07:00
Yann Collet
d2f5716c5d
Merge pull request #573 from laffer1/laffer1-pkgconfig-mnbsd
FIx pkgconfig file installation on MidnightBSD
2018-09-14 10:11:49 -07:00
Yann Collet
e8b08f9fbd updated build doc 2018-09-13 16:14:00 -07:00
Yann Collet
a803230f67 unpublish static-only function
these functions are now unpublished in dll by default.
One needs to opt-in, using macro LZ4_PUBLISH_STATIC_FUNCTIONS.

used this opportunity to update a bunch of api comments in lz4.h
2018-09-13 16:02:11 -07:00
Yann Collet
86023f01f2 avoid final trailing comma for enum lists
as detected in #485 by @JoachimSchneider.

Refactored the c_standards tests
so that these issues get automatically detected in CI tests.
2018-09-13 14:29:41 -07:00
Lucas Holt
de4667011a
FIx pkgconfig file installation on MidnightBSD 2018-09-11 21:18:43 -04:00
Yann Collet
6d32240b2e clarify constant MFLIMIT
and separate it from MATCH_SAFEGUARD_DISTANCE.

While both constants have same value,
they do not seve same purpose, hence should not be confused.
2018-09-11 10:00:13 -07:00
Yann Collet
b87a8e9e62 fixed minor warning in fuzzer.c
added a few more comments and assert()
2018-09-10 16:48:41 -07:00
Yann Collet
63fc6fbf7e restored nullifying output
to counter possible (offset==0)
2018-09-10 16:22:16 -07:00
Yann Collet
32272f9866 removed temporary debug traces 2018-09-10 15:51:53 -07:00
Yann Collet
d28389b2dc Merge branch 'dev' into partialDecode 2018-09-10 15:44:40 -07:00
Yann Collet
6e54d8df33
Merge pull request #569 from lz4/circle2
Migrate CircleCI tests from 1.0 towards 2.0
2018-09-10 14:44:15 -07:00
Yann Collet
f8519d454e
Merge pull request #565 from lz4/lz4f_init
Introduced constants LZ4F_INIT_*
2018-09-10 13:11:56 -07:00
Yann Collet
674eac3325 Merge branch 'dev' of github.com:Cyan4973/lz4 into dev 2018-09-10 12:02:42 -07:00
Lucas Holt
3318d573ba Add support for MidnightBSD 2018-09-08 14:46:54 -04:00
Yann Collet
e22bb80074 fixed fuzzer test
and removed one blind copy, since there is no more guarantee that at least 4 bytes are still available in output buffer
2018-09-07 18:22:01 -07:00
Yann Collet
eaed9ea4a1 updated function interface documentation 2018-09-07 16:21:31 -07:00