From 2e10aab20f17adfffb2379e828124be12c774779 Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Wed, 16 Nov 2016 08:59:18 +0100 Subject: MinGW doesn't require the import library at all --- lib/README.md | 8 ++++++-- lib/dll/README.md | 12 ++++++------ lib/dll/fullbench-dll/Makefile | 2 +- tests/Makefile | 2 +- visual/README.md | 8 ++++---- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/README.md b/lib/README.md index 430be1f..18793d4 100644 --- a/lib/README.md +++ b/lib/README.md @@ -42,12 +42,16 @@ It must be used with static linking ***only***. DLL can be created using MinGW+MSYS with the `make liblz4` command. This command creates `dll\liblz4.dll` and the import library `dll\liblz4.lib`. -To compile a project the import library has to be added to linking options. +The import library is only required with Visual C++. +The header files `lz4.h`, `lz4hc.h`, `lz4frame.h` and the dynamic library +`dll\liblz4.dll` are required to compile a project using gcc/MinGW. +The dynamic library has to be added to linking options. It means that if a project that uses LZ4 consists of a single `test-dll.c` file it should be compiled with "liblz4.lib". For example: ``` - gcc $(CFLAGS) test-dll.c -o test-dll liblz4.lib + gcc $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\liblz4.dll ``` +The compiled executable will require LZ4 DLL which is available at `dll\liblz4.dll`. #### Miscellaneous diff --git a/lib/dll/README.md b/lib/dll/README.md index 779b8ae..bb3dbd6 100644 --- a/lib/dll/README.md +++ b/lib/dll/README.md @@ -4,9 +4,9 @@ The static and dynamic LZ4 libraries #### The package contents - `dll\liblz4.dll` : The DLL of LZ4 library -- `dll\liblz4.lib` : The import library of LZ4 library -- `include\` : Header files required with LZ4 library +- `dll\liblz4.lib` : The import library of LZ4 library for Visual C++ - `fullbench\` : The example of usage of LZ4 library +- `include\` : Header files required with LZ4 library - `static\liblz4_static.lib` : The static LZ4 library @@ -19,13 +19,13 @@ Use `make` to build `fullbench-dll` and `fullbench-lib`. #### Using LZ4 DLL with gcc/MinGW -The header files from `include\` and the import library `dll\liblz4.lib` +The header files from `include\` and the dynamic library `dll\liblz4.dll` are required to compile a project using gcc/MinGW. -The import library has to be added to linking options. +The dynamic library has to be added to linking options. It means that if a project that uses LZ4 consists of a single `test-dll.c` -file it should be compiled with "liblz4.lib". For example: +file it should be compiled with "liblz4.dll". For example: ``` - gcc $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\liblz4.lib + gcc $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\liblz4.dll ``` The compiled executable will require LZ4 DLL which is available at `dll\liblz4.dll`. diff --git a/lib/dll/fullbench-dll/Makefile b/lib/dll/fullbench-dll/Makefile index 32e13fc..680e1b6 100644 --- a/lib/dll/fullbench-dll/Makefile +++ b/lib/dll/fullbench-dll/Makefile @@ -54,7 +54,7 @@ fullbench-lib: fullbench/fullbench.c fullbench/xxhash.c $(CC) $(FLAGS) $^ -o $@$(EXT) static/liblz4_static.lib fullbench-dll: fullbench/fullbench.c fullbench/xxhash.c - $(CC) $(FLAGS) $^ -o $@$(EXT) -DLZ4_DLL_IMPORT=1 dll/liblz4.lib + $(CC) $(FLAGS) $^ -o $@$(EXT) -DLZ4_DLL_IMPORT=1 dll/liblz4.dll clean: @$(RM) fullbench-dll$(EXT) fullbench-lib$(EXT) \ diff --git a/tests/Makefile b/tests/Makefile index 2132f85..4e96769 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -94,7 +94,7 @@ fullbench-lib: fullbench.c $(LZ4DIR)/xxhash.c fullbench-dll: fullbench.c $(LZ4DIR)/xxhash.c $(MAKE) -C $(LZ4DIR) liblz4 - $(CC) $(FLAGS) $^ -o $@$(EXT) -DLZ4_DLL_IMPORT=1 $(LZ4DIR)/dll/liblz4.lib + $(CC) $(FLAGS) $^ -o $@$(EXT) -DLZ4_DLL_IMPORT=1 $(LZ4DIR)/dll/liblz4.dll fuzzer : $(LZ4DIR)/lz4.o $(LZ4DIR)/lz4hc.o $(LZ4DIR)/xxhash.o fuzzer.c $(CC) $(FLAGS) $^ -o $@$(EXT) diff --git a/visual/README.md b/visual/README.md index 4e76eb2..216971f 100644 --- a/visual/README.md +++ b/visual/README.md @@ -22,7 +22,7 @@ The following projects are included with the lz4 distribution: #### Projects available within lz4.sln The Visual Studio solution file `lz4.sln` contains many projects that will be compiled to the -`visual\VS2010\bin\$(Platform)_$(Configuration)\lz4.exe` directory. For example `lz4` set to `x64` and +`visual\VS2010\bin\$(Platform)_$(Configuration)` directory. For example `lz4` set to `x64` and `Release` will be compiled to `visual\VS2010\bin\x64_Release\lz4.exe`. The solution file contains the following projects: @@ -43,11 +43,11 @@ The header files `lib\lz4.h`, `lib\lz4hc.h`, `lib\lz4frame.h` and the import lib project using Visual C++. 1. The path to header files should be added to `Additional Include Directories` that can - be found in project properties `C/C++` then `General`. + be found in Project Properties of Visual Studio IDE in the `C/C++` Property Pages on the `General` page. 2. The import library has to be added to `Additional Dependencies` that can - be found in project properties `Linker` then `Input`. + be found in Project Properties in the `Linker` Property Pages on the `Input` page. If one will provide only the name `liblz4.lib` without a full path to the library - the directory has to be added to `Linker\General\Additional Library Directories`. + then the directory has to be added to `Linker\General\Additional Library Directories`. The compiled executable will require LZ4 DLL which is available at `visual\VS2010\bin\$(Platform)_$(Configuration)\liblz4.dll`. -- cgit v0.12 From 7b6a9d86383579099fd174000b857a5ea1671f0b Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Wed, 16 Nov 2016 09:01:45 +0100 Subject: Merge remote-tracking branch 'refs/remotes/lz4/dev' into dev --- README.md | 6 +++--- appveyor.yml | 18 +++++++++--------- lib/lz4.h | 2 +- lib/lz4frame.c | 37 ++++++++++++++++++------------------- programs/bench.c | 1 + programs/datagen.c | 29 ++++++++++------------------- programs/lz4.1 | 3 ++- programs/lz4cli.c | 22 ++++++++-------------- programs/lz4io.c | 12 ++++++------ programs/lz4io.h | 16 ++++++++++------ 10 files changed, 68 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index b0033f2..91661a9 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ LZ4 library is provided as open-source software using BSD 2-Clause license. [travisMasterBadge]: https://travis-ci.org/lz4/lz4.svg?branch=master "Continuous Integration test suite" [travisDevBadge]: https://travis-ci.org/lz4/lz4.svg?branch=dev "Continuous Integration test suite" [travisLink]: https://travis-ci.org/lz4/lz4 -[AppveyorMasterBadge]: https://ci.appveyor.com/api/projects/status/v6kxv9si529477cq/branch/master?svg=true "Visual test suite" -[AppveyorDevBadge]: https://ci.appveyor.com/api/projects/status/v6kxv9si529477cq/branch/dev?svg=true "Visual test suite" -[AppveyorLink]: https://ci.appveyor.com/project/YannCollet/lz4 +[AppveyorMasterBadge]: https://ci.appveyor.com/api/projects/status/jc2yhgwyc7qqtsko/branch/master?svg=true "Windows test suite" +[AppveyorDevBadge]: https://ci.appveyor.com/api/projects/status/jc2yhgwyc7qqtsko/branch/dev?svg=true "Windows test suite" +[AppveyorLink]: https://ci.appveyor.com/project/YannCollet/lz4-1lndh [coverBadge]: https://scan.coverity.com/projects/4735/badge.svg "Static code analysis of Master branch" [coverlink]: https://scan.coverity.com/projects/4735 diff --git a/appveyor.yml b/appveyor.yml index 37f3bd5..210f5d7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -34,9 +34,9 @@ install: ) build_script: - - if [%PLATFORM%]==[mingw32] SET PATH=%PATH_MINGW32%;%PATH_ORIGINAL% - - if [%PLATFORM%]==[mingw64] SET PATH=%PATH_MINGW64%;%PATH_ORIGINAL% - - if [%PLATFORM%]==[clang] SET PATH=%PATH_MINGW64%;%PATH_ORIGINAL% + - if [%PLATFORM%]==[mingw32] SET PATH=%PATH_MINGW32%;%PATH_ORIGINAL% + - if [%PLATFORM%]==[mingw64] SET PATH=%PATH_MINGW64%;%PATH_ORIGINAL% + - if [%PLATFORM%]==[clang] SET PATH=%PATH_MINGW64%;%PATH_ORIGINAL% - ECHO *** && ECHO Building %COMPILER% %PLATFORM% %CONFIGURATION% && ECHO *** @@ -108,11 +108,11 @@ test_script: - if not [%COMPILER%]==[unknown] ( CD programs && lz4 -h && - lz4 -i1b lz4.exe && + lz4 -i1b lz4.exe && lz4 -i1b5 lz4.exe && lz4 -i1b10 lz4.exe && lz4 -i1b15 lz4.exe && - echo ------- lz4 tested ------- && + echo ------- lz4 tested ------- && fullbench.exe -i1 fullbench.exe ) @@ -125,7 +125,7 @@ artifacts: deploy: - provider: GitHub auth_token: - secure: LgJo8emYc3sFnlNWkGl4/VYK3nk/8+RagcsqDlAi3xeqNGNutnKjcftjg84uJoT4 + secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId artifact: bin\lz4.exe force_update: true on: @@ -135,7 +135,7 @@ deploy: - provider: GitHub auth_token: - secure: LgJo8emYc3sFnlNWkGl4/VYK3nk/8+RagcsqDlAi3xeqNGNutnKjcftjg84uJoT4 + secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId artifact: bin\lz4_32.exe force_update: true on: @@ -145,7 +145,7 @@ deploy: - provider: GitHub auth_token: - secure: LgJo8emYc3sFnlNWkGl4/VYK3nk/8+RagcsqDlAi3xeqNGNutnKjcftjg84uJoT4 + secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId artifact: bin\liblz4_x64.zip force_update: true on: @@ -155,7 +155,7 @@ deploy: - provider: GitHub auth_token: - secure: LgJo8emYc3sFnlNWkGl4/VYK3nk/8+RagcsqDlAi3xeqNGNutnKjcftjg84uJoT4 + secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId artifact: bin\liblz4_x86.zip force_update: true on: diff --git a/lib/lz4.h b/lib/lz4.h index c1ea91a..babd78c 100644 --- a/lib/lz4.h +++ b/lib/lz4.h @@ -85,7 +85,7 @@ extern "C" { /*========== Version =========== */ #define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */ #define LZ4_VERSION_MINOR 7 /* for new (non-breaking) interface capabilities */ -#define LZ4_VERSION_RELEASE 2 /* for tweaks, bug-fixes, or development */ +#define LZ4_VERSION_RELEASE 3 /* for tweaks, bug-fixes, or development */ #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE) diff --git a/lib/lz4frame.c b/lib/lz4frame.c index c31f82d..c8e5bde 100644 --- a/lib/lz4frame.c +++ b/lib/lz4frame.c @@ -817,9 +817,8 @@ static size_t LZ4F_headerSize(const void* src, size_t srcSize) */ static size_t LZ4F_decodeHeader(LZ4F_dctx* dctxPtr, const void* src, size_t srcSize) { - BYTE FLG, BD, HC; + BYTE FLG, BD; unsigned version, blockMode, blockChecksumFlag, contentSizeFlag, contentChecksumFlag, blockSizeID; - size_t bufferNeeded; size_t frameHeaderSize; const BYTE* srcPtr = (const BYTE*)src; @@ -877,9 +876,9 @@ static size_t LZ4F_decodeHeader(LZ4F_dctx* dctxPtr, const void* src, size_t srcS if (blockSizeID < 4) return err0r(LZ4F_ERROR_maxBlockSize_invalid); /* 4-7 only supported values for the time being */ if (((BD>>0)&_4BITS) != 0) return err0r(LZ4F_ERROR_reservedFlag_set); /* Reserved bits */ - /* check */ - HC = LZ4F_headerChecksum(srcPtr+4, frameHeaderSize-5); - if (HC != srcPtr[frameHeaderSize-1]) return err0r(LZ4F_ERROR_headerChecksum_invalid); /* Bad header checksum error */ + /* check header */ + { BYTE const HC = LZ4F_headerChecksum(srcPtr+4, frameHeaderSize-5); + if (HC != srcPtr[frameHeaderSize-1]) return err0r(LZ4F_ERROR_headerChecksum_invalid); } /* save */ dctxPtr->frameInfo.blockMode = (LZ4F_blockMode_t)blockMode; @@ -892,17 +891,17 @@ static size_t LZ4F_decodeHeader(LZ4F_dctx* dctxPtr, const void* src, size_t srcS /* init */ if (contentChecksumFlag) XXH32_reset(&(dctxPtr->xxh), 0); - /* alloc */ - bufferNeeded = dctxPtr->maxBlockSize + ((dctxPtr->frameInfo.blockMode==LZ4F_blockLinked) * 128 KB); - if (bufferNeeded > dctxPtr->maxBufferSize) { /* tmp buffers too small */ - FREEMEM(dctxPtr->tmpIn); - FREEMEM(dctxPtr->tmpOutBuffer); - dctxPtr->maxBufferSize = bufferNeeded; - dctxPtr->tmpIn = (BYTE*)ALLOCATOR(dctxPtr->maxBlockSize); - if (dctxPtr->tmpIn == NULL) return err0r(LZ4F_ERROR_GENERIC); - dctxPtr->tmpOutBuffer= (BYTE*)ALLOCATOR(dctxPtr->maxBufferSize); - if (dctxPtr->tmpOutBuffer== NULL) return err0r(LZ4F_ERROR_GENERIC); - } + /* internal buffers allocation */ + { size_t const bufferNeeded = dctxPtr->maxBlockSize + ((dctxPtr->frameInfo.blockMode==LZ4F_blockLinked) * 128 KB); + if (bufferNeeded > dctxPtr->maxBufferSize) { /* tmp buffers too small */ + FREEMEM(dctxPtr->tmpIn); + dctxPtr->tmpIn = (BYTE*)ALLOCATOR(dctxPtr->maxBlockSize); + if (dctxPtr->tmpIn == NULL) return err0r(LZ4F_ERROR_allocation_failed); + dctxPtr->maxBufferSize = bufferNeeded; + FREEMEM(dctxPtr->tmpOutBuffer); + dctxPtr->tmpOutBuffer= (BYTE*)ALLOCATOR(bufferNeeded); + if (dctxPtr->tmpOutBuffer== NULL) return err0r(LZ4F_ERROR_allocation_failed); + } } dctxPtr->tmpInSize = 0; dctxPtr->tmpInTarget = 0; dctxPtr->dict = dctxPtr->tmpOutBuffer; @@ -981,9 +980,9 @@ static void LZ4F_updateDict(LZ4F_dctx* dctxPtr, const BYTE* dstPtr, size_t dstSi } if (withinTmp) { /* copy relevant dict portion in front of tmpOut within tmpOutBuffer */ - size_t preserveSize = dctxPtr->tmpOut - dctxPtr->tmpOutBuffer; + size_t const preserveSize = dctxPtr->tmpOut - dctxPtr->tmpOutBuffer; size_t copySize = 64 KB - dctxPtr->tmpOutSize; - const BYTE* oldDictEnd = dctxPtr->dict + dctxPtr->dictSize - dctxPtr->tmpOutStart; + const BYTE* const oldDictEnd = dctxPtr->dict + dctxPtr->dictSize - dctxPtr->tmpOutStart; if (dctxPtr->tmpOutSize > 64 KB) copySize = 0; if (copySize > preserveSize) copySize = preserveSize; @@ -996,7 +995,7 @@ static void LZ4F_updateDict(LZ4F_dctx* dctxPtr, const BYTE* dstPtr, size_t dstSi if (dctxPtr->dict == dctxPtr->tmpOutBuffer) { /* copy dst into tmp to complete dict */ if (dctxPtr->dictSize + dstSize > dctxPtr->maxBufferSize) { /* tmp buffer not large enough */ - size_t preserveSize = 64 KB - dstSize; /* note : dstSize < 64 KB */ + size_t const preserveSize = 64 KB - dstSize; /* note : dstSize < 64 KB */ memcpy(dctxPtr->tmpOutBuffer, dctxPtr->dict + dctxPtr->dictSize - preserveSize, preserveSize); dctxPtr->dictSize = preserveSize; } diff --git a/programs/bench.c b/programs/bench.c index cfd60db..434da8b 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -260,6 +260,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize, cSize = 0; { U32 blockNb; for (blockNb=0; blockNb%10u (%5.3f),%6.1f MB/s\r", diff --git a/programs/datagen.c b/programs/datagen.c index d851418..ed37c2a 100644 --- a/programs/datagen.c +++ b/programs/datagen.c @@ -81,10 +81,10 @@ typedef BYTE litDistribTable[LTSIZE]; - /********************************************************* * Local Functions *********************************************************/ +#define MIN(a,b) ( (a) < (b) ? (a) :(b) ) #define RDG_rotl32(x,r) ((x << r) | (x >> (32 - r))) static unsigned int RDG_rand(U32* src) { @@ -99,24 +99,15 @@ static unsigned int RDG_rand(U32* src) static void RDG_fillLiteralDistrib(litDistribTable lt, double ld) { - U32 i = 0; - BYTE character = '0'; - BYTE firstChar = '('; - BYTE lastChar = '}'; - - if (ld==0.0) - { - character = 0; - firstChar = 0; - lastChar =255; - } - while (i LTSIZE) weight = LTSIZE-i; - end = i + weight; - while (i < end) lt[i++] = character; + BYTE const firstChar = ld <= 0.0 ? 0 : '('; + BYTE const lastChar = ld <= 0.0 ? 255 : '}'; + BYTE character = ld <= 0.0 ? 0 : '0'; + U32 u = 0; + + while (u lastChar) character = firstChar; } diff --git a/programs/lz4.1 b/programs/lz4.1 index 434b131..2c94033 100644 --- a/programs/lz4.1 +++ b/programs/lz4.1 @@ -207,7 +207,8 @@ hence for a file. It won't work with unknown source size, such as stdin or pipe. sparse mode support (default:enabled on file, disabled on stdout) .TP .B \-l - use Legacy format (useful for Linux Kernel compression) + use Legacy format (typically used for Linux Kernel compression) + note : \fB-l\fR is not compatible with \fB-m\fR (\fB--multiple\fR) . .SS "Other options" .TP diff --git a/programs/lz4cli.c b/programs/lz4cli.c index 88fbb53..297ce6b 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -288,11 +288,11 @@ int main(int argc, const char** argv) const char* input_filename = NULL; const char* output_filename= NULL; char* dynNameSpace = NULL; - const char** inFileNames = NULL; + const char** inFileNames = (const char**) calloc(argc, sizeof(char*)); unsigned ifnIdx=0; const char nullOutput[] = NULL_OUTPUT; const char extension[] = LZ4_EXTENSION; - int blockSize = LZ4IO_setBlockSizeID(LZ4_BLOCKSIZEID_DEFAULT); + size_t blockSize = LZ4IO_setBlockSizeID(LZ4_BLOCKSIZEID_DEFAULT); const char* const exeName = argv[0]; #ifdef UTIL_HAS_CREATEFILELIST const char** extendedFileList = NULL; @@ -301,6 +301,10 @@ int main(int argc, const char** argv) #endif /* Init */ + if (inFileNames==NULL) { + DISPLAY("Allocation error : not enough memory \n"); + return 1; + } LZ4IO_setOverwrite(0); /* lz4cat predefined behavior */ @@ -311,8 +315,6 @@ int main(int argc, const char** argv) output_filename=stdoutmark; displayLevel=1; multiple_inputs=1; - inFileNames = (const char**) calloc(argc, sizeof(char*)); - if (inFileNames==NULL) { perror(exeName); exit(1); } } if (!strcmp(exeName, UNLZ4)) { mode = om_decompress; } @@ -336,7 +338,7 @@ int main(int argc, const char** argv) if (!strcmp(argument, "--compress")) { mode = om_compress; continue; } if ((!strcmp(argument, "--decompress")) || (!strcmp(argument, "--uncompress"))) { mode = om_decompress; continue; } - if (!strcmp(argument, "--multiple")) { multiple_inputs = 1; if (inFileNames==NULL) inFileNames = (const char**)malloc(argc * sizeof(char*)); continue; } + if (!strcmp(argument, "--multiple")) { multiple_inputs = 1; continue; } if (!strcmp(argument, "--test")) { mode = om_test; continue; } if (!strcmp(argument, "--force")) { LZ4IO_setOverwrite(1); continue; } if (!strcmp(argument, "--no-force")) { LZ4IO_setOverwrite(0); continue; } @@ -454,10 +456,6 @@ int main(int argc, const char** argv) /* Benchmark */ case 'b': mode = om_bench; multiple_inputs=1; - if (inFileNames == NULL) { - inFileNames = (const char**) calloc(argc, sizeof(char*)); - if (inFileNames==NULL) { perror(exeName); exit(1); } - } break; #ifdef UTIL_HAS_CREATEFILELIST @@ -466,10 +464,6 @@ int main(int argc, const char** argv) #endif /* Treat non-option args as input files. See https://code.google.com/p/lz4/issues/detail?id=151 */ case 'm': multiple_inputs=1; - if (inFileNames == NULL) { - inFileNames = (const char**) calloc(argc, sizeof(char*)); - if (inFileNames==NULL) { perror(exeName); exit(1); } - } break; /* Modify Nb Seconds (benchmark only) */ @@ -514,7 +508,7 @@ int main(int argc, const char** argv) } DISPLAYLEVEL(3, WELCOME_MESSAGE); - if ((mode == om_compress) || (mode == om_bench)) DISPLAYLEVEL(4, "Blocks size : %i KB\n", blockSize>>10); + if ((mode == om_compress) || (mode == om_bench)) DISPLAYLEVEL(4, "Blocks size : %i KB\n", (U32)(blockSize>>10)); if (multiple_inputs) { input_filename = inFileNames[0]; diff --git a/programs/lz4io.c b/programs/lz4io.c index 5a366a4..4d076a9 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -134,9 +134,6 @@ static int g_blockIndependence = 1; static int g_sparseFileSupport = 1; static int g_contentSizeFlag = 0; -static const int minBlockSizeID = 4; -static const int maxBlockSizeID = 7; - /************************************** * Exceptions @@ -183,10 +180,12 @@ int LZ4IO_setTestMode(int yes) } /* blockSizeID : valid values : 4-5-6-7 */ -int LZ4IO_setBlockSizeID(int bsid) +size_t LZ4IO_setBlockSizeID(unsigned bsid) { - static const int blockSizeTable[] = { 64 KB, 256 KB, 1 MB, 4 MB }; - if ((bsid < minBlockSizeID) || (bsid > maxBlockSizeID)) return -1; + static const size_t blockSizeTable[] = { 64 KB, 256 KB, 1 MB, 4 MB }; + static const unsigned minBlockSizeID = 4; + static const unsigned maxBlockSizeID = 7; + if ((bsid < minBlockSizeID) || (bsid > maxBlockSizeID)) return 0; g_blockSizeId = bsid; return blockSizeTable[g_blockSizeId-minBlockSizeID]; } @@ -777,6 +776,7 @@ static dRess_t LZ4IO_createDResources(void) ress.dstBuffer = malloc(ress.dstBufferSize); if (!ress.srcBuffer || !ress.dstBuffer) EXM_THROW(61, "Allocation error : not enough memory"); + ress.dstFile = NULL; return ress; } diff --git a/programs/lz4io.h b/programs/lz4io.h index 315c805..e1ab5f3 100644 --- a/programs/lz4io.h +++ b/programs/lz4io.h @@ -32,16 +32,20 @@ #ifndef LZ4IO_H_237902873 #define LZ4IO_H_237902873 +/*--- Dependency ---*/ +#include /* size_t */ + + /* ************************************************** */ /* Special input/output values */ /* ************************************************** */ #define NULL_OUTPUT "null" -static char const stdinmark[] = "stdin"; -static char const stdoutmark[] = "stdout"; +static const char stdinmark[] = "stdin"; +static const char stdoutmark[] = "stdout"; #ifdef _WIN32 -static char const nulmark[] = "nul"; +static const char nulmark[] = "nul"; #else -static char const nulmark[] = "/dev/null"; +static const char nulmark[] = "/dev/null"; #endif @@ -69,8 +73,8 @@ int LZ4IO_setOverwrite(int yes); int LZ4IO_setTestMode(int yes); /* blockSizeID : valid values : 4-5-6-7 - return : -1 if error, blockSize if OK */ -int LZ4IO_setBlockSizeID(int blockSizeID); + return : 0 if error, blockSize if OK */ +size_t LZ4IO_setBlockSizeID(unsigned blockSizeID); /* Default setting : independent blocks */ typedef enum { LZ4IO_blockLinked=0, LZ4IO_blockIndependent} LZ4IO_blockMode_t; -- cgit v0.12 From 873206e70e68efb75eae772ade3bce1d8e221c06 Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Wed, 16 Nov 2016 09:21:10 +0100 Subject: appveyor.yml: create only lz4_x64.zip and lz4_x86.zip --- appveyor.yml | 53 +++++++++++++++-------------------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 210f5d7..9643b71 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -66,19 +66,16 @@ build_script: COPY lib\dll\fullbench-dll\Makefile bin\ && COPY lib\dll\fullbench-dll\fullbench-dll.* bin\fullbench\ && COPY lib\dll\README.md bin\ && - COPY lib\liblz4.a bin\static\liblz4_static.lib + COPY lib\liblz4.a bin\static\liblz4_static.lib && + COPY programs\lz4.exe bin\lz4.exe ) - if [%COMPILER%]==[gcc] if [%PLATFORM%]==[mingw64] ( - 7z.exe a bin\liblz4_x64.zip .\bin\fullbench .\bin\dll .\bin\static .\bin\include .\bin\Makefile .\bin\README.md && - appveyor PushArtifact bin\liblz4_x64.zip && - COPY programs\lz4.exe bin\lz4.exe && - appveyor PushArtifact bin\lz4.exe + 7z.exe a bin\liblz4_x64.zip .\bin\lz4.exe .\bin\fullbench .\bin\dll .\bin\static .\bin\include .\bin\Makefile .\bin\README.md && + appveyor PushArtifact bin\lz4_x64.zip ) - if [%COMPILER%]==[gcc] if [%PLATFORM%]==[mingw32] ( - 7z.exe a bin\liblz4_x86.zip .\bin\fullbench .\bin\dll .\bin\static .\bin\include .\bin\Makefile .\bin\README.md && - appveyor PushArtifact bin\liblz4_x86.zip && - COPY programs\lz4.exe bin\lz4_32.exe && - appveyor PushArtifact bin\lz4_32.exe + 7z.exe a bin\liblz4_x86.zip .\bin\lz4.exe .\bin\fullbench .\bin\dll .\bin\static .\bin\include .\bin\Makefile .\bin\README.md && + appveyor PushArtifact bin\lz4_x86.zip ) - if [%COMPILER%]==[gcc] (COPY tests\fullbench.exe programs\) - if [%COMPILER%]==[visual] ( @@ -105,7 +102,7 @@ test_script: - ECHO *** && ECHO Testing %COMPILER% %PLATFORM% %CONFIGURATION% && ECHO *** - - if not [%COMPILER%]==[unknown] ( + - if [%COMPILER%]==[unknown] ( CD programs && lz4 -h && lz4 -i1b lz4.exe && @@ -117,48 +114,28 @@ test_script: ) artifacts: - - path: bin\lz4.exe - - path: bin\lz4_32.exe - - path: bin\liblz4_x64.zip - - path: bin\liblz4_x86.zip + - path: bin\lz4_x64.zip + - path: bin\lz4_x86.zip deploy: - provider: GitHub + artifact: bin\lz4_x64.zip + release: lz4_x64-v$(appveyor_build_version) auth_token: secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId - artifact: bin\lz4.exe force_update: true on: COMPILER: gcc PLATFORM: "mingw64" - appveyor_repo_tag: true + #appveyor_repo_tag: true - provider: GitHub + artifact: bin\lz4_x86.zip + release: lz4_x86-v$(appveyor_build_version) auth_token: secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId - artifact: bin\lz4_32.exe force_update: true on: COMPILER: gcc PLATFORM: "mingw32" - appveyor_repo_tag: true - -- provider: GitHub - auth_token: - secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId - artifact: bin\liblz4_x64.zip - force_update: true - on: - COMPILER: gcc - PLATFORM: "mingw64" - appveyor_repo_tag: true - -- provider: GitHub - auth_token: - secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId - artifact: bin\liblz4_x86.zip - force_update: true - on: - COMPILER: gcc - PLATFORM: "mingw32" - appveyor_repo_tag: true + #appveyor_repo_tag: true -- cgit v0.12 From 11f6217cc287d1b8d79b40361ed6b6ce6ef42172 Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Wed, 16 Nov 2016 09:32:26 +0100 Subject: created dll\example directory --- appveyor.yml | 20 +-- lib/dll/README.md | 53 -------- lib/dll/example/Makefile | 63 ++++++++++ lib/dll/example/README.md | 53 ++++++++ lib/dll/example/fullbench-dll.sln | 25 ++++ lib/dll/example/fullbench-dll.vcxproj | 182 ++++++++++++++++++++++++++++ lib/dll/fullbench-dll/Makefile | 61 ---------- lib/dll/fullbench-dll/fullbench-dll.sln | 25 ---- lib/dll/fullbench-dll/fullbench-dll.vcxproj | 182 ---------------------------- 9 files changed, 333 insertions(+), 331 deletions(-) delete mode 100644 lib/dll/README.md create mode 100644 lib/dll/example/Makefile create mode 100644 lib/dll/example/README.md create mode 100644 lib/dll/example/fullbench-dll.sln create mode 100644 lib/dll/example/fullbench-dll.vcxproj delete mode 100644 lib/dll/fullbench-dll/Makefile delete mode 100644 lib/dll/fullbench-dll/fullbench-dll.sln delete mode 100644 lib/dll/fullbench-dll/fullbench-dll.vcxproj diff --git a/appveyor.yml b/appveyor.yml index 9643b71..dd9a700 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -55,26 +55,26 @@ build_script: ) ) - if [%COMPILER%]==[gcc] if not [%PLATFORM%]==[clang] ( - MKDIR bin\dll bin\static bin\fullbench bin\include && - COPY tests\fullbench.c bin\fullbench\ && - COPY lib\xxhash.c bin\fullbench\ && - COPY lib\xxhash.h bin\fullbench\ && + MKDIR bin\dll bin\static bin\example bin\include && + COPY tests\fullbench.c bin\example\ && + COPY lib\xxhash.c bin\example\ && + COPY lib\xxhash.h bin\example\ && COPY lib\lz4.h bin\include\ && COPY lib\lz4hc.h bin\include\ && COPY lib\lz4frame.h bin\include\ && - COPY lib\dll\liblz4.* bin\dll\ && - COPY lib\dll\fullbench-dll\Makefile bin\ && - COPY lib\dll\fullbench-dll\fullbench-dll.* bin\fullbench\ && - COPY lib\dll\README.md bin\ && COPY lib\liblz4.a bin\static\liblz4_static.lib && + COPY lib\dll\liblz4.* bin\dll\ && + COPY lib\dll\example\Makefile bin\example\ && + COPY lib\dll\example\fullbench-dll.* bin\example\ && + COPY lib\dll\example\README.md bin\ && COPY programs\lz4.exe bin\lz4.exe ) - if [%COMPILER%]==[gcc] if [%PLATFORM%]==[mingw64] ( - 7z.exe a bin\liblz4_x64.zip .\bin\lz4.exe .\bin\fullbench .\bin\dll .\bin\static .\bin\include .\bin\Makefile .\bin\README.md && + 7z.exe a bin\lz4_x64.zip .\bin\lz4.exe .\bin\fullbench .\bin\dll .\bin\static .\bin\include .\bin\Makefile .\bin\README.md && appveyor PushArtifact bin\lz4_x64.zip ) - if [%COMPILER%]==[gcc] if [%PLATFORM%]==[mingw32] ( - 7z.exe a bin\liblz4_x86.zip .\bin\lz4.exe .\bin\fullbench .\bin\dll .\bin\static .\bin\include .\bin\Makefile .\bin\README.md && + 7z.exe a bin\lz4_x86.zip .\bin\lz4.exe .\bin\fullbench .\bin\dll .\bin\static .\bin\include .\bin\Makefile .\bin\README.md && appveyor PushArtifact bin\lz4_x86.zip ) - if [%COMPILER%]==[gcc] (COPY tests\fullbench.exe programs\) diff --git a/lib/dll/README.md b/lib/dll/README.md deleted file mode 100644 index bb3dbd6..0000000 --- a/lib/dll/README.md +++ /dev/null @@ -1,53 +0,0 @@ -The static and dynamic LZ4 libraries -==================================== - -#### The package contents - -- `dll\liblz4.dll` : The DLL of LZ4 library -- `dll\liblz4.lib` : The import library of LZ4 library for Visual C++ -- `fullbench\` : The example of usage of LZ4 library -- `include\` : Header files required with LZ4 library -- `static\liblz4_static.lib` : The static LZ4 library - - -#### The example of usage of static and dynamic LZ4 libraries with gcc/MinGW - -Use `make` to build `fullbench-dll` and `fullbench-lib`. -`fullbench-dll` uses a dynamic LZ4 library from the `dll` directory. -`fullbench-lib` uses a static LZ4 library from the `lib` directory. - - -#### Using LZ4 DLL with gcc/MinGW - -The header files from `include\` and the dynamic library `dll\liblz4.dll` -are required to compile a project using gcc/MinGW. -The dynamic library has to be added to linking options. -It means that if a project that uses LZ4 consists of a single `test-dll.c` -file it should be compiled with "liblz4.dll". For example: -``` - gcc $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\liblz4.dll -``` -The compiled executable will require LZ4 DLL which is available at `dll\liblz4.dll`. - - -#### The example of usage of static and dynamic LZ4 libraries with Visual C++ - -Open `fullbench\fullbench-dll.sln` to compile `fullbench-dll` that uses a -dynamic LZ4 library from the `dll` directory. The solution works with Visual C++ -2010 or newer. When one will open the solution with Visual C++ newer than 2010 -then the solution will upgraded to the current version. - - -#### Using LZ4 DLL with Visual C++ - -The header files from `include\` and the import library `dll\liblz4.lib` -are required to compile a project using Visual C++. - -1. The header files should be added to `Additional Include Directories` that can - be found in project properties `C/C++` then `General`. -2. The import library has to be added to `Additional Dependencies` that can - be found in project properties `Linker` then `Input`. - If one will provide only the name `liblz4.lib` without a full path to the library - the directory has to be added to `Linker\General\Additional Library Directories`. - -The compiled executable will require LZ4 DLL which is available at `dll\liblz4.dll`. diff --git a/lib/dll/example/Makefile b/lib/dll/example/Makefile new file mode 100644 index 0000000..e987956 --- /dev/null +++ b/lib/dll/example/Makefile @@ -0,0 +1,63 @@ +# ########################################################################## +# LZ4 programs - Makefile +# Copyright (C) Yann Collet 2016 +# +# 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 homepage : http://www.lz4.org +# - LZ4 source repository : https://github.com/lz4/lz4 +# ########################################################################## + +VOID := /dev/null +LZ4DIR := ../include +LIBDIR := ../static +DLLDIR := ../dll + +CFLAGS ?= -O3 # can select custom flags. For example : CFLAGS="-O2 -g" make +CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum \ + -Wdeclaration-after-statement -Wstrict-prototypes \ + -Wpointer-arith -Wstrict-aliasing=1 +CFLAGS += $(MOREFLAGS) +CPPFLAGS:= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_ +FLAGS := $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) + + +# Define *.exe as extension for Windows systems +ifneq (,$(filter Windows%,$(OS))) +EXT =.exe +else +EXT = +endif + +.PHONY: default fullbench-dll fullbench-lib + + +default: all + +all: fullbench-dll fullbench-lib + + +fullbench-lib: fullbench.c xxhash.c + $(CC) $(FLAGS) $^ -o $@$(EXT) $(LIBDIR)/liblz4_static.lib + +fullbench-dll: fullbench.c xxhash.c + $(CC) $(FLAGS) $^ -o $@$(EXT) -DLZ4_DLL_IMPORT=1 $(DLLDIR)/liblz4.dll + +clean: + @$(RM) fullbench-dll$(EXT) fullbench-lib$(EXT) \ + @echo Cleaning completed diff --git a/lib/dll/example/README.md b/lib/dll/example/README.md new file mode 100644 index 0000000..bb3dbd6 --- /dev/null +++ b/lib/dll/example/README.md @@ -0,0 +1,53 @@ +The static and dynamic LZ4 libraries +==================================== + +#### The package contents + +- `dll\liblz4.dll` : The DLL of LZ4 library +- `dll\liblz4.lib` : The import library of LZ4 library for Visual C++ +- `fullbench\` : The example of usage of LZ4 library +- `include\` : Header files required with LZ4 library +- `static\liblz4_static.lib` : The static LZ4 library + + +#### The example of usage of static and dynamic LZ4 libraries with gcc/MinGW + +Use `make` to build `fullbench-dll` and `fullbench-lib`. +`fullbench-dll` uses a dynamic LZ4 library from the `dll` directory. +`fullbench-lib` uses a static LZ4 library from the `lib` directory. + + +#### Using LZ4 DLL with gcc/MinGW + +The header files from `include\` and the dynamic library `dll\liblz4.dll` +are required to compile a project using gcc/MinGW. +The dynamic library has to be added to linking options. +It means that if a project that uses LZ4 consists of a single `test-dll.c` +file it should be compiled with "liblz4.dll". For example: +``` + gcc $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\liblz4.dll +``` +The compiled executable will require LZ4 DLL which is available at `dll\liblz4.dll`. + + +#### The example of usage of static and dynamic LZ4 libraries with Visual C++ + +Open `fullbench\fullbench-dll.sln` to compile `fullbench-dll` that uses a +dynamic LZ4 library from the `dll` directory. The solution works with Visual C++ +2010 or newer. When one will open the solution with Visual C++ newer than 2010 +then the solution will upgraded to the current version. + + +#### Using LZ4 DLL with Visual C++ + +The header files from `include\` and the import library `dll\liblz4.lib` +are required to compile a project using Visual C++. + +1. The header files should be added to `Additional Include Directories` that can + be found in project properties `C/C++` then `General`. +2. The import library has to be added to `Additional Dependencies` that can + be found in project properties `Linker` then `Input`. + If one will provide only the name `liblz4.lib` without a full path to the library + the directory has to be added to `Linker\General\Additional Library Directories`. + +The compiled executable will require LZ4 DLL which is available at `dll\liblz4.dll`. diff --git a/lib/dll/example/fullbench-dll.sln b/lib/dll/example/fullbench-dll.sln new file mode 100644 index 0000000..72e302e --- /dev/null +++ b/lib/dll/example/fullbench-dll.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2012 for Windows Desktop +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench-dll", "fullbench-dll.vcxproj", "{13992FD2-077E-4954-B065-A428198201A9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {13992FD2-077E-4954-B065-A428198201A9}.Debug|Win32.ActiveCfg = Debug|Win32 + {13992FD2-077E-4954-B065-A428198201A9}.Debug|Win32.Build.0 = Debug|Win32 + {13992FD2-077E-4954-B065-A428198201A9}.Debug|x64.ActiveCfg = Debug|x64 + {13992FD2-077E-4954-B065-A428198201A9}.Debug|x64.Build.0 = Debug|x64 + {13992FD2-077E-4954-B065-A428198201A9}.Release|Win32.ActiveCfg = Release|Win32 + {13992FD2-077E-4954-B065-A428198201A9}.Release|Win32.Build.0 = Release|Win32 + {13992FD2-077E-4954-B065-A428198201A9}.Release|x64.ActiveCfg = Release|x64 + {13992FD2-077E-4954-B065-A428198201A9}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/lib/dll/example/fullbench-dll.vcxproj b/lib/dll/example/fullbench-dll.vcxproj new file mode 100644 index 0000000..cdb5534 --- /dev/null +++ b/lib/dll/example/fullbench-dll.vcxproj @@ -0,0 +1,182 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {13992FD2-077E-4954-B065-A428198201A9} + Win32Proj + fullbench-dll + $(SolutionDir)bin\$(Platform)_$(Configuration)\ + $(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\ + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath); + + + true + $(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath); + true + + + false + $(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath); + + + false + $(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath); + true + + + + + + Level4 + Disabled + WIN32;_DEBUG;_CONSOLE;LZ4_DLL_IMPORT=1;%(PreprocessorDefinitions) + true + false + ..\include + + + Console + true + $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) + liblz4.lib;%(AdditionalDependencies) + false + + + + + + + Level4 + Disabled + WIN32;_DEBUG;_CONSOLE;LZ4_DLL_IMPORT=1;%(PreprocessorDefinitions) + true + true + /analyze:stacksize295252 %(AdditionalOptions) + ..\include + + + Console + true + $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) + liblz4.lib;%(AdditionalDependencies) + + + + + Level4 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;LZ4_DLL_IMPORT=1;%(PreprocessorDefinitions) + false + false + ..\include + + + Console + true + true + true + $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) + liblz4.lib;%(AdditionalDependencies) + false + + + + + Level4 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;LZ4_DLL_IMPORT=1;%(PreprocessorDefinitions) + false + true + /analyze:stacksize295252 %(AdditionalOptions) + ..\include + + + Console + true + true + true + $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) + liblz4.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/dll/fullbench-dll/Makefile b/lib/dll/fullbench-dll/Makefile deleted file mode 100644 index 680e1b6..0000000 --- a/lib/dll/fullbench-dll/Makefile +++ /dev/null @@ -1,61 +0,0 @@ -# ########################################################################## -# LZ4 programs - Makefile -# Copyright (C) Yann Collet 2016 -# -# 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 homepage : http://www.lz4.org -# - LZ4 source repository : https://github.com/lz4/lz4 -# ########################################################################## - -VOID := /dev/null -LZ4DIR := ./include - -CFLAGS ?= -O3 # can select custom flags. For example : CFLAGS="-O2 -g" make -CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum \ - -Wdeclaration-after-statement -Wstrict-prototypes \ - -Wpointer-arith -Wstrict-aliasing=1 -CFLAGS += $(MOREFLAGS) -CPPFLAGS:= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_ -FLAGS := $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) - - -# Define *.exe as extension for Windows systems -ifneq (,$(filter Windows%,$(OS))) -EXT =.exe -else -EXT = -endif - -.PHONY: default fullbench-dll fullbench-lib - - -default: all - -all: fullbench-dll fullbench-lib - - -fullbench-lib: fullbench/fullbench.c fullbench/xxhash.c - $(CC) $(FLAGS) $^ -o $@$(EXT) static/liblz4_static.lib - -fullbench-dll: fullbench/fullbench.c fullbench/xxhash.c - $(CC) $(FLAGS) $^ -o $@$(EXT) -DLZ4_DLL_IMPORT=1 dll/liblz4.dll - -clean: - @$(RM) fullbench-dll$(EXT) fullbench-lib$(EXT) \ - @echo Cleaning completed diff --git a/lib/dll/fullbench-dll/fullbench-dll.sln b/lib/dll/fullbench-dll/fullbench-dll.sln deleted file mode 100644 index 72e302e..0000000 --- a/lib/dll/fullbench-dll/fullbench-dll.sln +++ /dev/null @@ -1,25 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2012 for Windows Desktop -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench-dll", "fullbench-dll.vcxproj", "{13992FD2-077E-4954-B065-A428198201A9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {13992FD2-077E-4954-B065-A428198201A9}.Debug|Win32.ActiveCfg = Debug|Win32 - {13992FD2-077E-4954-B065-A428198201A9}.Debug|Win32.Build.0 = Debug|Win32 - {13992FD2-077E-4954-B065-A428198201A9}.Debug|x64.ActiveCfg = Debug|x64 - {13992FD2-077E-4954-B065-A428198201A9}.Debug|x64.Build.0 = Debug|x64 - {13992FD2-077E-4954-B065-A428198201A9}.Release|Win32.ActiveCfg = Release|Win32 - {13992FD2-077E-4954-B065-A428198201A9}.Release|Win32.Build.0 = Release|Win32 - {13992FD2-077E-4954-B065-A428198201A9}.Release|x64.ActiveCfg = Release|x64 - {13992FD2-077E-4954-B065-A428198201A9}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/lib/dll/fullbench-dll/fullbench-dll.vcxproj b/lib/dll/fullbench-dll/fullbench-dll.vcxproj deleted file mode 100644 index cdb5534..0000000 --- a/lib/dll/fullbench-dll/fullbench-dll.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {13992FD2-077E-4954-B065-A428198201A9} - Win32Proj - fullbench-dll - $(SolutionDir)bin\$(Platform)_$(Configuration)\ - $(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\ - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath); - - - true - $(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath); - true - - - false - $(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath); - - - false - $(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath); - true - - - - - - Level4 - Disabled - WIN32;_DEBUG;_CONSOLE;LZ4_DLL_IMPORT=1;%(PreprocessorDefinitions) - true - false - ..\include - - - Console - true - $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) - liblz4.lib;%(AdditionalDependencies) - false - - - - - - - Level4 - Disabled - WIN32;_DEBUG;_CONSOLE;LZ4_DLL_IMPORT=1;%(PreprocessorDefinitions) - true - true - /analyze:stacksize295252 %(AdditionalOptions) - ..\include - - - Console - true - $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) - liblz4.lib;%(AdditionalDependencies) - - - - - Level4 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;LZ4_DLL_IMPORT=1;%(PreprocessorDefinitions) - false - false - ..\include - - - Console - true - true - true - $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) - liblz4.lib;%(AdditionalDependencies) - false - - - - - Level4 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;LZ4_DLL_IMPORT=1;%(PreprocessorDefinitions) - false - true - /analyze:stacksize295252 %(AdditionalOptions) - ..\include - - - Console - true - true - true - $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) - liblz4.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - \ No newline at end of file -- cgit v0.12 From 8b48d5e446267418082b4d389fa6729e5a03a823 Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Wed, 16 Nov 2016 09:53:07 +0100 Subject: updated example\README.md --- appveyor.yml | 6 ++++-- lib/dll/example/README.md | 15 ++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index dd9a700..d1245c8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -70,11 +70,11 @@ build_script: COPY programs\lz4.exe bin\lz4.exe ) - if [%COMPILER%]==[gcc] if [%PLATFORM%]==[mingw64] ( - 7z.exe a bin\lz4_x64.zip .\bin\lz4.exe .\bin\fullbench .\bin\dll .\bin\static .\bin\include .\bin\Makefile .\bin\README.md && + 7z.exe a bin\lz4_x64.zip .\bin\lz4.exe .\bin\README.md .\bin\example .\bin\dll .\bin\static .\bin\include && appveyor PushArtifact bin\lz4_x64.zip ) - if [%COMPILER%]==[gcc] if [%PLATFORM%]==[mingw32] ( - 7z.exe a bin\lz4_x86.zip .\bin\lz4.exe .\bin\fullbench .\bin\dll .\bin\static .\bin\include .\bin\Makefile .\bin\README.md && + 7z.exe a bin\lz4_x86.zip .\bin\lz4.exe .\bin\README.md .\bin\example .\bin\dll .\bin\static .\bin\include && appveyor PushArtifact bin\lz4_x86.zip ) - if [%COMPILER%]==[gcc] (COPY tests\fullbench.exe programs\) @@ -124,6 +124,7 @@ deploy: auth_token: secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId force_update: true + prerelease: true on: COMPILER: gcc PLATFORM: "mingw64" @@ -135,6 +136,7 @@ deploy: auth_token: secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId force_update: true + prerelease: true on: COMPILER: gcc PLATFORM: "mingw32" diff --git a/lib/dll/example/README.md b/lib/dll/example/README.md index bb3dbd6..6f2b402 100644 --- a/lib/dll/example/README.md +++ b/lib/dll/example/README.md @@ -3,16 +3,17 @@ The static and dynamic LZ4 libraries #### The package contents -- `dll\liblz4.dll` : The DLL of LZ4 library -- `dll\liblz4.lib` : The import library of LZ4 library for Visual C++ -- `fullbench\` : The example of usage of LZ4 library -- `include\` : Header files required with LZ4 library +- `lz4.exe` : Command Line Utility, supporting gzip-like arguments +- `dll\liblz4.dll` : The DLL of LZ4 library +- `dll\liblz4.lib` : The import library of LZ4 library for Visual C++ +- `example\` : The example of usage of LZ4 library +- `include\` : Header files required with LZ4 library - `static\liblz4_static.lib` : The static LZ4 library #### The example of usage of static and dynamic LZ4 libraries with gcc/MinGW -Use `make` to build `fullbench-dll` and `fullbench-lib`. +Use `cd example` and `make` to build `fullbench-dll` and `fullbench-lib`. `fullbench-dll` uses a dynamic LZ4 library from the `dll` directory. `fullbench-lib` uses a static LZ4 library from the `lib` directory. @@ -25,14 +26,14 @@ The dynamic library has to be added to linking options. It means that if a project that uses LZ4 consists of a single `test-dll.c` file it should be compiled with "liblz4.dll". For example: ``` - gcc $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\liblz4.dll + gcc $(CFLAGS) -Iinclude\ test-dll.c -o test-dll dll\liblz4.dll ``` The compiled executable will require LZ4 DLL which is available at `dll\liblz4.dll`. #### The example of usage of static and dynamic LZ4 libraries with Visual C++ -Open `fullbench\fullbench-dll.sln` to compile `fullbench-dll` that uses a +Open `example\fullbench-dll.sln` to compile `fullbench-dll` that uses a dynamic LZ4 library from the `dll` directory. The solution works with Visual C++ 2010 or newer. When one will open the solution with Visual C++ newer than 2010 then the solution will upgraded to the current version. -- cgit v0.12 From 632ab3b8d411b8da88ea8963992d2b8d2db5a7e9 Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Wed, 16 Nov 2016 10:53:06 +0100 Subject: updated programs\README.md --- appveyor.yml | 8 +++----- lib/dll/example/README.md | 13 +++++++++++++ programs/README.md | 15 +++++++++------ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d1245c8..2885e30 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -102,7 +102,7 @@ test_script: - ECHO *** && ECHO Testing %COMPILER% %PLATFORM% %CONFIGURATION% && ECHO *** - - if [%COMPILER%]==[unknown] ( + - if not [%COMPILER%]==[unknown] ( CD programs && lz4 -h && lz4 -i1b lz4.exe && @@ -120,7 +120,6 @@ artifacts: deploy: - provider: GitHub artifact: bin\lz4_x64.zip - release: lz4_x64-v$(appveyor_build_version) auth_token: secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId force_update: true @@ -128,11 +127,10 @@ deploy: on: COMPILER: gcc PLATFORM: "mingw64" - #appveyor_repo_tag: true + appveyor_repo_tag: true - provider: GitHub artifact: bin\lz4_x86.zip - release: lz4_x86-v$(appveyor_build_version) auth_token: secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId force_update: true @@ -140,4 +138,4 @@ deploy: on: COMPILER: gcc PLATFORM: "mingw32" - #appveyor_repo_tag: true + appveyor_repo_tag: true diff --git a/lib/dll/example/README.md b/lib/dll/example/README.md index 6f2b402..216c1e9 100644 --- a/lib/dll/example/README.md +++ b/lib/dll/example/README.md @@ -11,6 +11,19 @@ The static and dynamic LZ4 libraries - `static\liblz4_static.lib` : The static LZ4 library +#### Usage of Command Line Interface + +Command Line Interface (CLI) supports gzip-like arguments. +By default CLI takes an input file and compresses it to an output file: +``` +Usage: lz4 [arg] [input] [output] +``` +The full list of commands for CLI can be obtained with `-h` or `-H`. +The ratio can be improved with commands from `-3` to `-16` but higher levels also have slower compression. +CLI supports aggregation of parameters i.e. `-b1`, `-e18`, and `-i1` can be joined into `-b1e18i1`. +CLI includes in-memory compression benchmark module with compression levels starting from `-b` and ending with `-e` with iteration time of `-i` seconds. + + #### The example of usage of static and dynamic LZ4 libraries with gcc/MinGW Use `cd example` and `make` to build `fullbench-dll` and `fullbench-lib`. diff --git a/programs/README.md b/programs/README.md index b67408f..2ad0449 100644 --- a/programs/README.md +++ b/programs/README.md @@ -21,7 +21,7 @@ It makes benchmark more precise as it eliminates I/O overhead. The benchmark measures ratio, compressed size, compression and decompression speed. One can select compression levels starting from `-b` and ending with `-e`. -The `-i` parameter selects a number of iterations used for each of tested levels. +The `-i` parameter selects a number of seconds used for each of tested levels. @@ -39,6 +39,7 @@ Arguments : -d : decompression (default for .lz4 extension) -z : force compression -f : overwrite output without prompting +--rm : remove source file(s) after successful de/compression -h/-H : display help/long help and exit Advanced arguments : @@ -48,18 +49,20 @@ Advanced arguments : -c : force write to standard output, even if it is the console -t : test compressed file integrity -m : multiple input files (implies automatic output filenames) + -r : operate recursively on directories (sets also -m) -l : compress using Legacy format (Linux kernel compression) - -B# : Block size [4-7](default : 7) + -B# : Block size [4-7] (default : 7) -BD : Block dependency (improve compression ratio) --no-frame-crc : disable stream checksum (default:enabled) --content-size : compressed frame includes original size (default:not present) --[no-]sparse : sparse mode (default:enabled on file, disabled on stdout) Benchmark arguments : -Benchmark arguments : -b# : benchmark file(s), using # compression level (default : 1) - -e# : test all compression levels from -bX to # (default: 1) - -i# : iteration loops [1-9](default : 3), benchmark mode only - ``` + -e# : test all compression levels from -bX to # (default : 1) + -i# : minimum evaluation time in seconds (default : 3s) + -B# : cut file into independent blocks of size # bytes [32+] + or predefined block size [4-7] (default: 7) +``` #### License -- cgit v0.12 From 2dee7bdaf6710f15d7128273014f3d42d0b7afaa Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Wed, 16 Nov 2016 11:06:28 +0100 Subject: include NEWS in lz4_x64.zip and lz4_x86.zip --- appveyor.yml | 4 ++-- lib/dll/example/README.md | 24 +++++++++++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2885e30..93c1101 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -70,11 +70,11 @@ build_script: COPY programs\lz4.exe bin\lz4.exe ) - if [%COMPILER%]==[gcc] if [%PLATFORM%]==[mingw64] ( - 7z.exe a bin\lz4_x64.zip .\bin\lz4.exe .\bin\README.md .\bin\example .\bin\dll .\bin\static .\bin\include && + 7z.exe a bin\lz4_x64.zip NEWS .\bin\lz4.exe .\bin\README.md .\bin\example .\bin\dll .\bin\static .\bin\include && appveyor PushArtifact bin\lz4_x64.zip ) - if [%COMPILER%]==[gcc] if [%PLATFORM%]==[mingw32] ( - 7z.exe a bin\lz4_x86.zip .\bin\lz4.exe .\bin\README.md .\bin\example .\bin\dll .\bin\static .\bin\include && + 7z.exe a bin\lz4_x86.zip NEWS .\bin\lz4.exe .\bin\README.md .\bin\example .\bin\dll .\bin\static .\bin\include && appveyor PushArtifact bin\lz4_x86.zip ) - if [%COMPILER%]==[gcc] (COPY tests\fullbench.exe programs\) diff --git a/lib/dll/example/README.md b/lib/dll/example/README.md index 216c1e9..4908663 100644 --- a/lib/dll/example/README.md +++ b/lib/dll/example/README.md @@ -1,13 +1,13 @@ -The static and dynamic LZ4 libraries +LZ4 Windows binary package ==================================== #### The package contents -- `lz4.exe` : Command Line Utility, supporting gzip-like arguments -- `dll\liblz4.dll` : The DLL of LZ4 library -- `dll\liblz4.lib` : The import library of LZ4 library for Visual C++ -- `example\` : The example of usage of LZ4 library -- `include\` : Header files required with LZ4 library +- `lz4.exe` : Command Line Utility, supporting gzip-like arguments +- `dll\liblz4.dll` : The DLL of LZ4 library +- `dll\liblz4.lib` : The import library of LZ4 library for Visual C++ +- `example\` : The example of usage of LZ4 library +- `include\` : Header files required with LZ4 library - `static\liblz4_static.lib` : The static LZ4 library @@ -16,12 +16,14 @@ The static and dynamic LZ4 libraries Command Line Interface (CLI) supports gzip-like arguments. By default CLI takes an input file and compresses it to an output file: ``` -Usage: lz4 [arg] [input] [output] + Usage: lz4 [arg] [input] [output] ``` -The full list of commands for CLI can be obtained with `-h` or `-H`. -The ratio can be improved with commands from `-3` to `-16` but higher levels also have slower compression. -CLI supports aggregation of parameters i.e. `-b1`, `-e18`, and `-i1` can be joined into `-b1e18i1`. -CLI includes in-memory compression benchmark module with compression levels starting from `-b` and ending with `-e` with iteration time of `-i` seconds. +The full list of commands for CLI can be obtained with `-h` or `-H`. The ratio can +be improved with commands from `-3` to `-16` but higher levels also have slower +compression. CLI includes in-memory compression benchmark module with compression +levels starting from `-b` and ending with `-e` with iteration time of `-i` seconds. +CLI supports aggregation of parameters i.e. `-b1`, `-e18`, and `-i1` can be joined +into `-b1e18i1`. #### The example of usage of static and dynamic LZ4 libraries with gcc/MinGW -- cgit v0.12