summaryrefslogtreecommitdiffstats
path: root/lib/lz4.c
Commit message (Collapse)AuthorAgeFilesLines
* simplified output_directiveYann Collet2019-04-151-15/+17
|
* fix comma for pedanticYann Collet2019-04-151-1/+1
|
* unified limitedOutput_directiveYann Collet2019-04-151-16/+15
| | | | | | | | | | | between lz4.c and lz4hc.c . was left in a strange state after the "amalgamation" patch. Now only 3 directives remain, same name across both implementations, single definition place. Might allow some light simplification due to reduced nb of states possible.
* fixed lz4frame with linked blocksYann Collet2019-04-151-11/+9
| | | | | | | when one block was not compressible, it would tag the context as `dirty`, resulting in compression automatically bailing out of all future blocks, making the rest of the frame uncompressible.
* fixed minor Visual warningsYann Collet2019-04-121-2/+2
| | | | | | | | 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.
* introduce LZ4_DISTANCE_MAX build macroYann Collet2019-04-111-15/+20
| | | | | | | | | | 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
* modified LZ4_initStreamHC() to look like LZ4_initStream()Yann Collet2019-04-091-0/+1
| | | | | it is now a pure initializer, for statically allocated states. It can initialize any memory area, and because of this, requires size.
* check some more initialization resultYann Collet2019-04-081-1/+5
| | | | ensure it's not NULL.
* removed LZ4_stream_t alignment test on VisualYann Collet2019-04-081-0/+8
| | | | | | | 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.
* LZ4_initStream() checks alignment restrictionYann Collet2019-04-081-0/+7
| | | | updated associated documentation
* created LZ4_initStream()Yann Collet2019-04-051-5/+12
| | | | | | | | | | - 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*.
* minor comments and reformattingYann Collet2019-04-031-12/+17
|
* fixed minor conversion warningsYann Collet2019-04-031-14/+10
|
* created LZ4_FAST_DEC_LOOP build macroYann Collet2019-04-021-5/+16
|
* fixed a few minor conversion warningsYann Collet2019-04-021-20/+22
|
* Merge pull request #645 from djwatson/optimize_decompress_genericYann Collet2019-02-121-19/+245
|\ | | | | Optimize decompress generic
| * decompress_generic: Limit fastpath to x86Dave Watson2019-02-111-3/+9
| | | | | | | | | | New fastpath currently shows a regression on qualcomm arm chips. Restrict it to x86 for now
| * decompress_generic: Add fastpath for small offsetsDave Watson2019-02-081-19/+59
| | | | | | | | | | | | | | | | 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.
| * decompress_generic: Unroll loops a bit moreDave Watson2019-02-081-7/+7
| | | | | | | | | | | | | | | | 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.
| * decompress_generic: remove msan writeDave Watson2019-02-081-5/+0
| | | | | | | | | | 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.
| * decompress_generic: re-add fastpathDave Watson2019-02-081-4/+19
| | | | | | | | | | This is the remaineder of the original 'shortcut'. If true, we can avoid the loop in LZ4_wildCopy, and directly copy instead.
| * decompress_generic: drop partial copy check in fast loopDave Watson2019-02-081-15/+0
| | | | | | | | | | | | 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.
| * decompress_generic: Optimize literal copiesDave Watson2019-02-081-12/+21
| | | | | | | | | | | | | | | | 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.
| * decompress_generic: optimize match copyDave Watson2019-02-081-23/+28
| | | | | | | | | | | | 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.
| * decompress_generic: Add a loop fastpathDave Watson2019-02-081-5/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * decompress_generic: Refactor variable length fieldsDave Watson2019-02-081-12/+35
| | | | | | | | | | Make a helper function to read variable lengths for literals and match length.
* | Eliminate optimize attribute warning with clang on PPC64LEJeremy Maitin-Shepard2019-02-041-1/+1
|/
* Fix Dict Size Test in `LZ4_compress_fast_continue()`W. Felix Handte2018-12-051-4/+2
| | | | | | | 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()`.
* Don't Attach Very Small DictionariesW. Felix Handte2018-12-041-1/+3
| | | | | | | | | | | | | | | | | 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.
* Enable amalgamation of lz4hc.c and lz4.cBing Xu2018-11-161-1/+14
|
* Some followups and renamingsOleg Khabinov2018-10-011-7/+8
|
* Rename initCheck to dirtyContext and use it in LZ4_resetStream_fast() to ↵Oleg Khabinov2018-09-281-8/+32
| | | | check if full reset is needed.
* Merge pull request #578 from lz4/support128bitYann Collet2018-09-261-11/+14
|\ | | | | Support for 128bit pointers like AS400
| * increase size of LZ4 contexts for 128-bit systemsYann Collet2018-09-181-1/+2
| |
| * use byU32 mode for any pointer > 32-bitYann Collet2018-09-141-10/+12
| | | | | | | | including 128-bit, like IBM AS-400
* | tried to clean another bunch of cppcheck warningsYann Collet2018-09-191-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | fixed minor cppcheck warnings in libYann Collet2018-09-181-198/+200
|/
* clarify constant MFLIMITYann Collet2018-09-111-4/+5
| | | | | | | and separate it from MATCH_SAFEGUARD_DISTANCE. While both constants have same value, they do not seve same purpose, hence should not be confused.
* fixed minor warning in fuzzer.cYann Collet2018-09-101-6/+8
| | | | added a few more comments and assert()
* restored nullifying outputYann Collet2018-09-101-1/+5
| | | | to counter possible (offset==0)
* removed temporary debug tracesYann Collet2018-09-101-2/+0
|
* fixed fuzzer testYann Collet2018-09-081-4/+6
| | | | and removed one blind copy, since there is no more guarantee that at least 4 bytes are still available in output buffer
* first sketch for a byte-accurate partial decoderYann Collet2018-09-071-47/+79
|
* updated API documentationYann Collet2018-09-071-2/+2
|
* Also Fix Appveyor Cast WarningW. Felix Handte2018-05-221-1/+1
|
* Remove #define-rename of `LZ4_decompress_safe_forceExtDict`W. Felix Handte2018-05-221-8/+8
|
* Test Linking C-Compiled Library and C++-Compiled TestsW. Felix Handte2018-05-221-0/+15
|
* small extDict : fixed side-effectYann Collet2018-05-061-3/+6
| | | | | | don't fix dictionaries of size 0. setting dictEnd == source triggers prefix mode, thus removing possibility to use CDict.
* fixed frametest errorYann Collet2018-05-061-1/+12
| | | | | | | | | | | | | | | | | | | | The error can be reproduced using following command : ./frametest -v -i100000000 -s1659 -t31096808 It's actually a bug in the stream LZ4 API, when starting a new stream and providing a first chunk to complete with size < MINMATCH. In which case, the chunk becomes a dictionary. No hash was generated and stored, but the chunk is accessible as default position 0 points to dictStart, and position 0 is still within MAX_DISTANCE. Then, next attempt to read 32-bits from position 0 fails. The issue would have been mitigated by starting from index 64 KB, effectively eliminating position 0 as too far away. The proper fix is to eliminate such "dictionary" as too small. Which is what this patch does.
* fix comments / indentationCyan49732018-05-031-10/+8
| | | | as requested by @terrelln