From d0f8d407b0fee05e3f1c325c54948b54685f9e92 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 23 Mar 2015 08:57:14 +0100 Subject: updated dist list --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9cf76c2..5e6157f 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ TEXT = $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4.h $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4hc.h \ $(PRGDIR)/datagen.c $(PRGDIR)/datagen.h $(PRGDIR)/datagencli.c $(PRGDIR)/fuzzer.c \ $(PRGDIR)/lz4io.c $(PRGDIR)/lz4io.h \ $(PRGDIR)/bench.c $(PRGDIR)/bench.h \ - $(PRGDIR)/lz4.1 $(PRGDIR)/lz4c.1 $(PRGDIR)/lz4cat.1 \ + $(PRGDIR)/lz4.1 \ $(PRGDIR)/Makefile $(PRGDIR)/COPYING NONTEXT = images/image00.png images/image01.png images/image02.png \ images/image03.png images/image04.png images/image05.png \ -- cgit v0.12 From 6b923d57a6af892d2d8da409fb07f256504c074c Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 23 Mar 2015 19:59:41 +0100 Subject: Updated long commands, with reverse "--no-" variants --- programs/lz4.1 | 18 ++++++++++++++---- programs/lz4cli.c | 24 ++++++++++++++---------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/programs/lz4.1 b/programs/lz4.1 index 8bab7a3..85bfb06 100644 --- a/programs/lz4.1 +++ b/programs/lz4.1 @@ -59,12 +59,19 @@ files as is. .B lz4 will decompress such files as if they were a single .B .lz4 -file. +file. For example: + lz4 file1 > foo.lz4 + lz4 file2 >> foo.lz4 + then + lz4cat foo.lz4 + is equivalent to : + cat file1 file2 + .PP .SH OPTIONS . -.SS "Short command concatenation" +.SS "Short commands concatenation" In some cases, some options can be expressed using short command .B "-x" or long command @@ -75,6 +82,9 @@ is equivalent to .B "-dc" . Long commands cannot be concatenated. They must be clearly separated by a space. +.SS "Multiple commands" +When multiple contradictory commands are issued on a same command line, +only the latest one will be applied. . .SS "Operation mode" If multiple operation mode options are given, @@ -171,10 +181,10 @@ with the resulting compressed file named .B \--no-frame-crc disable stream checksum (default:enabled) .TP -.B \--frame-content-size +.B \--content-size compressed frame includes original size (default:not present) .TP -.B \--sparse-support +.B \--sparse enable sparse file (default:disabled)(experimental) .TP .B \-l diff --git a/programs/lz4cli.c b/programs/lz4cli.c index 6c57864..da5da71 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -173,9 +173,9 @@ static int usage_advanced(void) DISPLAY( " -B# : Block size [4-7](default : 7)\n"); DISPLAY( " -BD : Block dependency (improve compression ratio)\n"); /* DISPLAY( " -BX : enable block checksum (default:disabled)\n"); *//* Option currently inactive */ - DISPLAY( "--no-frame-crc : disable stream checksum (default:enabled)\n"); - DISPLAY( "--frame-content-size : compressed frame includes original size (default:not present)\n"); - DISPLAY( "--sparse-support : enable sparse file (default:disabled)(experimental)\n"); + DISPLAY( "--no-frame-crc : disable stream checksum (default:enabled)\n"); + DISPLAY( "--content-size : compressed frame includes original size (default:not present)\n"); + DISPLAY( "--sparse : enable sparse file (default:disabled)(experimental)\n"); DISPLAY( "Benchmark arguments :\n"); DISPLAY( " -b : benchmark file(s)\n"); DISPLAY( " -i# : iteration loops [1-9](default : 3), benchmark mode only\n"); @@ -293,19 +293,23 @@ int main(int argc, char** argv) /* long commands (--long-word) */ if (!strcmp(argument, "--compress")) { forceCompress = 1; continue; } - if (!strcmp(argument, "--decompress")) { decode = 1; continue; } - if (!strcmp(argument, "--uncompress")) { decode = 1; continue; } + if ((!strcmp(argument, "--decompress")) + || (!strcmp(argument, "--uncompress"))) { decode = 1; continue; } if (!strcmp(argument, "--test")) { decode = 1; LZ4IO_setOverwrite(1); output_filename=nulmark; continue; } if (!strcmp(argument, "--force")) { LZ4IO_setOverwrite(1); continue; } - if (!strcmp(argument, "--stdout")) { forceStdout=1; output_filename=stdoutmark; displayLevel=1; continue; } - if (!strcmp(argument, "--to-stdout")) { forceStdout=1; output_filename=stdoutmark; displayLevel=1; continue; } + if (!strcmp(argument, "--no-force")) { LZ4IO_setOverwrite(0); continue; } + if ((!strcmp(argument, "--stdout")) + || (!strcmp(argument, "--to-stdout"))) { forceStdout=1; output_filename=stdoutmark; displayLevel=1; continue; } + if (!strcmp(argument, "--frame-crc")) { LZ4IO_setStreamChecksumMode(1); continue; } if (!strcmp(argument, "--no-frame-crc")) { LZ4IO_setStreamChecksumMode(0); continue; } - if (!strcmp(argument, "--frame-content-size")) { LZ4IO_setContentSize(1); continue; } - if (!strcmp(argument, "--sparse-support")) { LZ4IO_setSparseFile(1); continue; } + if (!strcmp(argument, "--content-size")) { LZ4IO_setContentSize(1); continue; } + if (!strcmp(argument, "--no-content-size")) { LZ4IO_setContentSize(0); continue; } + if (!strcmp(argument, "--sparse")) { LZ4IO_setSparseFile(1); continue; } + if (!strcmp(argument, "--no-sparse")) { LZ4IO_setSparseFile(0); continue; } if (!strcmp(argument, "--verbose")) { displayLevel=4; continue; } if (!strcmp(argument, "--quiet")) { if (displayLevel) displayLevel--; continue; } if (!strcmp(argument, "--version")) { DISPLAY(WELCOME_MESSAGE); return 0; } - if (!strcmp(argument, "--keep")) { continue; } /* keep source file (default anyway, so useless) (for xz/lzma compatibility) */ + if (!strcmp(argument, "--keep")) { continue; } /* keep source file (default anyway; just for xz/lzma compatibility) */ /* Short commands (note : aggregated short commands are allowed) */ if (argument[0]=='-') -- cgit v0.12 From 5950f72b9e48ea2c928c9751de04fe3bb4d0119a Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 23 Mar 2015 20:03:45 +0100 Subject: Updated tests --- programs/Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/programs/Makefile b/programs/Makefile index 6aade89..a5ae8d3 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -144,16 +144,16 @@ test-travis: $(TRAVIS_TARGET) test-lz4-sparse: lz4 datagen @echo ---- test sparse file support ---- - ./datagen -g50M -P100 | ./lz4 -B4D | ./lz4 -dv --sparse-support > tmpB4 - ./datagen -g50M -P100 | ./lz4 -B5D | ./lz4 -dv --sparse-support > tmpB5 - ./datagen -g50M -P100 | ./lz4 -B6D | ./lz4 -dv --sparse-support > tmpB6 - ./datagen -g50M -P100 | ./lz4 -B7D | ./lz4 -dv --sparse-support > tmpB7 + ./datagen -g50M -P100 | ./lz4 -B4D | ./lz4 -dv --sparse > tmpB4 + ./datagen -g50M -P100 | ./lz4 -B5D | ./lz4 -dv --sparse > tmpB5 + ./datagen -g50M -P100 | ./lz4 -B6D | ./lz4 -dv --sparse > tmpB6 + ./datagen -g50M -P100 | ./lz4 -B7D | ./lz4 -dv --sparse > tmpB7 ls -ls tmp* ./datagen -g50M -P100 | diff -s - tmpB4 ./datagen -g50M -P100 | diff -s - tmpB5 ./datagen -g50M -P100 | diff -s - tmpB6 ./datagen -g50M -P100 | diff -s - tmpB7 - ./datagen -s1 -g1200007 -P100 | ./lz4 | ./lz4 -dv --sparse-support > tmpOdd # Odd size file (to not finish on an exact nb of blocks) + ./datagen -s1 -g1200007 -P100 | ./lz4 | ./lz4 -dv --sparse > tmpOdd # Odd size file (to not finish on an exact nb of blocks) ./datagen -s1 -g1200007 -P100 | diff -s - tmpOdd ls -ls tmpOdd @rm tmp* @@ -162,7 +162,7 @@ test-lz4-contentSize: lz4 datagen @echo ---- test original size support ---- ./datagen -g15M > tmp ./lz4 -v tmp | ./lz4 -t - ./lz4 -v --frame-content-size tmp | ./lz4 -d > tmp2 + ./lz4 -v --content-size tmp | ./lz4 -d > tmp2 diff -s tmp tmp2 @rm tmp* @@ -237,8 +237,8 @@ test-mem: lz4 datagen fuzzer frametest valgrind --leak-check=yes ./lz4 -9 -BD -f tmp $(VOID) ./datagen -g16MB > tmp valgrind --leak-check=yes ./lz4 -9 -B5D -f tmp tmp2 - ./datagen -g256MB > tmp valgrind --leak-check=yes ./lz4 -t tmp2 + ./datagen -g256MB > tmp valgrind --leak-check=yes ./lz4 -B4D -f -vq tmp $(VOID) rm tmp* valgrind --leak-check=yes ./fuzzer -i64 -t1 -- cgit v0.12 From 80e71c6e8b0cbcd3b9976ded45cef1474a34b40c Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 23 Mar 2015 21:22:13 +0100 Subject: Updated man page : "--[no-]X" --- programs/lz4.1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/programs/lz4.1 b/programs/lz4.1 index 85bfb06..1225832 100644 --- a/programs/lz4.1 +++ b/programs/lz4.1 @@ -87,8 +87,6 @@ When multiple contradictory commands are issued on a same command line, only the latest one will be applied. . .SS "Operation mode" -If multiple operation mode options are given, -the last one takes effect. .TP .BR \-z ", " \-\-compress Compress. @@ -122,7 +120,7 @@ Test the integrity of compressed .B .lz4 files. The decompressed data is discarded. -No files are created or removed. +No files are created nor removed. . .SS "Operation modifiers" .TP @@ -133,7 +131,7 @@ No files are created or removed. high compression .TP -.BR \-f ", " --force +.BR \-f ", " --[no-]force This option has several effects: .RS .IP \(bu 3 @@ -178,13 +176,15 @@ with the resulting compressed file named .B \-BD block dependency (improve compression ratio) .TP -.B \--no-frame-crc +.B \--[no-]frame-crc disable stream checksum (default:enabled) .TP -.B \--content-size - compressed frame includes original size (default:not present) +.B \--[no-]content-size + compressed file includes original size (default:not present) + Note : this option can only be activated when the original size can be determined, +hence for a file. It won't work with unknown source size, such as stdin pipe. .TP -.B \--sparse +.B \--[no-]sparse enable sparse file (default:disabled)(experimental) .TP .B \-l -- cgit v0.12 From a38166bd5261ac8ff93dad8fa87eb6ee3deeea2d Mon Sep 17 00:00:00 2001 From: Takayuki MATSUOKA Date: Wed, 25 Mar 2015 07:51:56 +0900 Subject: Add document : "Streaming API Basics" --- examples/streaming_api_basics.md | 87 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 examples/streaming_api_basics.md diff --git a/examples/streaming_api_basics.md b/examples/streaming_api_basics.md new file mode 100644 index 0000000..6c2632f --- /dev/null +++ b/examples/streaming_api_basics.md @@ -0,0 +1,87 @@ +# LZ4 Streaming API Basics + +## LZ4 API sets + +LZ4 has the following API sets : + + - "Auto Framing" API (lz4frame.h) : + This is most recommended API for usual application. + It guarantees interoperability with other LZ4 framing format compliant tools/libraries + such as LZ4 command line utility, node-lz4, etc. + - "Block" API : This is recommended for simple purpose. + It compress single raw memory block to LZ4 memory block and vice versa. + - "Streaming" API : This is designed for complex thing. + For example, compress huge stream data in restricted memory environment. + +Basically, you should use "Auto Framing" API. +But if you want to write advanced application, it's time to use Block or Streaming APIs. + + +## What is difference between Block and Streaming API ? + +Block API (de)compresses single contiguous memory block. +In other words, LZ4 library find redundancy from single contiguous memory block. +Streaming API does same thing but (de)compress multiple adjacent contiguous memory block. +So LZ4 library could find more redundancy than Block API. + +The following figure shows difference between API and block sizes. +In these figures, original data is splitted to 4KiBytes contiguous chunks. + +``` +Original Data + +---------------+---------------+----+----+----+ + | 4KiB Chunk A | 4KiB Chunk B | C | D |... | + +---------------+---------------+----+----+----+ + +Example (1) : Block API, 4KiB Block + +---------------+---------------+----+----+----+ + | 4KiB Chunk A | 4KiB Chunk B | C | D |... | + +---------------+---------------+----+----+----+ + | Block #1 | Block #2 | #3 | #4 |... | + +---------------+---------------+----+----+----+ + + (No Dependency) + + +Example (2) : Block API, 8KiB Block + +---------------+---------------+----+----+----+ + | 4KiB Chunk A | 4KiB Chunk B | C | D |... | + +---------------+---------------+----+----+----+ + | Block #1 |Block #2 |... | + +--------------------+----------+-------+-+----+ + ^ | ^ | + | | | | + +--------------+ +----+ + Internal Dependency Internal Dependency + + +Example (3) : Streaming API, 4KiB Block + +---------------+---------------+-----+----+----+ + | 4KiB Chunk A | 4KiB Chunk B | C | D |... | + +---------------+---------------+-----+----+----+ + | Block #1 | Block #2 | #3 | #4 |... | + +---------------+----+----------+-+---+-+--+----+ + ^ | ^ | ^ | + | | | | | | + +--------------+ +--------+ +---+ + Dependency Dependency Dependency +``` + + - In example (1), there is no dependency. + All blocks are compressed independently. + - In example (2), naturally 8KiBytes block has internal dependency. + But still block #1 and #2 are compressed independently. + - In example (3), block #2 has dependency to #1, + also #3 has dependency to #2 and #1, #4 has #3, #2 and #1, and so on. + +Here, we can observe difference between example (2) and (3). +In (2), there's no dependency between chunk B and C, but (3) has dependency between B and C. +This dependency improves compression ratio. + + +## Restriction of Streaming API + +For the efficiency, Streaming API doesn't keep mirror copy of dependent (de)compressed memory. +This means users should keep these dependent (de)compressed memory explicitly. +Usually, "Dependent memory" is previous adjacent contiguous memory up to 64KiBytes. +LZ4 will not access further memories. -- cgit v0.12 From 438fee9169d2267f46ddd54f770b5f22a61ebb86 Mon Sep 17 00:00:00 2001 From: Takayuki MATSUOKA Date: Wed, 25 Mar 2015 07:52:17 +0900 Subject: Add document for "Double Buffer" example --- examples/blockStreaming_doubleBuffer.md | 99 +++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 examples/blockStreaming_doubleBuffer.md diff --git a/examples/blockStreaming_doubleBuffer.md b/examples/blockStreaming_doubleBuffer.md new file mode 100644 index 0000000..cd295df --- /dev/null +++ b/examples/blockStreaming_doubleBuffer.md @@ -0,0 +1,99 @@ +# LZ4 Streaming API Example : Double Buffer + +`blockStreaming_doubleBuffer.c` is LZ4 Straming API example which implements double buffer (de)compression. + +Please note : + + - Firstly, read "LZ4 Streaming API Basics". + - This is relatively advanced application example. + - Output file is not compatible with lz4frame and platform dependent. + + +## What's the point of this example ? + + - Handle huge file in small amount of memory + - Always better compression ratio than Block API + - Uniform block size + + +## How the compression works + +First of all, allocate "Double Buffer" for input and LZ4 compressed data buffer for output. +Double buffer has two pages, "first" page (Page#1) and "second" page (Page#2). + +``` + Double Buffer + + Page#1 Page#2 + +---------+---------+ + | Block#1 | | + +----+----+---------+ + | + v + {Out#1} + + + Prefix Dependency + +---------+ + | | + v | + +---------+----+----+ + | Block#1 | Block#2 | + +---------+----+----+ + | + v + {Out#2} + + + External Dictionary Mode + +---------+ + | | + | v + +----+----+---------+ + | Block#3 | Block#2 | + +----+----+---------+ + | + v + {Out#3} + + + Prefix Dependency + +---------+ + | | + v | + +---------+----+----+ + | Block#3 | Block#4 | + +---------+----+----+ + | + v + {Out#4} +``` + +Next, read first block to double buffer's first page. And compress it by `LZ4_compress_continue()`. +For the first time, LZ4 doesn't know any previous dependencies, +so it just compress the line without dependencies and generates compressed block {Out#1} to LZ4 compressed data buffer. +After that, write {Out#1} to the file. + +Next, read second block to double buffer's second page. And compress it. +In this time, LZ4 can use dependency to Block#1 to improve compression ratio. +This dependency is called "Prefix mode". + +Next, read third block to double buffer's *first* page. And compress it. +Also this time, LZ4 can use dependency to Block#2. +This dependency is called "External Dictonaly mode". + +Continue these procedure to the end of the file. + + +## How the decompression works + +Decompression will do reverse order. + + - Read first compressed block. + - Decompress it to the first page and write that page to the file. + - Read second compressed block. + - Decompress it to the second page and write that page to the file. + - Read third compressed block. + - Decompress it to the *first* page and write that page to the file. + +Continue these procedure to the end of the compressed file. -- cgit v0.12 From 19665c93ea4a25e02970a53ec5d2cd1af9303c43 Mon Sep 17 00:00:00 2001 From: Takayuki MATSUOKA Date: Wed, 25 Mar 2015 07:52:35 +0900 Subject: Add document for "Line by Line Text Compression" example --- examples/blockStreaming_lineByLine.md | 121 ++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 examples/blockStreaming_lineByLine.md diff --git a/examples/blockStreaming_lineByLine.md b/examples/blockStreaming_lineByLine.md new file mode 100644 index 0000000..1d379a0 --- /dev/null +++ b/examples/blockStreaming_lineByLine.md @@ -0,0 +1,121 @@ +# LZ4 Streaming API Example : Line by Line Text Compression + +`blockStreaming_lineByLine.c` is LZ4 Straming API example which implements line by line incremental (de)compression. + +Please note the following restrictions : + + - Firstly, read "LZ4 Streaming API Basics". + - This is relatively advanced application example. + - Output file is not compatible with lz4frame and platform dependent. + + +## What's the point of this example ? + + - Line by line incremental (de)compression. + - Handle huge file in small amount of memory + - Generally better compression ratio than Block API + - Non-uniform block size + + +## How the compression works + +First of all, allocate "Ring Buffer" for input and LZ4 compressed data buffer for output. + +``` +(1) + Ring Buffer + + +--------+ + | Line#1 | + +---+----+ + | + v + {Out#1} + + +(2) + Prefix Mode Dependency + +----+ + | | + v | + +--------+-+------+ + | Line#1 | Line#2 | + +--------+---+----+ + | + v + {Out#2} + + +(3) + Prefix Prefix + +----+ +----+ + | | | | + v | v | + +--------+-+------+-+------+ + | Line#1 | Line#2 | Line#3 | + +--------+--------+---+----+ + | + v + {Out#3} + + +(4) + External Dictionary Mode + +----+ +----+ + | | | | + v | v | + ------+--------+-+------+-+--------+ + | .... | Line#X | Line#X+1 | + ------+--------+--------+-----+----+ + ^ | + | v + | {Out#X+1} + | + Reset + + +(5) + Prefix + +-----+ + | | + v | + ------+--------+--------+----------+--+-------+ + | .... | Line#X | Line#X+1 | Line#X+2 | + ------+--------+--------+----------+-----+----+ + ^ | + | v + | {Out#X+2} + | + Reset +``` + +Next (see (1)), read first line to ringbuffer and compress it by `LZ4_compress_continue()`. +For the first time, LZ4 doesn't know any previous dependencies, +so it just compress the line without dependencies and generates compressed line {Out#1} to LZ4 compressed data buffer. +After that, write {Out#1} to the file and forward ringbuffer offset. + +Do the same things to second line (see (2)). +But in this time, LZ4 can use dependency to Line#1 to improve compression ratio. +This dependency is called "Prefix mode". + +Eventually, we'll reach end of ringbuffer at Line#X (see (4)). +This time, we should reset ringbuffer offset. +After resetting, at Line#X+1 pointer is not adjacent, but LZ4 still maintain its memory. +This is called "External Dictionary Mode". + +In Line#X+2 (see (5)), finally LZ4 forget almost all memories but still remains Line#X+1. +This is the same situation as Line#2. + +Continue these procedure to the end of text file. + + +## How the decompression works + +Decompression will do reverse order. + + - Read compressed line from the file to buffer. + - Decompress it to the ringbuffer. + - Output decompressed plain text line to the file. + - Forward ringbuffer offset. If offset exceedes end of the ringbuffer, reset it. + +Continue these procedure to the end of the compressed file. -- cgit v0.12 From 679afea730344759dabf524e2394a2bc3015fb6b Mon Sep 17 00:00:00 2001 From: Takayuki MATSUOKA Date: Wed, 25 Mar 2015 07:53:02 +0900 Subject: Add README.md as table of contents --- examples/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 examples/README.md diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..d0800b6 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,7 @@ +# LZ4 examples + +## Documents + + - [Streaming API Basics](streaming_api_basics.md) + - [Double Buffer](blockStreaming_doubleBuffer.md) + - [Line by Line Text Compression](blockStreaming_lineByLine.md) -- cgit v0.12 From 2af52a90b3759e589d608782a987d2b3d73abefb Mon Sep 17 00:00:00 2001 From: Takayuki MATSUOKA Date: Wed, 25 Mar 2015 08:12:18 +0900 Subject: Add "Examples" subtree --- examples/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/README.md b/examples/README.md index d0800b6..1b62d9e 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,5 +3,6 @@ ## Documents - [Streaming API Basics](streaming_api_basics.md) - - [Double Buffer](blockStreaming_doubleBuffer.md) - - [Line by Line Text Compression](blockStreaming_lineByLine.md) + - Examples + - [Double Buffer](blockStreaming_doubleBuffer.md) + - [Line by Line Text Compression](blockStreaming_lineByLine.md) -- cgit v0.12 From 4a9335bd605421218e3cc87dc77c4634051469eb Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 25 Mar 2015 17:22:26 +0100 Subject: Added : doc authorship --- examples/blockStreaming_doubleBuffer.md | 1 + examples/blockStreaming_lineByLine.md | 1 + examples/streaming_api_basics.md | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/blockStreaming_doubleBuffer.md b/examples/blockStreaming_doubleBuffer.md index cd295df..3027ea3 100644 --- a/examples/blockStreaming_doubleBuffer.md +++ b/examples/blockStreaming_doubleBuffer.md @@ -1,4 +1,5 @@ # LZ4 Streaming API Example : Double Buffer +by *Takayuki Matsuoka* `blockStreaming_doubleBuffer.c` is LZ4 Straming API example which implements double buffer (de)compression. diff --git a/examples/blockStreaming_lineByLine.md b/examples/blockStreaming_lineByLine.md index 1d379a0..4735f92 100644 --- a/examples/blockStreaming_lineByLine.md +++ b/examples/blockStreaming_lineByLine.md @@ -1,4 +1,5 @@ # LZ4 Streaming API Example : Line by Line Text Compression +by *Takayuki Matsuoka* `blockStreaming_lineByLine.c` is LZ4 Straming API example which implements line by line incremental (de)compression. diff --git a/examples/streaming_api_basics.md b/examples/streaming_api_basics.md index 6c2632f..a88d733 100644 --- a/examples/streaming_api_basics.md +++ b/examples/streaming_api_basics.md @@ -1,5 +1,5 @@ # LZ4 Streaming API Basics - +by *Takayuki Matsuoka* ## LZ4 API sets LZ4 has the following API sets : -- cgit v0.12 From a357f434f06de70e5d670b8669becccb09f4c7a6 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 25 Mar 2015 18:06:40 +0100 Subject: Fixed cast-align warnings on 32-bits --- lib/lz4.c | 2 +- lib/lz4.h | 4 ++-- lib/lz4hc.c | 2 +- lib/lz4hc.h | 16 +++++++++++----- lib/xxhash.h | 18 ++++++++++-------- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/lib/lz4.c b/lib/lz4.c index e15a022..881d1af 100644 --- a/lib/lz4.c +++ b/lib/lz4.c @@ -1321,7 +1321,7 @@ void* LZ4_create (const char* inputBuffer) char* LZ4_slideInputBuffer (void* LZ4_Data) { LZ4_stream_t_internal* ctx = (LZ4_stream_t_internal*)LZ4_Data; - int dictSize = LZ4_saveDict((LZ4_stream_t*)ctx, (char*)ctx->bufferStart, 64 KB); + int dictSize = LZ4_saveDict((LZ4_stream_t*)LZ4_Data, (char*)ctx->bufferStart, 64 KB); return (char*)(ctx->bufferStart + dictSize); } diff --git a/lib/lz4.h b/lib/lz4.h index 7b938da..de43fc0 100644 --- a/lib/lz4.h +++ b/lib/lz4.h @@ -39,8 +39,8 @@ extern "C" { #endif /* - * lz4.h provides raw compression format functions, for optimal performance and integration into programs. - * If you need to generate data using an inter-operable format (respecting the framing specification), + * lz4.h provides block compression functions, for optimal performance. + * If you need to generate inter-operable compressed data (respecting LZ4 frame specification), * please use lz4frame.h instead. */ diff --git a/lib/lz4hc.c b/lib/lz4hc.c index 357fa96..a03c511 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -594,7 +594,7 @@ int LZ4_freeStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr) { free(LZ4_streamHCPtr); /* initialization */ void LZ4_resetStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel) { - LZ4_STATIC_ASSERT(sizeof(LZ4HC_Data_Structure) <= LZ4_STREAMHCSIZE); /* if compilation fails here, LZ4_STREAMHCSIZE must be increased */ + LZ4_STATIC_ASSERT(sizeof(LZ4HC_Data_Structure) <= sizeof(LZ4_streamHC_t)); /* if compilation fails here, LZ4_STREAMHCSIZE must be increased */ ((LZ4HC_Data_Structure*)LZ4_streamHCPtr)->base = NULL; ((LZ4HC_Data_Structure*)LZ4_streamHCPtr)->compressionLevel = (unsigned)compressionLevel; } diff --git a/lib/lz4hc.h b/lib/lz4hc.h index eb72051..4a05845 100644 --- a/lib/lz4hc.h +++ b/lib/lz4hc.h @@ -79,7 +79,7 @@ int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize /************************************** - Using an external allocation +* Using an external allocation **************************************/ int LZ4_sizeofStateHC(void); int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize); @@ -102,12 +102,18 @@ They just use the externally allocated memory for state instead of allocating th +/***************************** +* Includes +*****************************/ +#include /* size_t */ + + /************************************** - Experimental Streaming Functions +* Experimental Streaming Functions **************************************/ -#define LZ4_STREAMHCSIZE_U64 32774 -#define LZ4_STREAMHCSIZE (LZ4_STREAMHCSIZE_U64 * sizeof(unsigned long long)) -typedef struct { unsigned long long table[LZ4_STREAMHCSIZE_U64]; } LZ4_streamHC_t; +#define LZ4_STREAMHCSIZE 262192 +#define LZ4_STREAMHCSIZE_SIZET (LZ4_STREAMHCSIZE / sizeof(size_t)) +typedef struct { size_t table[LZ4_STREAMHCSIZE_SIZET]; } LZ4_streamHC_t; /* LZ4_streamHC_t This structure allows static allocation of LZ4 HC streaming state. diff --git a/lib/xxhash.h b/lib/xxhash.h index 99b0c27..34eea73 100644 --- a/lib/xxhash.h +++ b/lib/xxhash.h @@ -56,6 +56,12 @@ SHA1-32 0.28 GB/s 10 Q.Score is a measure of quality of the hash function. It depends on successfully passing SMHasher test set. 10 is a perfect score. + +A new 64-bits version, named XXH64, is available since r35. +It offers better speed for 64-bits applications. +Name Speed on 64 bits Speed on 32 bits +XXH64 13.8 GB/s 1.9 GB/s +XXH32 6.8 GB/s 6.0 GB/s */ #pragma once @@ -66,20 +72,15 @@ extern "C" { /***************************** - Includes +* Definitions *****************************/ #include /* size_t */ - - -/***************************** - Type -*****************************/ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode; /***************************** - Simple Hash Functions +* Simple Hash Functions *****************************/ unsigned int XXH32 (const void* input, size_t length, unsigned seed); @@ -94,12 +95,13 @@ XXH32() : Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s XXH64() : Calculate the 64-bits hash of sequence of length "len" stored at memory address "input". + Faster on 64-bits systems. Slower on 32-bits systems. */ /***************************** - Advanced Hash Functions +* Advanced Hash Functions *****************************/ typedef struct { long long ll[ 6]; } XXH32_state_t; typedef struct { long long ll[11]; } XXH64_state_t; -- cgit v0.12 From b4755c79026b6ac0b7f300933e9c022d35fb7460 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 25 Mar 2015 23:59:38 +0100 Subject: Added : arm cross-compilation test --- .travis.yml | 6 ++++-- Makefile | 10 +++++++--- NEWS | 3 ++- programs/Makefile | 8 ++++++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e975b5..8fabb1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,19 +3,21 @@ compiler: gcc script: make test-travis before_install: - sudo apt-get update -qq + - sudo apt-get install -qq gcc-arm-linux-gnueabi - sudo apt-get install -qq clang - sudo apt-get install -qq g++-multilib - sudo apt-get install -qq gcc-multilib - sudo apt-get install -qq valgrind env: + - LZ4_TRAVIS_CI_ENV=dist - LZ4_TRAVIS_CI_ENV=travis-install - LZ4_TRAVIS_CI_ENV=streaming-examples - LZ4_TRAVIS_CI_ENV=cmake - - LZ4_TRAVIS_CI_ENV=gpptest - LZ4_TRAVIS_CI_ENV=clangtest - LZ4_TRAVIS_CI_ENV=staticAnalyze - - LZ4_TRAVIS_CI_ENV=dist + - LZ4_TRAVIS_CI_ENV=gpptest + - LZ4_TRAVIS_CI_ENV=armtest - LZ4_TRAVIS_CI_ENV=test-lz4 - LZ4_TRAVIS_CI_ENV=test-lz4c - LZ4_TRAVIS_CI_ENV=test-lz4c32 diff --git a/Makefile b/Makefile index 5e6157f..451672b 100644 --- a/Makefile +++ b/Makefile @@ -127,15 +127,19 @@ test-travis: $(TRAVIS_TARGET) cmake: @cd cmake_unofficial; cmake CMakeLists.txt; $(MAKE) -gpptest: clean - export CC=g++; export CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align"; $(MAKE) -e all - clangtest: clean export CC=clang; $(MAKE) all staticAnalyze: clean export CFLAGS=-g; scan-build -v $(MAKE) all +gpptest: clean + export CC=g++; export CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align"; $(MAKE) -e all + +armtest: clean + export CC=arm-linux-gnueabi-gcc; cd lib; $(MAKE) -e all + export CC=arm-linux-gnueabi-gcc; cd programs; $(MAKE) -e bins + streaming-examples: cd examples; $(MAKE) -e test diff --git a/NEWS b/NEWS index aea9cd1..2eeb948 100644 --- a/NEWS +++ b/NEWS @@ -7,9 +7,10 @@ New : lz4frame & lz4cli frame content size support New : lz4frame supports skippable frames Changed:Default "make install" directory is /usr/local New : lz4 cli supports "pass-through" mode -New : g++ compatibility tests New : datagen can generate sparse files New : scan-build tests +New : g++ compatibility tests +New : arm cross-compilation test Fixed : Fuzzer + frametest compatibility with NetBSD (issue #48) Added : Visual project directory Updated:Man page & Specification diff --git a/programs/Makefile b/programs/Makefile index a5ae8d3..a324148 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -61,9 +61,13 @@ endif TRAVIS_TARGET=$(LZ4_TRAVIS_CI_ENV) -default: lz4 lz4c +default: lz4 -all: lz4 lz4c lz4c32 fullbench fullbench32 fuzzer fuzzer32 frametest frametest32 datagen +m32: lz4c32 fullbench32 fuzzer32 frametest32 + +bins: lz4 lz4c fullbench fuzzer frametest datagen + +all: bins m32 lz4: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c bench.c lz4io.c lz4cli.c $(CC) $(FLAGS) $^ -o $@$(EXT) -- cgit v0.12 From 27f7d06ca83e7b9262f9a0cf8a8540b785d4a716 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 26 Mar 2015 00:28:14 +0100 Subject: minor beautifier (make clean) --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 451672b..b6c2a97 100644 --- a/Makefile +++ b/Makefile @@ -79,10 +79,10 @@ lz4programs: @cd $(PRGDIR); $(MAKE) -e clean: - @rm -f $(DISTRIBNAME) *.sha1 - @cd $(PRGDIR); $(MAKE) clean - @cd $(LZ4DIR); $(MAKE) clean - @cd examples; $(MAKE) clean + @rm -f $(DISTRIBNAME) *.sha1 > /dev/null + @cd $(PRGDIR); $(MAKE) clean > /dev/null + @cd $(LZ4DIR); $(MAKE) clean > /dev/null + @cd examples; $(MAKE) clean > /dev/null @echo Cleaning completed -- cgit v0.12 From b0097677f26cf2027a1608bb5d713212fed3b542 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 26 Mar 2015 11:41:55 +0100 Subject: windows friendly make clean --- Makefile | 337 +++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 221 insertions(+), 116 deletions(-) diff --git a/Makefile b/Makefile index b6c2a97..a324148 100644 --- a/Makefile +++ b/Makefile @@ -1,88 +1,111 @@ -# ################################################################ -# LZ4 - Makefile +# ########################################################################## +# LZ4 programs - Makefile # Copyright (C) Yann Collet 2011-2015 -# All rights reserved. -# -# BSD license -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, this -# list of conditions and the following disclaimer in the documentation and/or -# other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# +# +# GPL v2 License +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# # You can contact the author at : # - LZ4 source repository : https://github.com/Cyan4973/lz4 -# - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c -# ################################################################ - -# Version number -export VERSION=128 -export RELEASE=r$(VERSION) +# - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c +# ########################################################################## +# lz4 : Command Line Utility, supporting gzip-like arguments +# lz4c : CLU, supporting also legacy lz4demo arguments +# lz4c32: Same as lz4c, but forced to compile in 32-bits mode +# fuzzer : Test tool, to check lz4 integrity on target platform +# fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode +# fullbench : Precisely measure speed for each LZ4 function variant +# fullbench32: Same as fullbench, but forced to compile in 32-bits mode +# ########################################################################## + +RELEASE?= r128 DESTDIR?= PREFIX ?= /usr/local +CFLAGS ?= -O3 +CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -pedantic -DLZ4_VERSION=\"$(RELEASE)\" +FLAGS = -I../lib $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -LIBDIR ?= $(PREFIX)/lib -INCLUDEDIR=$(PREFIX)/include -PRGDIR = programs -LZ4DIR = lib -DISTRIBNAME=lz4-$(RELEASE).tar.gz - -TEXT = $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4.h $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4hc.h \ - $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4frame.h $(LZ4DIR)/lz4frame_static.h \ - $(LZ4DIR)/xxhash.c $(LZ4DIR)/xxhash.h \ - $(LZ4DIR)/liblz4.pc.in $(LZ4DIR)/Makefile $(LZ4DIR)/LICENSE \ - Makefile lz4_block_format.txt LZ4_Frame_Format.html NEWS README.md \ - cmake_unofficial/CMakeLists.txt \ - $(PRGDIR)/fullbench.c $(PRGDIR)/lz4cli.c \ - $(PRGDIR)/datagen.c $(PRGDIR)/datagen.h $(PRGDIR)/datagencli.c $(PRGDIR)/fuzzer.c \ - $(PRGDIR)/lz4io.c $(PRGDIR)/lz4io.h \ - $(PRGDIR)/bench.c $(PRGDIR)/bench.h \ - $(PRGDIR)/lz4.1 \ - $(PRGDIR)/Makefile $(PRGDIR)/COPYING -NONTEXT = images/image00.png images/image01.png images/image02.png \ - images/image03.png images/image04.png images/image05.png \ - images/image06.png -SOURCES = $(TEXT) $(NONTEXT) +BINDIR=$(PREFIX)/bin +MANDIR=$(PREFIX)/share/man/man1 +LZ4DIR=../lib +TEST_FILES = COPYING +TEST_TARGETS=test-native -# Select test target for Travis CI's Build Matrix -ifneq (,$(filter test-%,$(LZ4_TRAVIS_CI_ENV))) -TRAVIS_TARGET=prg-travis + +# Define *.exe as extension for Windows systems +ifneq (,$(filter Windows%,$(OS))) +EXT =.exe +VOID = nul else -TRAVIS_TARGET=$(LZ4_TRAVIS_CI_ENV) +EXT = +VOID = /dev/null endif -default: lz4programs +# Select test target for Travis CI's Build Matrix +TRAVIS_TARGET=$(LZ4_TRAVIS_CI_ENV) + + +default: lz4 + +m32: lz4c32 fullbench32 fuzzer32 frametest32 + +bins: lz4 lz4c fullbench fuzzer frametest datagen + +all: bins m32 + +lz4: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c bench.c lz4io.c lz4cli.c + $(CC) $(FLAGS) $^ -o $@$(EXT) -all: - @cd $(LZ4DIR); $(MAKE) -e all - @cd $(PRGDIR); $(MAKE) -e all +lz4c : $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c bench.c lz4io.c lz4cli.c + $(CC) $(FLAGS) -DENABLE_LZ4C_LEGACY_OPTIONS $^ -o $@$(EXT) -lz4programs: - @cd $(PRGDIR); $(MAKE) -e +lz4c32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c bench.c lz4io.c lz4cli.c + $(CC) -m32 $(FLAGS) -DENABLE_LZ4C_LEGACY_OPTIONS $^ -o $@$(EXT) + +fullbench : $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c fullbench.c + $(CC) $(FLAGS) $^ -o $@$(EXT) + +fullbench32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c fullbench.c + $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) + +fuzzer : $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c fuzzer.c + $(CC) $(FLAGS) $^ -o $@$(EXT) + +fuzzer32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c fuzzer.c + $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) + +frametest: $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c frametest.c + $(CC) $(FLAGS) $^ -o $@$(EXT) + +frametest32: $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c frametest.c + $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) + +datagen : datagen.c datagencli.c + $(CC) $(FLAGS) $^ -o $@$(EXT) clean: - @rm -f $(DISTRIBNAME) *.sha1 > /dev/null - @cd $(PRGDIR); $(MAKE) clean > /dev/null - @cd $(LZ4DIR); $(MAKE) clean > /dev/null - @cd examples; $(MAKE) clean > /dev/null + @rm -f core *.o *.test \ + lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) \ + fullbench$(EXT) fullbench32$(EXT) \ + fuzzer$(EXT) fuzzer32$(EXT) \ + frametest$(EXT) frametest32$(EXT) \ + datagen$(EXT) @echo Cleaning completed @@ -90,60 +113,142 @@ clean: #make install is validated only for Linux, OSX, kFreeBSD and Hurd targets ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU)) -install: - @cd $(LZ4DIR); $(MAKE) -e install - @cd $(PRGDIR); $(MAKE) -e install +install: lz4 lz4c + @echo Installing binaries + @install -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/ + @install -m 755 lz4 $(DESTDIR)$(BINDIR)/lz4 + @ln -sf lz4 $(DESTDIR)$(BINDIR)/lz4cat + @ln -sf lz4 $(DESTDIR)$(BINDIR)/unlz4 + @install -m 755 lz4c $(DESTDIR)$(BINDIR)/lz4c + @echo Installing man pages + @install -m 644 lz4.1 $(DESTDIR)$(MANDIR)/lz4.1 + @ln -sf lz4.1 $(DESTDIR)$(MANDIR)/lz4c.1 + @ln -sf lz4.1 $(DESTDIR)$(MANDIR)/lz4cat.1 + @ln -sf lz4.1 $(DESTDIR)$(MANDIR)/unlz4.1 + @echo lz4 installation completed uninstall: - @cd $(LZ4DIR); $(MAKE) uninstall - @cd $(PRGDIR); $(MAKE) uninstall - -travis-install: - sudo $(MAKE) install - -dist: clean - @install -dD -m 700 lz4-$(RELEASE)/lib/ - @install -dD -m 700 lz4-$(RELEASE)/programs/ - @install -dD -m 700 lz4-$(RELEASE)/cmake_unofficial/ - @install -dD -m 700 lz4-$(RELEASE)/images/ - @for f in $(TEXT); do \ - tr -d '\r' < $$f > .tmp; \ - install -m 600 .tmp lz4-$(RELEASE)/$$f; \ - done - @rm .tmp - @for f in $(NONTEXT); do \ - install -m 600 $$f lz4-$(RELEASE)/$$f; \ - done - @tar -czf $(DISTRIBNAME) lz4-$(RELEASE)/ - @rm -rf lz4-$(RELEASE) - @sha1sum $(DISTRIBNAME) > $(DISTRIBNAME).sha1 - @echo Distribution $(DISTRIBNAME) built - -test: - @cd $(PRGDIR); $(MAKE) -e test - -test-travis: $(TRAVIS_TARGET) + rm -f $(DESTDIR)$(BINDIR)/lz4cat + rm -f $(DESTDIR)$(BINDIR)/unlz4 + [ -x $(DESTDIR)$(BINDIR)/lz4 ] && rm -f $(DESTDIR)$(BINDIR)/lz4 + [ -x $(DESTDIR)$(BINDIR)/lz4c ] && rm -f $(DESTDIR)$(BINDIR)/lz4c + [ -f $(DESTDIR)$(MANDIR)/lz4.1 ] && rm -f $(DESTDIR)$(MANDIR)/lz4.1 + rm -f $(DESTDIR)$(MANDIR)/lz4c.1 + rm -f $(DESTDIR)$(MANDIR)/lz4cat.1 + rm -f $(DESTDIR)$(MANDIR)/unlz4.1 + @echo lz4 programs successfully uninstalled -cmake: - @cd cmake_unofficial; cmake CMakeLists.txt; $(MAKE) +test: test-lz4 test-lz4c test-frametest test-fullbench test-fuzzer test-mem -clangtest: clean - export CC=clang; $(MAKE) all +test32: test-lz4c32 test-frametest32 test-fullbench32 test-fuzzer32 test-mem32 -staticAnalyze: clean - export CFLAGS=-g; scan-build -v $(MAKE) all +test-all: test test32 -gpptest: clean - export CC=g++; export CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align"; $(MAKE) -e all - -armtest: clean - export CC=arm-linux-gnueabi-gcc; cd lib; $(MAKE) -e all - export CC=arm-linux-gnueabi-gcc; cd programs; $(MAKE) -e bins - -streaming-examples: - cd examples; $(MAKE) -e test +test-travis: $(TRAVIS_TARGET) -prg-travis: - @cd $(PRGDIR); $(MAKE) -e test-travis +test-lz4-sparse: lz4 datagen + @echo ---- test sparse file support ---- + ./datagen -g50M -P100 | ./lz4 -B4D | ./lz4 -dv --sparse > tmpB4 + ./datagen -g50M -P100 | ./lz4 -B5D | ./lz4 -dv --sparse > tmpB5 + ./datagen -g50M -P100 | ./lz4 -B6D | ./lz4 -dv --sparse > tmpB6 + ./datagen -g50M -P100 | ./lz4 -B7D | ./lz4 -dv --sparse > tmpB7 + ls -ls tmp* + ./datagen -g50M -P100 | diff -s - tmpB4 + ./datagen -g50M -P100 | diff -s - tmpB5 + ./datagen -g50M -P100 | diff -s - tmpB6 + ./datagen -g50M -P100 | diff -s - tmpB7 + ./datagen -s1 -g1200007 -P100 | ./lz4 | ./lz4 -dv --sparse > tmpOdd # Odd size file (to not finish on an exact nb of blocks) + ./datagen -s1 -g1200007 -P100 | diff -s - tmpOdd + ls -ls tmpOdd + @rm tmp* + +test-lz4-contentSize: lz4 datagen + @echo ---- test original size support ---- + ./datagen -g15M > tmp + ./lz4 -v tmp | ./lz4 -t + ./lz4 -v --content-size tmp | ./lz4 -d > tmp2 + diff -s tmp tmp2 + @rm tmp* + +test-lz4-frame-concatenation: lz4 datagen + @echo ---- test frame concatenation ---- + @echo -n > empty.test + @echo hi > nonempty.test + cat nonempty.test empty.test nonempty.test > orig.test + @./lz4 -zq empty.test > empty.lz4.test + @./lz4 -zq nonempty.test > nonempty.lz4.test + cat nonempty.lz4.test empty.lz4.test nonempty.lz4.test > concat.lz4.test + ./lz4 -d concat.lz4.test > result.test + sdiff orig.test result.test + @rm *.test + @echo frame concatenation test completed + +test-lz4: lz4 datagen test-lz4-sparse test-lz4-contentSize test-lz4-frame-concatenation + @echo ---- test lz4 basic compression/decompression ---- + ./datagen -g0 | ./lz4 -v | ./lz4 -t + ./datagen -g16KB | ./lz4 -9 | ./lz4 -t + ./datagen | ./lz4 | ./lz4 -t + ./datagen -g6M -P99 | ./lz4 -9BD | ./lz4 -t + ./datagen -g17M | ./lz4 -9v | ./lz4 -tq + ./datagen -g33M | ./lz4 --no-frame-crc | ./lz4 -t + ./datagen -g256MB | ./lz4 -vqB4D | ./lz4 -t + ./datagen -g6GB | ./lz4 -vqB5D | ./lz4 -t + ./datagen -g6GB | ./lz4 -vq9BD | ./lz4 -t + @echo ---- test multiple input files ---- + @./datagen -s1 > file1 + @./datagen -s2 > file2 + @./datagen -s3 > file3 + ./lz4 -f -m file1 file2 file3 + ls -l file* + @rm file1 file2 file3 file1.lz4 file2.lz4 file3.lz4 + @echo ---- test pass-through ---- + ./datagen | ./lz4 -tf + +test-lz4c: lz4c datagen + ./datagen -g256MB | ./lz4c -l -v | ./lz4c -t + +test-lz4c32: lz4 lz4c32 datagen + ./datagen -g16KB | ./lz4c32 -9 | ./lz4c32 -t + ./datagen -g16KB | ./lz4c32 -9 | ./lz4 -t + ./datagen | ./lz4c32 | ./lz4c32 -t + ./datagen | ./lz4c32 | ./lz4 -t + ./datagen -g256MB | ./lz4c32 -vqB4D | ./lz4c32 -t + ./datagen -g256MB | ./lz4c32 -vqB4D | ./lz4 -t + ./datagen -g6GB | ./lz4c32 -vqB5D | ./lz4c32 -t + ./datagen -g6GB | ./lz4c32 -vq9BD | ./lz4 -t + +test-fullbench: fullbench + ./fullbench --no-prompt $(TEST_FILES) + +test-fullbench32: fullbench32 + ./fullbench32 --no-prompt $(TEST_FILES) + +test-fuzzer: fuzzer + ./fuzzer + +test-fuzzer32: fuzzer32 + ./fuzzer32 + +test-frametest: frametest + ./frametest + +test-frametest32: frametest32 + ./frametest32 + +test-mem: lz4 datagen fuzzer frametest + valgrind --leak-check=yes ./datagen -g50M > $(VOID) + ./datagen -g16KB > tmp + valgrind --leak-check=yes ./lz4 -9 -BD -f tmp $(VOID) + ./datagen -g16MB > tmp + valgrind --leak-check=yes ./lz4 -9 -B5D -f tmp tmp2 + valgrind --leak-check=yes ./lz4 -t tmp2 + ./datagen -g256MB > tmp + valgrind --leak-check=yes ./lz4 -B4D -f -vq tmp $(VOID) + rm tmp* + valgrind --leak-check=yes ./fuzzer -i64 -t1 + valgrind --leak-check=yes ./frametest -i256 + +test-mem32: lz4c32 datagen +# unfortunately, valgrind doesn't seem to work with non-native binary. If someone knows how to do a valgrind-test on a 32-bits exe with a 64-bits system... endif -- cgit v0.12 From 5780864c0ce08622238a267c46fb489d7066cad4 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 26 Mar 2015 14:16:20 +0100 Subject: Fixed : Makefile --- Makefile | 336 ++++++++++++++++++++++----------------------------------------- 1 file changed, 119 insertions(+), 217 deletions(-) diff --git a/Makefile b/Makefile index a324148..59c5e3b 100644 --- a/Makefile +++ b/Makefile @@ -1,111 +1,95 @@ -# ########################################################################## -# LZ4 programs - Makefile +# ################################################################ +# LZ4 - Makefile # Copyright (C) Yann Collet 2011-2015 -# -# GPL v2 License -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# +# All rights reserved. +# +# BSD license +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, this +# list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# # You can contact the author at : # - LZ4 source repository : https://github.com/Cyan4973/lz4 -# - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c -# ########################################################################## -# lz4 : Command Line Utility, supporting gzip-like arguments -# lz4c : CLU, supporting also legacy lz4demo arguments -# lz4c32: Same as lz4c, but forced to compile in 32-bits mode -# fuzzer : Test tool, to check lz4 integrity on target platform -# fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode -# fullbench : Precisely measure speed for each LZ4 function variant -# fullbench32: Same as fullbench, but forced to compile in 32-bits mode -# ########################################################################## - -RELEASE?= r128 +# - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c +# ################################################################ + +# Version number +export VERSION=128 +export RELEASE=r$(VERSION) DESTDIR?= PREFIX ?= /usr/local -CFLAGS ?= -O3 -CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -pedantic -DLZ4_VERSION=\"$(RELEASE)\" -FLAGS = -I../lib $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -BINDIR=$(PREFIX)/bin -MANDIR=$(PREFIX)/share/man/man1 -LZ4DIR=../lib +LIBDIR ?= $(PREFIX)/lib +INCLUDEDIR=$(PREFIX)/include +PRGDIR = programs +LZ4DIR = lib +DISTRIBNAME=lz4-$(RELEASE).tar.gz + +TEXT = $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4.h $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4hc.h \ + $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4frame.h $(LZ4DIR)/lz4frame_static.h \ + $(LZ4DIR)/xxhash.c $(LZ4DIR)/xxhash.h \ + $(LZ4DIR)/liblz4.pc.in $(LZ4DIR)/Makefile $(LZ4DIR)/LICENSE \ + Makefile lz4_block_format.txt LZ4_Frame_Format.html NEWS README.md \ + cmake_unofficial/CMakeLists.txt \ + $(PRGDIR)/fullbench.c $(PRGDIR)/lz4cli.c \ + $(PRGDIR)/datagen.c $(PRGDIR)/datagen.h $(PRGDIR)/datagencli.c $(PRGDIR)/fuzzer.c \ + $(PRGDIR)/lz4io.c $(PRGDIR)/lz4io.h \ + $(PRGDIR)/bench.c $(PRGDIR)/bench.h \ + $(PRGDIR)/lz4.1 \ + $(PRGDIR)/Makefile $(PRGDIR)/COPYING +NONTEXT = images/image00.png images/image01.png images/image02.png \ + images/image03.png images/image04.png images/image05.png \ + images/image06.png +SOURCES = $(TEXT) $(NONTEXT) -TEST_FILES = COPYING -TEST_TARGETS=test-native +# Select test target for Travis CI's Build Matrix +ifneq (,$(filter test-%,$(LZ4_TRAVIS_CI_ENV))) +TRAVIS_TARGET=prg-travis +else +TRAVIS_TARGET=$(LZ4_TRAVIS_CI_ENV) +endif -# Define *.exe as extension for Windows systems +# Define nul output ifneq (,$(filter Windows%,$(OS))) -EXT =.exe VOID = nul else -EXT = VOID = /dev/null endif -# Select test target for Travis CI's Build Matrix -TRAVIS_TARGET=$(LZ4_TRAVIS_CI_ENV) - - -default: lz4 - -m32: lz4c32 fullbench32 fuzzer32 frametest32 - -bins: lz4 lz4c fullbench fuzzer frametest datagen - -all: bins m32 - -lz4: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c bench.c lz4io.c lz4cli.c - $(CC) $(FLAGS) $^ -o $@$(EXT) +default: lz4programs -lz4c : $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c bench.c lz4io.c lz4cli.c - $(CC) $(FLAGS) -DENABLE_LZ4C_LEGACY_OPTIONS $^ -o $@$(EXT) +all: + @cd $(LZ4DIR); $(MAKE) -e all + @cd $(PRGDIR); $(MAKE) -e all -lz4c32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c bench.c lz4io.c lz4cli.c - $(CC) -m32 $(FLAGS) -DENABLE_LZ4C_LEGACY_OPTIONS $^ -o $@$(EXT) - -fullbench : $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c fullbench.c - $(CC) $(FLAGS) $^ -o $@$(EXT) - -fullbench32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c fullbench.c - $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) - -fuzzer : $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c fuzzer.c - $(CC) $(FLAGS) $^ -o $@$(EXT) - -fuzzer32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c fuzzer.c - $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) - -frametest: $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c frametest.c - $(CC) $(FLAGS) $^ -o $@$(EXT) - -frametest32: $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c frametest.c - $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) - -datagen : datagen.c datagencli.c - $(CC) $(FLAGS) $^ -o $@$(EXT) +lz4programs: + @cd $(PRGDIR); $(MAKE) -e clean: - @rm -f core *.o *.test \ - lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) \ - fullbench$(EXT) fullbench32$(EXT) \ - fuzzer$(EXT) fuzzer32$(EXT) \ - frametest$(EXT) frametest32$(EXT) \ - datagen$(EXT) + @rm -f $(DISTRIBNAME) *.sha1 > $(VOID) + @cd $(PRGDIR); $(MAKE) clean > $(VOID) + @cd $(LZ4DIR); $(MAKE) clean > $(VOID) + @cd examples; $(MAKE) clean > $(VOID) @echo Cleaning completed @@ -113,142 +97,60 @@ clean: #make install is validated only for Linux, OSX, kFreeBSD and Hurd targets ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU)) -install: lz4 lz4c - @echo Installing binaries - @install -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/ - @install -m 755 lz4 $(DESTDIR)$(BINDIR)/lz4 - @ln -sf lz4 $(DESTDIR)$(BINDIR)/lz4cat - @ln -sf lz4 $(DESTDIR)$(BINDIR)/unlz4 - @install -m 755 lz4c $(DESTDIR)$(BINDIR)/lz4c - @echo Installing man pages - @install -m 644 lz4.1 $(DESTDIR)$(MANDIR)/lz4.1 - @ln -sf lz4.1 $(DESTDIR)$(MANDIR)/lz4c.1 - @ln -sf lz4.1 $(DESTDIR)$(MANDIR)/lz4cat.1 - @ln -sf lz4.1 $(DESTDIR)$(MANDIR)/unlz4.1 - @echo lz4 installation completed +install: + @cd $(LZ4DIR); $(MAKE) -e install + @cd $(PRGDIR); $(MAKE) -e install uninstall: - rm -f $(DESTDIR)$(BINDIR)/lz4cat - rm -f $(DESTDIR)$(BINDIR)/unlz4 - [ -x $(DESTDIR)$(BINDIR)/lz4 ] && rm -f $(DESTDIR)$(BINDIR)/lz4 - [ -x $(DESTDIR)$(BINDIR)/lz4c ] && rm -f $(DESTDIR)$(BINDIR)/lz4c - [ -f $(DESTDIR)$(MANDIR)/lz4.1 ] && rm -f $(DESTDIR)$(MANDIR)/lz4.1 - rm -f $(DESTDIR)$(MANDIR)/lz4c.1 - rm -f $(DESTDIR)$(MANDIR)/lz4cat.1 - rm -f $(DESTDIR)$(MANDIR)/unlz4.1 - @echo lz4 programs successfully uninstalled + @cd $(LZ4DIR); $(MAKE) uninstall + @cd $(PRGDIR); $(MAKE) uninstall + +travis-install: + sudo $(MAKE) install + +dist: clean + @install -dD -m 700 lz4-$(RELEASE)/lib/ + @install -dD -m 700 lz4-$(RELEASE)/programs/ + @install -dD -m 700 lz4-$(RELEASE)/cmake_unofficial/ + @install -dD -m 700 lz4-$(RELEASE)/images/ + @for f in $(TEXT); do \ + tr -d '\r' < $$f > .tmp; \ + install -m 600 .tmp lz4-$(RELEASE)/$$f; \ + done + @rm .tmp + @for f in $(NONTEXT); do \ + install -m 600 $$f lz4-$(RELEASE)/$$f; \ + done + @tar -czf $(DISTRIBNAME) lz4-$(RELEASE)/ + @rm -rf lz4-$(RELEASE) + @sha1sum $(DISTRIBNAME) > $(DISTRIBNAME).sha1 + @echo Distribution $(DISTRIBNAME) built + +test: + @cd $(PRGDIR); $(MAKE) -e test -test: test-lz4 test-lz4c test-frametest test-fullbench test-fuzzer test-mem +test-travis: $(TRAVIS_TARGET) -test32: test-lz4c32 test-frametest32 test-fullbench32 test-fuzzer32 test-mem32 +cmake: + @cd cmake_unofficial; cmake CMakeLists.txt; $(MAKE) -test-all: test test32 +clangtest: clean + export CC=clang; $(MAKE) all -test-travis: $(TRAVIS_TARGET) +staticAnalyze: clean + export CFLAGS=-g; scan-build -v $(MAKE) all + +gpptest: clean + export CC=g++; export CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align"; $(MAKE) -e all + +armtest: clean + export CC=arm-linux-gnueabi-gcc; cd lib; $(MAKE) -e all + export CC=arm-linux-gnueabi-gcc; cd programs; $(MAKE) -e bins + +streaming-examples: + cd examples; $(MAKE) -e test -test-lz4-sparse: lz4 datagen - @echo ---- test sparse file support ---- - ./datagen -g50M -P100 | ./lz4 -B4D | ./lz4 -dv --sparse > tmpB4 - ./datagen -g50M -P100 | ./lz4 -B5D | ./lz4 -dv --sparse > tmpB5 - ./datagen -g50M -P100 | ./lz4 -B6D | ./lz4 -dv --sparse > tmpB6 - ./datagen -g50M -P100 | ./lz4 -B7D | ./lz4 -dv --sparse > tmpB7 - ls -ls tmp* - ./datagen -g50M -P100 | diff -s - tmpB4 - ./datagen -g50M -P100 | diff -s - tmpB5 - ./datagen -g50M -P100 | diff -s - tmpB6 - ./datagen -g50M -P100 | diff -s - tmpB7 - ./datagen -s1 -g1200007 -P100 | ./lz4 | ./lz4 -dv --sparse > tmpOdd # Odd size file (to not finish on an exact nb of blocks) - ./datagen -s1 -g1200007 -P100 | diff -s - tmpOdd - ls -ls tmpOdd - @rm tmp* - -test-lz4-contentSize: lz4 datagen - @echo ---- test original size support ---- - ./datagen -g15M > tmp - ./lz4 -v tmp | ./lz4 -t - ./lz4 -v --content-size tmp | ./lz4 -d > tmp2 - diff -s tmp tmp2 - @rm tmp* - -test-lz4-frame-concatenation: lz4 datagen - @echo ---- test frame concatenation ---- - @echo -n > empty.test - @echo hi > nonempty.test - cat nonempty.test empty.test nonempty.test > orig.test - @./lz4 -zq empty.test > empty.lz4.test - @./lz4 -zq nonempty.test > nonempty.lz4.test - cat nonempty.lz4.test empty.lz4.test nonempty.lz4.test > concat.lz4.test - ./lz4 -d concat.lz4.test > result.test - sdiff orig.test result.test - @rm *.test - @echo frame concatenation test completed - -test-lz4: lz4 datagen test-lz4-sparse test-lz4-contentSize test-lz4-frame-concatenation - @echo ---- test lz4 basic compression/decompression ---- - ./datagen -g0 | ./lz4 -v | ./lz4 -t - ./datagen -g16KB | ./lz4 -9 | ./lz4 -t - ./datagen | ./lz4 | ./lz4 -t - ./datagen -g6M -P99 | ./lz4 -9BD | ./lz4 -t - ./datagen -g17M | ./lz4 -9v | ./lz4 -tq - ./datagen -g33M | ./lz4 --no-frame-crc | ./lz4 -t - ./datagen -g256MB | ./lz4 -vqB4D | ./lz4 -t - ./datagen -g6GB | ./lz4 -vqB5D | ./lz4 -t - ./datagen -g6GB | ./lz4 -vq9BD | ./lz4 -t - @echo ---- test multiple input files ---- - @./datagen -s1 > file1 - @./datagen -s2 > file2 - @./datagen -s3 > file3 - ./lz4 -f -m file1 file2 file3 - ls -l file* - @rm file1 file2 file3 file1.lz4 file2.lz4 file3.lz4 - @echo ---- test pass-through ---- - ./datagen | ./lz4 -tf - -test-lz4c: lz4c datagen - ./datagen -g256MB | ./lz4c -l -v | ./lz4c -t - -test-lz4c32: lz4 lz4c32 datagen - ./datagen -g16KB | ./lz4c32 -9 | ./lz4c32 -t - ./datagen -g16KB | ./lz4c32 -9 | ./lz4 -t - ./datagen | ./lz4c32 | ./lz4c32 -t - ./datagen | ./lz4c32 | ./lz4 -t - ./datagen -g256MB | ./lz4c32 -vqB4D | ./lz4c32 -t - ./datagen -g256MB | ./lz4c32 -vqB4D | ./lz4 -t - ./datagen -g6GB | ./lz4c32 -vqB5D | ./lz4c32 -t - ./datagen -g6GB | ./lz4c32 -vq9BD | ./lz4 -t - -test-fullbench: fullbench - ./fullbench --no-prompt $(TEST_FILES) - -test-fullbench32: fullbench32 - ./fullbench32 --no-prompt $(TEST_FILES) - -test-fuzzer: fuzzer - ./fuzzer - -test-fuzzer32: fuzzer32 - ./fuzzer32 - -test-frametest: frametest - ./frametest - -test-frametest32: frametest32 - ./frametest32 - -test-mem: lz4 datagen fuzzer frametest - valgrind --leak-check=yes ./datagen -g50M > $(VOID) - ./datagen -g16KB > tmp - valgrind --leak-check=yes ./lz4 -9 -BD -f tmp $(VOID) - ./datagen -g16MB > tmp - valgrind --leak-check=yes ./lz4 -9 -B5D -f tmp tmp2 - valgrind --leak-check=yes ./lz4 -t tmp2 - ./datagen -g256MB > tmp - valgrind --leak-check=yes ./lz4 -B4D -f -vq tmp $(VOID) - rm tmp* - valgrind --leak-check=yes ./fuzzer -i64 -t1 - valgrind --leak-check=yes ./frametest -i256 - -test-mem32: lz4c32 datagen -# unfortunately, valgrind doesn't seem to work with non-native binary. If someone knows how to do a valgrind-test on a 32-bits exe with a 64-bits system... +prg-travis: + @cd $(PRGDIR); $(MAKE) -e test-travis endif -- cgit v0.12 From 1ba37f378404f912fffe265a9506147695e158db Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 26 Mar 2015 19:49:15 +0100 Subject: Reference format doc --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 4d6b60a..f960e7d 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,7 @@ Benchmark evaluates the compression of reference [Silesia Corpus](http://sun.aei +The LZ4 block compression format is detailed within [lz4_block_format.txt](lz4_block_format.txt). + +For streaming unknown amount of data and compress files of any size, a frame format has been published, and can be consulted within the file LZ4_Frame_Format.html . + -- cgit v0.12 From ce71b073b5a4a9e2bdd78855f50ddc146baac1c5 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 26 Mar 2015 19:58:19 +0100 Subject: converted to markdown friendly syntax --- lz4_block_format.txt | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lz4_block_format.txt b/lz4_block_format.txt index 2c424c5..e248fd9 100644 --- a/lz4_block_format.txt +++ b/lz4_block_format.txt @@ -1,6 +1,7 @@ -LZ4 Format Description -Last revised: 2012-02-27 -Author : Y. Collet +LZ4 Block Format Description +============================ +Last revised: 2015-03-26; +Author : Yann Collet @@ -11,19 +12,19 @@ using any programming language. LZ4 is an LZ77-type compressor with a fixed, byte-oriented encoding. The most important design principle behind LZ4 is simplicity. It helps to create an easy to read and maintain source code. -It also helps later on for optimisations, compactness, and speed. -There is no entropy encoder backend nor framing layer. +It also helps later on for optimizations, compactness, and speed. +There is no entropy encoder back-end nor framing layer. The latter is assumed to be handled by other parts of the system. -This document only describes the format, +This document only describes the block format, not how the LZ4 compressor nor decompressor actually work. The correctness of the decompressor should not depend on implementation details of the compressor, and vice versa. --- Compressed block format -- - +Compressed block format +----------------------- An LZ4 compressed block is composed of sequences. Schematically, a sequence is a suite of literals, followed by a match copy. @@ -90,8 +91,8 @@ On decoding the matchlength, we reach the end of the compressed sequence, and therefore start another one. --- Parsing restrictions -- - +Parsing restrictions +----------------------- There are specific parsing rules to respect in order to remain compatible with assumptions made by the decoder : 1) The last 5 bytes are always literals @@ -104,8 +105,8 @@ Note that the last sequence is also incomplete, and stops right after literals. --- Additional notes -- - +Additional notes +----------------------- There is no assumption nor limits to the way the compressor searches and selects matches within the source data block. It could be a fast scan, a multi-probe, a full search using BST, -- cgit v0.12