From c8a78dba1fc21f64dec72cf217c21fe8784c42bf Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 5 Sep 2016 06:49:55 -0700 Subject: datagen depends on lz4.h for version string --- programs/datagencli.c | 7 ++----- programs/frametest.c | 15 ++++++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/programs/datagencli.c b/programs/datagencli.c index 7b2b140..2fbcc50 100644 --- a/programs/datagencli.c +++ b/programs/datagencli.c @@ -29,6 +29,7 @@ **************************************/ #include /* fprintf, stderr */ #include "datagen.h" /* RDG_generate */ +#include "lz4.h" /* LZ4_VERSION_STRING */ /************************************** @@ -53,10 +54,6 @@ /************************************** * Constants **************************************/ -#ifndef LZ4_VERSION -# define LZ4_VERSION "r1" -#endif - #define KB *(1 <<10) #define MB *(1 <<20) #define GB *(1U<<30) @@ -182,7 +179,7 @@ int main(int argc, char** argv) } } - DISPLAYLEVEL(4, "Data Generator %s \n", LZ4_VERSION); + DISPLAYLEVEL(4, "Data Generator %s \n", LZ4_VERSION_STRING); DISPLAYLEVEL(3, "Seed = %u \n", seed); if (proba!=COMPRESSIBILITY_DEFAULT) DISPLAYLEVEL(3, "Compressibility : %i%%\n", (U32)(proba*100)); diff --git a/programs/frametest.c b/programs/frametest.c index d9f2566..e8f6975 100644 --- a/programs/frametest.c +++ b/programs/frametest.c @@ -591,7 +591,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi size_t srcStart = FUZ_rand(&randState) % (srcDataLength - srcSize); U64 frameContentSize = ((FUZ_rand(&randState) & 0xF) == 1) ? srcSize : 0; size_t cSize; - U64 crcOrig, crcDecoded; + U64 crcOrig; LZ4F_preferences_t* prefsPtr = &prefs; (void)FUZ_rand(&coreRand); /* update seed */ @@ -654,24 +654,29 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi { const BYTE* ip = (const BYTE*)compressedBuffer; const BYTE* const iend = ip + cSize; + DISPLAY("cSize : %u ; srcSize : %u \n", (U32)cSize, (U32)srcDataLength); BYTE* op = (BYTE*)decodedBuffer; BYTE* const oend = op + srcDataLength; size_t totalOut = 0; unsigned maxBits = FUZ_highbit((U32)cSize); - unsigned nonContiguousDst = (FUZ_rand(&randState) & 3) == 1; + unsigned nonContiguousDst = (FUZ_rand(&randState) & 3) == 1; /* 0 : contiguous; 1 : non-contiguous; 2 : dst overwritten */ nonContiguousDst += FUZ_rand(&randState) & nonContiguousDst; /* 0=>0; 1=>1,2 */ XXH64_reset(&xxh64, 1); if (maxBits < 3) maxBits = 3; while (ip < iend) { - unsigned nbBitsI = (FUZ_rand(&randState) % (maxBits-1)) + 1; - unsigned nbBitsO = (FUZ_rand(&randState) % (maxBits)) + 1; + unsigned const nbBitsI = (FUZ_rand(&randState) % (maxBits-1)) + 1; + unsigned const nbBitsO = (FUZ_rand(&randState) % (maxBits)) + 1; size_t iSize = (FUZ_rand(&randState) & ((1< (size_t)(iend-ip)) iSize = iend-ip; if (oSize > (size_t)(oend-op)) oSize = oend-op; dOptions.stableDst = FUZ_rand(&randState) & 1; if (nonContiguousDst==2) dOptions.stableDst = 0; + DISPLAY("in : %u / %u ; out : %u / %u \n", (U32)iSize, (U32)(iend-ip), (U32)oSize, (U32)(oend-op)); + if (iSize == 107662) + iSize += !iSize; result = LZ4F_decompress(dCtx, op, &oSize, ip, &iSize, &dOptions); + DISPLAY("consumed : %u ; generated : %u ; hint : %u \n", (U32)iSize, (U32)oSize, (U32)result); if (result == (size_t)-LZ4F_ERROR_contentChecksum_invalid) locateBuffDiff((BYTE*)srcBuffer+srcStart, decodedBuffer, srcSize, nonContiguousDst); CHECK(LZ4F_isError(result), "Decompression failed (error %i:%s)", (int)result, LZ4F_getErrorName((LZ4F_errorCode_t)result)); @@ -684,7 +689,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi } CHECK(result != 0, "Frame decompression failed (error %i)", (int)result); if (totalOut) { /* otherwise, it's a skippable frame */ - crcDecoded = XXH64_digest(&xxh64); + U64 const crcDecoded = XXH64_digest(&xxh64); if (crcDecoded != crcOrig) locateBuffDiff((BYTE*)srcBuffer+srcStart, decodedBuffer, srcSize, nonContiguousDst); CHECK(crcDecoded != crcOrig, "Decompression corruption"); } -- cgit v0.12 From 33993542af61ebaa87db3a0adbfe3661c0a5d313 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 6 Sep 2016 16:46:52 +0200 Subject: removed test artefacts --- lib/lz4.c | 5 ++--- lib/lz4frame.c | 2 +- programs/frametest.c | 5 ----- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/lz4.c b/lib/lz4.c index f485970..08128bb 100644 --- a/lib/lz4.c +++ b/lib/lz4.c @@ -1103,7 +1103,7 @@ FORCE_INLINE int LZ4_decompress_generic( int partialDecoding, /* full, partial */ int targetOutputSize, /* only used if partialDecoding==partial */ int dict, /* noDict, withPrefix64k, usingExtDict */ - const BYTE* const lowPrefix, /* == dest if dict == noDict */ + const BYTE* const lowPrefix, /* == dest when no prefix */ const BYTE* const dictStart, /* only if dict==usingExtDict */ const size_t dictSize /* note : = 0 if noDict */ ) @@ -1385,8 +1385,7 @@ FORCE_INLINE int LZ4_decompress_usingDict_generic(const char* source, char* dest { if (dictSize==0) return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, noDict, (BYTE*)dest, NULL, 0); - if (dictStart+dictSize == dest) - { + if (dictStart+dictSize == dest) { if (dictSize >= (int)(64 KB - 1)) return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, withPrefix64k, (BYTE*)dest-64 KB, NULL, 0); return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, noDict, (BYTE*)dest-dictSize, NULL, 0); diff --git a/lib/lz4frame.c b/lib/lz4frame.c index 1dc2bca..4cf259f 100644 --- a/lib/lz4frame.c +++ b/lib/lz4frame.c @@ -1184,7 +1184,7 @@ size_t LZ4F_decompress(LZ4F_decompressionContext_t decompressionContext, } selectedIn = dctxPtr->tmpIn; dctxPtr->dStage = dstage_decodeCBlock; - break; + /* pass-through */ } case dstage_decodeCBlock: diff --git a/programs/frametest.c b/programs/frametest.c index e8f6975..4322ab8 100644 --- a/programs/frametest.c +++ b/programs/frametest.c @@ -654,7 +654,6 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi { const BYTE* ip = (const BYTE*)compressedBuffer; const BYTE* const iend = ip + cSize; - DISPLAY("cSize : %u ; srcSize : %u \n", (U32)cSize, (U32)srcDataLength); BYTE* op = (BYTE*)decodedBuffer; BYTE* const oend = op + srcDataLength; size_t totalOut = 0; @@ -672,11 +671,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi if (oSize > (size_t)(oend-op)) oSize = oend-op; dOptions.stableDst = FUZ_rand(&randState) & 1; if (nonContiguousDst==2) dOptions.stableDst = 0; - DISPLAY("in : %u / %u ; out : %u / %u \n", (U32)iSize, (U32)(iend-ip), (U32)oSize, (U32)(oend-op)); - if (iSize == 107662) - iSize += !iSize; result = LZ4F_decompress(dCtx, op, &oSize, ip, &iSize, &dOptions); - DISPLAY("consumed : %u ; generated : %u ; hint : %u \n", (U32)iSize, (U32)oSize, (U32)result); if (result == (size_t)-LZ4F_ERROR_contentChecksum_invalid) locateBuffDiff((BYTE*)srcBuffer+srcStart, decodedBuffer, srcSize, nonContiguousDst); CHECK(LZ4F_isError(result), "Decompression failed (error %i:%s)", (int)result, LZ4F_getErrorName((LZ4F_errorCode_t)result)); -- cgit v0.12 From 3b9439ccd043fe5704af6528f3b3155cf6f8f0c4 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Sat, 17 Sep 2016 11:59:13 +0200 Subject: updated uninstall --- lib/Makefile | 18 +++++++++--------- programs/Makefile | 34 +++++++++++++++++----------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 141da01..b5352a0 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -81,7 +81,7 @@ liblz4: *.c @ln -sf $@.$(SHARED_EXT_VER) $@.$(SHARED_EXT) clean: - @rm -f core *.o *.a *.$(SHARED_EXT) *.$(SHARED_EXT).* liblz4.pc + @$(RM) -f core *.o *.a *.$(SHARED_EXT) *.$(SHARED_EXT).* liblz4.pc @echo Cleaning library completed @@ -111,14 +111,14 @@ install: liblz4 liblz4.pc @echo lz4 static and shared libraries installed uninstall: - @rm -f $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT) - @rm -f $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR) - @rm -f $(DESTDIR)$(LIBDIR)/pkgconfig/liblz4.pc - @[ -x $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_VER) ] && rm -f $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_VER) - @[ -f $(DESTDIR)$(LIBDIR)/liblz4.a ] && rm -f $(DESTDIR)$(LIBDIR)/liblz4.a - @[ -f $(DESTDIR)$(INCLUDEDIR)/lz4.h ] && rm -f $(DESTDIR)$(INCLUDEDIR)/lz4.h - @[ -f $(DESTDIR)$(INCLUDEDIR)/lz4hc.h ] && rm -f $(DESTDIR)$(INCLUDEDIR)/lz4hc.h - @[ -f $(DESTDIR)$(INCLUDEDIR)/lz4frame.h ] && rm -f $(DESTDIR)$(INCLUDEDIR)/lz4frame.h + @$(RM) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT) + @$(RM) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR) + @$(RM) $(DESTDIR)$(LIBDIR)/pkgconfig/liblz4.pc + @$(RM) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_VER) + @$(RM) $(DESTDIR)$(LIBDIR)/liblz4.a + @$(RM) $(DESTDIR)$(INCLUDEDIR)/lz4.h + @$(RM) $(DESTDIR)$(INCLUDEDIR)/lz4hc.h + @$(RM) $(DESTDIR)$(INCLUDEDIR)/lz4frame.h @echo lz4 libraries successfully uninstalled endif diff --git a/programs/Makefile b/programs/Makefile index 290361f..6ed7af0 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -102,7 +102,7 @@ datagen : datagen.o datagencli.c clean: @$(MAKE) -C $(LZ4DIR) $@ > $(VOID) - @rm -f core *.o *.test tmp* \ + @$(RM) core *.o *.test tmp* \ lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) \ fullbench$(EXT) fullbench32$(EXT) \ fuzzer$(EXT) fuzzer32$(EXT) \ @@ -131,14 +131,14 @@ install: lz4$(EXT) lz4c$(EXT) @echo lz4 installation completed uninstall: - rm -f $(DESTDIR)$(BINDIR)/lz4cat$(EXT) - rm -f $(DESTDIR)$(BINDIR)/unlz4$(EXT) - [ -x $(DESTDIR)$(BINDIR)/lz4$(EXT) ] && rm -f $(DESTDIR)$(BINDIR)/lz4$(EXT) - [ -x $(DESTDIR)$(BINDIR)/lz4c$(EXT) ] && rm -f $(DESTDIR)$(BINDIR)/lz4c$(EXT) - [ -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 + @$(RM) $(DESTDIR)$(BINDIR)/lz4cat$(EXT) + @$(RM) $(DESTDIR)$(BINDIR)/unlz4$(EXT) + @$(RM) $(DESTDIR)$(BINDIR)/lz4$(EXT) + @$(RM) $(DESTDIR)$(BINDIR)/lz4c$(EXT) + @$(RM) $(DESTDIR)$(MANDIR)/lz4.1 + @$(RM) $(DESTDIR)$(MANDIR)/lz4c.1 + @$(RM) $(DESTDIR)$(MANDIR)/lz4cat.1 + @$(RM) $(DESTDIR)$(MANDIR)/unlz4.1 @echo lz4 programs successfully uninstalled test: test-lz4 test-lz4c test-frametest test-fullbench test-fuzzer test-mem @@ -164,7 +164,7 @@ test-lz4-sparse: lz4 datagen ./datagen -s1 -g1200007 -P100 | ./lz4 | ./lz4 -dv --sparse > tmpOdd # Odd size file (to generate non-full last block) ./datagen -s1 -g1200007 -P100 | diff -s - tmpOdd ls -ls tmpOdd - @rm tmp* + @$(RM) tmp* @echo "\n Compatibility with Console :" echo "Hello World 1 !" | ./lz4 | ./lz4 -d -c echo "Hello World 2 !" | ./lz4 | ./lz4 -d | cat @@ -177,7 +177,7 @@ test-lz4-sparse: lz4 datagen ./lz4 -d -v tmpC >> tmpR ls -ls tmp* diff tmp2M tmpR - @rm tmp* + @$(RM) tmp* test-lz4-contentSize: lz4 datagen @echo "\n ---- test original size support ----" @@ -190,7 +190,7 @@ test-lz4-contentSize: lz4 datagen @ls -ls tmp ./lz4 --quiet --content-size tmp | ./lz4 --verbose --decompress --force --sparse - tmp2 @ls -ls tmp2 - @rm tmp* + @$(RM) tmp* test-lz4-frame-concatenation: lz4 datagen @echo "\n ---- test frame concatenation ----" @@ -202,7 +202,7 @@ test-lz4-frame-concatenation: lz4 datagen 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 + @$(RM) *.test @echo frame concatenation test completed test-lz4-multiple: lz4 datagen @@ -212,11 +212,11 @@ test-lz4-multiple: lz4 datagen @./datagen -s3 -g1M > tmp3 2> $(VOID) ./lz4 -f -m tmp* ls -ls tmp* - rm tmp1 tmp2 tmp3 + @$(RM) tmp1 tmp2 tmp3 ./lz4 -df -m *.lz4 ls -ls tmp* ./lz4 -f -m tmp1 notHere tmp2; echo $$? - @rm tmp* + @$(RM) tmp* test-lz4-basic: lz4 datagen @echo "\n ---- test lz4 basic compression/decompression ----" @@ -234,7 +234,7 @@ test-lz4-basic: lz4 datagen ./datagen -g256MB | ./lz4 -vqB4D | ./lz4 -t ./datagen -g6GB | ./lz4 -vqB5D | ./lz4 -qt ./datagen -g6GB | ./lz4 -vq9BD | ./lz4 -qt - @rm tmp* + @$(RM) tmp* test-lz4: lz4 datagen test-lz4-basic test-lz4-multiple test-lz4-sparse test-lz4-contentSize test-lz4-frame-concatenation @echo "\n ---- test pass-through ----" @@ -296,7 +296,7 @@ test-mem: lz4 datagen fuzzer frametest fullbench valgrind --leak-check=yes --error-exitcode=1 ./fullbench -i1 tmp tmp2 ./datagen -g256MB > tmp valgrind --leak-check=yes --error-exitcode=1 ./lz4 -B4D -f -vq tmp $(VOID) - rm tmp* + $(RM) tmp* valgrind --leak-check=yes --error-exitcode=1 ./fuzzer -i64 -t1 valgrind --leak-check=yes --error-exitcode=1 ./frametest -i256 -- cgit v0.12 From 46a7b94e8cf4c56eafcddeca09c63df368bfa4cb Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Fri, 23 Sep 2016 00:34:42 +0900 Subject: Use lower case for header file name "WinIoCtl.h" works on Windows because Windows uses case insensitive file system. But it doesn't work on GNU/Linux (for cross compiling with MinGW) because GNU/Linux uses case sensitive file system. --- programs/lz4io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/lz4io.c b/programs/lz4io.c index 1e9a2f5..f8eadf0 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -70,7 +70,7 @@ # if !defined(__DJGPP__) # define SET_BINARY_MODE(file) { int unused=_setmode(_fileno(file), _O_BINARY); (void)unused; } # include /* DeviceIoControl, HANDLE, FSCTL_SET_SPARSE */ -# include /* FSCTL_SET_SPARSE */ +# include /* FSCTL_SET_SPARSE */ # define SET_SPARSE_FILE_MODE(file) { DWORD dw; DeviceIoControl((HANDLE) _get_osfhandle(_fileno(file)), FSCTL_SET_SPARSE, 0, 0, 0, 0, &dw, 0); } # if defined(_MSC_VER) && (_MSC_VER >= 1400) /* Avoid MSVC fseek()'s 2GiB barrier */ # define fseek _fseeki64 -- cgit v0.12 From 012c66536cdb93d9bcfa565fadaaf2a281c489b9 Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Fri, 23 Sep 2016 00:21:04 +0900 Subject: Add LZ4LIB_API It's based on Zstandard's ZSTDLIB_API. See also: https://github.com/Cyan4973/lz4/issues/216#issuecomment-226245432 Deprecated functions aren't LZ4LIB_API targets. Because we don't need to export deprecated functions from now. There are same LZ4LIB_API definitions in each header files instead of including a common header file because LZ4_DEPRECATED is defined so. --- lib/Makefile | 2 +- lib/lz4.h | 77 +++++++++++++++++++------------ lib/lz4frame.h | 56 ++++++++++++++-------- lib/lz4hc.h | 47 +++++++++++++------ programs/Makefile | 2 +- visual/VS2010/datagen/datagen.vcxproj | 10 ++-- visual/VS2010/frametest/frametest.vcxproj | 10 ++-- visual/VS2010/fullbench/fullbench.vcxproj | 10 ++-- visual/VS2010/fuzzer/fuzzer.vcxproj | 10 ++-- visual/VS2010/liblz4/liblz4.vcxproj | 8 ++-- visual/VS2010/lz4/lz4.vcxproj | 10 ++-- 11 files changed, 146 insertions(+), 96 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index b5352a0..a653b65 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -43,7 +43,7 @@ LIBVER := $(shell echo $(LIBVER_SCRIPT)) DESTDIR?= PREFIX ?= /usr/local -CPPFLAGS= -DXXH_NAMESPACE=LZ4_ +CPPFLAGS= -DXXH_NAMESPACE=LZ4_ -DLZ4_DLL_EXPORT=1 CFLAGS ?= -O3 CFLAGS += -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wcast-qual -Wstrict-prototypes FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) diff --git a/lib/lz4.h b/lib/lz4.h index ba6d70b..dfe6f2a 100644 --- a/lib/lz4.h +++ b/lib/lz4.h @@ -48,6 +48,23 @@ extern "C" { * A library is provided to take care of it, see lz4frame.h. */ +/*-*************************************************************** +* Export parameters +*****************************************************************/ +/*! +* LZ4_DLL_EXPORT : +* Enable exporting of functions when building a Windows DLL +*/ +#if defined(_WIN32) +# if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) +# define LZ4LIB_API __declspec(dllexport) +# else +# define LZ4LIB_API __declspec(dllimport) +# endif +#else +# define LZ4LIB_API +#endif + /*-************************************ * Version **************************************/ @@ -56,13 +73,13 @@ extern "C" { #define LZ4_VERSION_RELEASE 2 /* for tweaks, bug-fixes, or development */ #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE) -int LZ4_versionNumber (void); +LZ4LIB_API int LZ4_versionNumber (void); #define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE #define LZ4_QUOTE(str) #str #define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str) #define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION) -const char* LZ4_versionString (void); +LZ4LIB_API const char* LZ4_versionString (void); /*-************************************ @@ -82,8 +99,8 @@ const char* LZ4_versionString (void); * Simple Functions **************************************/ -int LZ4_compress_default(const char* source, char* dest, int sourceSize, int maxDestSize); -int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize); +LZ4LIB_API int LZ4_compress_default(const char* source, char* dest, int sourceSize, int maxDestSize); +LZ4LIB_API int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize); /* LZ4_compress_default() : @@ -127,7 +144,7 @@ LZ4_compressBound() : return : maximum output size in a "worst case" scenario or 0, if input size is too large ( > LZ4_MAX_INPUT_SIZE) */ -int LZ4_compressBound(int inputSize); +LZ4LIB_API int LZ4_compressBound(int inputSize); /*! LZ4_compress_fast() : @@ -137,7 +154,7 @@ LZ4_compress_fast() : An acceleration value of "1" is the same as regular LZ4_compress_default() Values <= 0 will be replaced by ACCELERATION_DEFAULT (see lz4.c), which is 1. */ -int LZ4_compress_fast (const char* source, char* dest, int sourceSize, int maxDestSize, int acceleration); +LZ4LIB_API int LZ4_compress_fast (const char* source, char* dest, int sourceSize, int maxDestSize, int acceleration); /*! @@ -147,8 +164,8 @@ LZ4_compress_fast_extState() : and allocate it on 8-bytes boundaries (using malloc() typically). Then, provide it as 'void* state' to compression function. */ -int LZ4_sizeofState(void); -int LZ4_compress_fast_extState (void* state, const char* source, char* dest, int inputSize, int maxDestSize, int acceleration); +LZ4LIB_API int LZ4_sizeofState(void); +LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* source, char* dest, int inputSize, int maxDestSize, int acceleration); /*! @@ -162,7 +179,7 @@ LZ4_compress_destSize() : return : Nb bytes written into 'dest' (necessarily <= targetDestSize) or 0 if compression fails */ -int LZ4_compress_destSize (const char* source, char* dest, int* sourceSizePtr, int targetDestSize); +LZ4LIB_API int LZ4_compress_destSize (const char* source, char* dest, int* sourceSizePtr, int targetDestSize); /*! @@ -176,7 +193,7 @@ LZ4_decompress_fast() : However, it does not provide any protection against intentionally modified data stream (malicious input). Use this function in trusted environment only (data to decode comes from a trusted source). */ -int LZ4_decompress_fast (const char* source, char* dest, int originalSize); +LZ4LIB_API int LZ4_decompress_fast (const char* source, char* dest, int originalSize); /*! LZ4_decompress_safe_partial() : @@ -190,7 +207,7 @@ LZ4_decompress_safe_partial() : If the source stream is detected malformed, the function will stop decoding and return a negative result. This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets */ -int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize); +LZ4LIB_API int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize); /*-********************************************* @@ -210,15 +227,15 @@ typedef struct { long long table[LZ4_STREAMSIZE_U64]; } LZ4_stream_t; /*! LZ4_resetStream() : * Use this function to init an allocated `LZ4_stream_t` structure */ -void LZ4_resetStream (LZ4_stream_t* streamPtr); +LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr); /*! LZ4_createStream() will allocate and initialize an `LZ4_stream_t` structure. * LZ4_freeStream() releases its memory. * In the context of a DLL (liblz4), please use these methods rather than the static struct. * They are more future proof, in case of a change of `LZ4_stream_t` size. */ -LZ4_stream_t* LZ4_createStream(void); -int LZ4_freeStream (LZ4_stream_t* streamPtr); +LZ4LIB_API LZ4_stream_t* LZ4_createStream(void); +LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr); /*! LZ4_loadDict() : * Use this function to load a static dictionary into LZ4_stream. @@ -226,7 +243,7 @@ int LZ4_freeStream (LZ4_stream_t* streamPtr); * Loading a size of 0 is allowed. * Return : dictionary size, in bytes (necessarily <= 64 KB) */ -int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize); +LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize); /*! LZ4_compress_fast_continue() : * Compress buffer content 'src', using data from previously compressed blocks as dictionary to improve compression ratio. @@ -235,7 +252,7 @@ int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize) * If maxDstSize >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster. * If not, and if compressed data cannot fit into 'dst' buffer size, compression stops, and function returns a zero. */ -int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int maxDstSize, int acceleration); +LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int maxDstSize, int acceleration); /*! LZ4_saveDict() : * If previously compressed data block is not guaranteed to remain available at its memory location, @@ -244,7 +261,7 @@ int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* * dictionary is immediately usable, you can therefore call LZ4_compress_fast_continue(). * Return : saved dictionary size in bytes (necessarily <= dictSize), or 0 if error. */ -int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int dictSize); +LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int dictSize); /*-********************************************** @@ -264,15 +281,15 @@ typedef struct { unsigned long long table[LZ4_STREAMDECODESIZE_U64]; } LZ4_strea * LZ4_createStreamDecode will allocate and initialize an LZ4_streamDecode_t structure * LZ4_freeStreamDecode releases its memory. */ -LZ4_streamDecode_t* LZ4_createStreamDecode(void); -int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream); +LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void); +LZ4LIB_API int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream); /*! LZ4_setStreamDecode() : * Use this function to instruct where to find the dictionary. * Setting a size of 0 is allowed (same effect as reset). * @return : 1 if OK, 0 if error */ -int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize); +LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize); /* *_continue() : @@ -291,8 +308,8 @@ int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dicti Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer, and indicate where it is saved using LZ4_setStreamDecode() */ -int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxDecompressedSize); -int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize); +LZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxDecompressedSize); +LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize); /* @@ -302,8 +319,8 @@ Advanced decoding functions : a combination of LZ4_setStreamDecode() followed by LZ4_decompress_x_continue() They are stand-alone. They don't need nor update an LZ4_streamDecode_t structure. */ -int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxDecompressedSize, const char* dictStart, int dictSize); -int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize); +LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxDecompressedSize, const char* dictStart, int dictSize); +LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize); /*=************************************ @@ -333,12 +350,12 @@ int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalS /* Obsolete compression functions */ /* These functions will generate warnings in a future release */ -int LZ4_compress (const char* source, char* dest, int sourceSize); -int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize); -int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize); -int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); -int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize); -int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize); +LZ4LIB_API int LZ4_compress (const char* source, char* dest, int sourceSize); +LZ4LIB_API int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize); +LZ4LIB_API int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize); +LZ4LIB_API int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); +LZ4LIB_API int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize); +LZ4LIB_API int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize); /* Obsolete decompression functions */ /* These function names are completely deprecated and must no longer be used. diff --git a/lib/lz4frame.h b/lib/lz4frame.h index 6a1f987..d1cfa0c 100644 --- a/lib/lz4frame.h +++ b/lib/lz4frame.h @@ -49,14 +49,30 @@ extern "C" { **************************************/ #include /* size_t */ +/*-*************************************************************** +* Export parameters +*****************************************************************/ +/*! +* LZ4_DLL_EXPORT : +* Enable exporting of functions when building a Windows DLL +*/ +#if defined(_WIN32) +# if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) +# define LZ4LIB_API __declspec(dllexport) +# else +# define LZ4LIB_API __declspec(dllimport) +# endif +#else +# define LZ4LIB_API +#endif /*-************************************ * Error management **************************************/ typedef size_t LZ4F_errorCode_t; -unsigned LZ4F_isError(LZ4F_errorCode_t code); -const char* LZ4F_getErrorName(LZ4F_errorCode_t code); /* return error code string; useful for debugging */ +LZ4LIB_API unsigned LZ4F_isError(LZ4F_errorCode_t code); +LZ4LIB_API const char* LZ4F_getErrorName(LZ4F_errorCode_t code); /* return error code string; useful for debugging */ /*-************************************ @@ -128,7 +144,7 @@ typedef struct { /*-********************************* * Simple compression function ***********************************/ -size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr); +LZ4LIB_API size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr); /*!LZ4F_compressFrame() : * Compress an entire srcBuffer into a valid LZ4 frame, as defined by specification v1.5.1 @@ -139,7 +155,7 @@ size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* prefere * The result of the function is the number of bytes written into dstBuffer. * The function outputs an error code if it fails (can be tested using LZ4F_isError()) */ -size_t LZ4F_compressFrame(void* dstBuffer, size_t dstMaxSize, const void* srcBuffer, size_t srcSize, const LZ4F_preferences_t* preferencesPtr); +LZ4LIB_API size_t LZ4F_compressFrame(void* dstBuffer, size_t dstMaxSize, const void* srcBuffer, size_t srcSize, const LZ4F_preferences_t* preferencesPtr); @@ -156,8 +172,8 @@ typedef struct { /* Resource Management */ #define LZ4F_VERSION 100 -LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_compressionContext_t* cctxPtr, unsigned version); -LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_compressionContext_t cctx); +LZ4LIB_API LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_compressionContext_t* cctxPtr, unsigned version); +LZ4LIB_API LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_compressionContext_t cctx); /* LZ4F_createCompressionContext() : * The first thing to do is to create a compressionContext object, which will be used in all compression operations. * This is achieved using LZ4F_createCompressionContext(), which takes as argument a version and an LZ4F_preferences_t structure. @@ -170,7 +186,7 @@ LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_compressionContext_t cctx); /* Compression */ -size_t LZ4F_compressBegin(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const LZ4F_preferences_t* prefsPtr); +LZ4LIB_API size_t LZ4F_compressBegin(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const LZ4F_preferences_t* prefsPtr); /* LZ4F_compressBegin() : * will write the frame header into dstBuffer. * dstBuffer must be large enough to accommodate a header (dstMaxSize). Maximum header size is 15 bytes. @@ -179,7 +195,7 @@ size_t LZ4F_compressBegin(LZ4F_compressionContext_t cctx, void* dstBuffer, size_ * or an error code (can be tested using LZ4F_isError()) */ -size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* prefsPtr); +LZ4LIB_API size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* prefsPtr); /* LZ4F_compressBound() : * Provides the minimum size of Dst buffer given srcSize to handle worst case situations. * Different preferences can produce different results. @@ -187,7 +203,7 @@ size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* prefsPtr); * This function includes frame termination cost (4 bytes, or 8 if frame checksum is enabled) */ -size_t LZ4F_compressUpdate(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const void* srcBuffer, size_t srcSize, const LZ4F_compressOptions_t* cOptPtr); +LZ4LIB_API size_t LZ4F_compressUpdate(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const void* srcBuffer, size_t srcSize, const LZ4F_compressOptions_t* cOptPtr); /* LZ4F_compressUpdate() * LZ4F_compressUpdate() can be called repetitively to compress as much data as necessary. * The most important rule is that dstBuffer MUST be large enough (dstMaxSize) to ensure compression completion even in worst case. @@ -199,7 +215,7 @@ size_t LZ4F_compressUpdate(LZ4F_compressionContext_t cctx, void* dstBuffer, size * The function outputs an error code if it fails (can be tested using LZ4F_isError()) */ -size_t LZ4F_flush(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const LZ4F_compressOptions_t* cOptPtr); +LZ4LIB_API size_t LZ4F_flush(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const LZ4F_compressOptions_t* cOptPtr); /* LZ4F_flush() * Should you need to generate compressed data immediately, without waiting for the current block to be filled, * you can call LZ4_flush(), which will immediately compress any remaining data buffered within cctx. @@ -210,7 +226,7 @@ size_t LZ4F_flush(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMax * The function outputs an error code if it fails (can be tested using LZ4F_isError()) */ -size_t LZ4F_compressEnd(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const LZ4F_compressOptions_t* cOptPtr); +LZ4LIB_API size_t LZ4F_compressEnd(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const LZ4F_compressOptions_t* cOptPtr); /* LZ4F_compressEnd() * When you want to properly finish the compressed frame, just call LZ4F_compressEnd(). * It will flush whatever data remained within compressionContext (like LZ4_flush()) @@ -245,8 +261,8 @@ typedef struct { * The result of LZ4F_freeDecompressionContext() is indicative of the current state of decompressionContext when being released. * That is, it should be == 0 if decompression has been completed fully and correctly. */ -LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_decompressionContext_t* dctxPtr, unsigned version); -LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_decompressionContext_t dctx); +LZ4LIB_API LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_decompressionContext_t* dctxPtr, unsigned version); +LZ4LIB_API LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_decompressionContext_t dctx); /*====== Decompression ======*/ @@ -263,9 +279,9 @@ LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_decompressionContext_t dctx) * (typically, when there is not enough src bytes to fully decode the frame header) * Decompression is expected to resume from where it stopped (srcBuffer + *srcSizePtr) */ -size_t LZ4F_getFrameInfo(LZ4F_decompressionContext_t dctx, - LZ4F_frameInfo_t* frameInfoPtr, - const void* srcBuffer, size_t* srcSizePtr); +LZ4LIB_API size_t LZ4F_getFrameInfo(LZ4F_decompressionContext_t dctx, + LZ4F_frameInfo_t* frameInfoPtr, + const void* srcBuffer, size_t* srcSizePtr); /*!LZ4F_decompress() : * Call this function repetitively to regenerate data compressed within srcBuffer. @@ -291,10 +307,10 @@ size_t LZ4F_getFrameInfo(LZ4F_decompressionContext_t dctx, * * After a frame is fully decoded, dctx can be used again to decompress another frame. */ -size_t LZ4F_decompress(LZ4F_decompressionContext_t dctx, - void* dstBuffer, size_t* dstSizePtr, - const void* srcBuffer, size_t* srcSizePtr, - const LZ4F_decompressOptions_t* dOptPtr); +LZ4LIB_API size_t LZ4F_decompress(LZ4F_decompressionContext_t dctx, + void* dstBuffer, size_t* dstSizePtr, + const void* srcBuffer, size_t* srcSizePtr, + const LZ4F_decompressOptions_t* dOptPtr); diff --git a/lib/lz4hc.h b/lib/lz4hc.h index 75eed19..9ce9e4d 100644 --- a/lib/lz4hc.h +++ b/lib/lz4hc.h @@ -44,6 +44,23 @@ extern "C" { *****************************/ #include /* size_t */ +/*-*************************************************************** +* Export parameters +*****************************************************************/ +/*! +* LZ4_DLL_EXPORT : +* Enable exporting of functions when building a Windows DLL +*/ +#if defined(_WIN32) +# if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) +# define LZ4LIB_API __declspec(dllexport) +# else +# define LZ4LIB_API __declspec(dllimport) +# endif +#else +# define LZ4LIB_API +#endif + #define LZ4HC_MIN_CLEVEL 3 #define LZ4HC_DEFAULT_CLEVEL 9 @@ -64,7 +81,7 @@ LZ4_compress_HC() : @return : the number of bytes written into buffer 'dst' or 0 if compression fails. */ -int LZ4_compress_HC (const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); +LZ4LIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); /* Note : @@ -84,8 +101,8 @@ LZ4_compress_HC_extStateHC() : LZ4_compress_HC_extStateHC() is equivalent to previously described function. It just uses externally allocated memory for stateHC. */ -int LZ4_compress_HC_extStateHC(void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); -int LZ4_sizeofStateHC(void); +LZ4LIB_API int LZ4_compress_HC_extStateHC(void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); +LZ4LIB_API int LZ4_sizeofStateHC(void); /*-************************************ @@ -111,15 +128,15 @@ typedef struct { size_t table[LZ4_STREAMHCSIZE_SIZET]; } LZ4_streamHC_t; If you use LZ4 as a DLL, use these functions instead of static structure allocation, to avoid size mismatch between different versions. */ -LZ4_streamHC_t* LZ4_createStreamHC(void); -int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr); +LZ4LIB_API LZ4_streamHC_t* LZ4_createStreamHC(void); +LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr); -void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel); -int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize); +LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel); +LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize); -int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize); +LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize); -int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize); +LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize); /* These functions compress data in successive blocks of any size, using previous blocks as dictionary. @@ -168,16 +185,16 @@ int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSi /* deprecated compression functions */ /* these functions will trigger warning messages in future releases */ -int LZ4_compressHC (const char* source, char* dest, int inputSize); -int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize); +LZ4LIB_API int LZ4_compressHC (const char* source, char* dest, int inputSize); +LZ4LIB_API int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize); LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel); LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); -int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize); -int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); +LZ4LIB_API int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize); +LZ4LIB_API int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel); LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); -int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize); -int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize); +LZ4LIB_API int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize); +LZ4LIB_API int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize); /* Deprecated Streaming functions using older model; should no longer be used */ LZ4_DEPRECATED("use LZ4_createStreamHC() instead") void* LZ4_createHC (char* inputBuffer); diff --git a/programs/Makefile b/programs/Makefile index 6ed7af0..6214084 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -43,7 +43,7 @@ LZ4DIR := ../lib 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 CFLAGS += $(MOREFLAGS) -CPPFLAGS:= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_ +CPPFLAGS:= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_ -DLZ4_DLL_EXPORT=1 FLAGS := $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) diff --git a/visual/VS2010/datagen/datagen.vcxproj b/visual/VS2010/datagen/datagen.vcxproj index c51c5d3..74aabba 100644 --- a/visual/VS2010/datagen/datagen.vcxproj +++ b/visual/VS2010/datagen/datagen.vcxproj @@ -87,7 +87,7 @@ Level4 Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true false @@ -102,7 +102,7 @@ Level4 Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true true /analyze:stacksize295252 %(AdditionalOptions) @@ -120,7 +120,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true false @@ -139,7 +139,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true true /analyze:stacksize295252 %(AdditionalOptions) @@ -161,4 +161,4 @@ - \ No newline at end of file + diff --git a/visual/VS2010/frametest/frametest.vcxproj b/visual/VS2010/frametest/frametest.vcxproj index 7654396..b44a3e6 100644 --- a/visual/VS2010/frametest/frametest.vcxproj +++ b/visual/VS2010/frametest/frametest.vcxproj @@ -87,7 +87,7 @@ Level4 Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true false @@ -102,7 +102,7 @@ Level4 Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true true /analyze:stacksize295252 %(AdditionalOptions) @@ -120,7 +120,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true false @@ -139,7 +139,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true true /analyze:stacksize295252 %(AdditionalOptions) @@ -168,4 +168,4 @@ - \ No newline at end of file + diff --git a/visual/VS2010/fullbench/fullbench.vcxproj b/visual/VS2010/fullbench/fullbench.vcxproj index 28d0f90..84b22c6 100644 --- a/visual/VS2010/fullbench/fullbench.vcxproj +++ b/visual/VS2010/fullbench/fullbench.vcxproj @@ -87,7 +87,7 @@ Level4 Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true false @@ -102,7 +102,7 @@ Level4 Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true true /analyze:stacksize295252 %(AdditionalOptions) @@ -120,7 +120,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true false @@ -139,7 +139,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true true /analyze:stacksize295252 %(AdditionalOptions) @@ -168,4 +168,4 @@ - \ No newline at end of file + diff --git a/visual/VS2010/fuzzer/fuzzer.vcxproj b/visual/VS2010/fuzzer/fuzzer.vcxproj index 9c8f225..9b36c8a 100644 --- a/visual/VS2010/fuzzer/fuzzer.vcxproj +++ b/visual/VS2010/fuzzer/fuzzer.vcxproj @@ -87,7 +87,7 @@ Level4 Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true false @@ -102,7 +102,7 @@ Level4 Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true true /analyze:stacksize295252 %(AdditionalOptions) @@ -120,7 +120,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true false @@ -139,7 +139,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true true /analyze:stacksize295252 %(AdditionalOptions) @@ -165,4 +165,4 @@ - \ No newline at end of file + diff --git a/visual/VS2010/liblz4/liblz4.vcxproj b/visual/VS2010/liblz4/liblz4.vcxproj index 41435fe..cbc2173 100644 --- a/visual/VS2010/liblz4/liblz4.vcxproj +++ b/visual/VS2010/liblz4/liblz4.vcxproj @@ -87,7 +87,7 @@ Level4 Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) + WIN32;_DEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true false @@ -101,7 +101,7 @@ Level4 Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) + WIN32;_DEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true true /analyze:stacksize295252 %(AdditionalOptions) @@ -118,7 +118,7 @@ MaxSpeed true true - WIN32;NDEBUG;%(PreprocessorDefinitions) + WIN32;NDEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true false @@ -136,7 +136,7 @@ MaxSpeed true true - WIN32;NDEBUG;%(PreprocessorDefinitions) + WIN32;NDEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true true /analyze:stacksize295252 %(AdditionalOptions) diff --git a/visual/VS2010/lz4/lz4.vcxproj b/visual/VS2010/lz4/lz4.vcxproj index 4fc2770..7513d8c 100644 --- a/visual/VS2010/lz4/lz4.vcxproj +++ b/visual/VS2010/lz4/lz4.vcxproj @@ -87,7 +87,7 @@ Level4 Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true false @@ -102,7 +102,7 @@ Level4 Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true true /analyze:stacksize295252 %(AdditionalOptions) @@ -120,7 +120,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true false @@ -139,7 +139,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions) true true /analyze:stacksize295252 %(AdditionalOptions) @@ -172,4 +172,4 @@ - \ No newline at end of file + -- cgit v0.12 From 59771f41cdcb6be2a8fcb8a256b2511684baf956 Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Fri, 23 Sep 2016 10:38:33 +0900 Subject: Use different prefix for each file to avoid conflict --- lib/lz4frame.h | 46 +++++++++++++++++++++++----------------------- lib/lz4hc.h | 36 ++++++++++++++++++------------------ 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/lz4frame.h b/lib/lz4frame.h index d1cfa0c..a70d0e0 100644 --- a/lib/lz4frame.h +++ b/lib/lz4frame.h @@ -58,12 +58,12 @@ extern "C" { */ #if defined(_WIN32) # if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) -# define LZ4LIB_API __declspec(dllexport) +# define LZ4FLIB_API __declspec(dllexport) # else -# define LZ4LIB_API __declspec(dllimport) +# define LZ4FLIB_API __declspec(dllimport) # endif #else -# define LZ4LIB_API +# define LZ4FLIB_API #endif /*-************************************ @@ -71,8 +71,8 @@ extern "C" { **************************************/ typedef size_t LZ4F_errorCode_t; -LZ4LIB_API unsigned LZ4F_isError(LZ4F_errorCode_t code); -LZ4LIB_API const char* LZ4F_getErrorName(LZ4F_errorCode_t code); /* return error code string; useful for debugging */ +LZ4FLIB_API unsigned LZ4F_isError(LZ4F_errorCode_t code); +LZ4FLIB_API const char* LZ4F_getErrorName(LZ4F_errorCode_t code); /* return error code string; useful for debugging */ /*-************************************ @@ -144,7 +144,7 @@ typedef struct { /*-********************************* * Simple compression function ***********************************/ -LZ4LIB_API size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr); +LZ4FLIB_API size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr); /*!LZ4F_compressFrame() : * Compress an entire srcBuffer into a valid LZ4 frame, as defined by specification v1.5.1 @@ -155,7 +155,7 @@ LZ4LIB_API size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences * The result of the function is the number of bytes written into dstBuffer. * The function outputs an error code if it fails (can be tested using LZ4F_isError()) */ -LZ4LIB_API size_t LZ4F_compressFrame(void* dstBuffer, size_t dstMaxSize, const void* srcBuffer, size_t srcSize, const LZ4F_preferences_t* preferencesPtr); +LZ4FLIB_API size_t LZ4F_compressFrame(void* dstBuffer, size_t dstMaxSize, const void* srcBuffer, size_t srcSize, const LZ4F_preferences_t* preferencesPtr); @@ -172,8 +172,8 @@ typedef struct { /* Resource Management */ #define LZ4F_VERSION 100 -LZ4LIB_API LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_compressionContext_t* cctxPtr, unsigned version); -LZ4LIB_API LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_compressionContext_t cctx); +LZ4FLIB_API LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_compressionContext_t* cctxPtr, unsigned version); +LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_compressionContext_t cctx); /* LZ4F_createCompressionContext() : * The first thing to do is to create a compressionContext object, which will be used in all compression operations. * This is achieved using LZ4F_createCompressionContext(), which takes as argument a version and an LZ4F_preferences_t structure. @@ -186,7 +186,7 @@ LZ4LIB_API LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_compressionContext_ /* Compression */ -LZ4LIB_API size_t LZ4F_compressBegin(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const LZ4F_preferences_t* prefsPtr); +LZ4FLIB_API size_t LZ4F_compressBegin(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const LZ4F_preferences_t* prefsPtr); /* LZ4F_compressBegin() : * will write the frame header into dstBuffer. * dstBuffer must be large enough to accommodate a header (dstMaxSize). Maximum header size is 15 bytes. @@ -195,7 +195,7 @@ LZ4LIB_API size_t LZ4F_compressBegin(LZ4F_compressionContext_t cctx, void* dstBu * or an error code (can be tested using LZ4F_isError()) */ -LZ4LIB_API size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* prefsPtr); +LZ4FLIB_API size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* prefsPtr); /* LZ4F_compressBound() : * Provides the minimum size of Dst buffer given srcSize to handle worst case situations. * Different preferences can produce different results. @@ -203,7 +203,7 @@ LZ4LIB_API size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* p * This function includes frame termination cost (4 bytes, or 8 if frame checksum is enabled) */ -LZ4LIB_API size_t LZ4F_compressUpdate(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const void* srcBuffer, size_t srcSize, const LZ4F_compressOptions_t* cOptPtr); +LZ4FLIB_API size_t LZ4F_compressUpdate(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const void* srcBuffer, size_t srcSize, const LZ4F_compressOptions_t* cOptPtr); /* LZ4F_compressUpdate() * LZ4F_compressUpdate() can be called repetitively to compress as much data as necessary. * The most important rule is that dstBuffer MUST be large enough (dstMaxSize) to ensure compression completion even in worst case. @@ -215,7 +215,7 @@ LZ4LIB_API size_t LZ4F_compressUpdate(LZ4F_compressionContext_t cctx, void* dstB * The function outputs an error code if it fails (can be tested using LZ4F_isError()) */ -LZ4LIB_API size_t LZ4F_flush(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const LZ4F_compressOptions_t* cOptPtr); +LZ4FLIB_API size_t LZ4F_flush(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const LZ4F_compressOptions_t* cOptPtr); /* LZ4F_flush() * Should you need to generate compressed data immediately, without waiting for the current block to be filled, * you can call LZ4_flush(), which will immediately compress any remaining data buffered within cctx. @@ -226,7 +226,7 @@ LZ4LIB_API size_t LZ4F_flush(LZ4F_compressionContext_t cctx, void* dstBuffer, si * The function outputs an error code if it fails (can be tested using LZ4F_isError()) */ -LZ4LIB_API size_t LZ4F_compressEnd(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const LZ4F_compressOptions_t* cOptPtr); +LZ4FLIB_API size_t LZ4F_compressEnd(LZ4F_compressionContext_t cctx, void* dstBuffer, size_t dstMaxSize, const LZ4F_compressOptions_t* cOptPtr); /* LZ4F_compressEnd() * When you want to properly finish the compressed frame, just call LZ4F_compressEnd(). * It will flush whatever data remained within compressionContext (like LZ4_flush()) @@ -261,8 +261,8 @@ typedef struct { * The result of LZ4F_freeDecompressionContext() is indicative of the current state of decompressionContext when being released. * That is, it should be == 0 if decompression has been completed fully and correctly. */ -LZ4LIB_API LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_decompressionContext_t* dctxPtr, unsigned version); -LZ4LIB_API LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_decompressionContext_t dctx); +LZ4FLIB_API LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_decompressionContext_t* dctxPtr, unsigned version); +LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_decompressionContext_t dctx); /*====== Decompression ======*/ @@ -279,9 +279,9 @@ LZ4LIB_API LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_decompressionCont * (typically, when there is not enough src bytes to fully decode the frame header) * Decompression is expected to resume from where it stopped (srcBuffer + *srcSizePtr) */ -LZ4LIB_API size_t LZ4F_getFrameInfo(LZ4F_decompressionContext_t dctx, - LZ4F_frameInfo_t* frameInfoPtr, - const void* srcBuffer, size_t* srcSizePtr); +LZ4FLIB_API size_t LZ4F_getFrameInfo(LZ4F_decompressionContext_t dctx, + LZ4F_frameInfo_t* frameInfoPtr, + const void* srcBuffer, size_t* srcSizePtr); /*!LZ4F_decompress() : * Call this function repetitively to regenerate data compressed within srcBuffer. @@ -307,10 +307,10 @@ LZ4LIB_API size_t LZ4F_getFrameInfo(LZ4F_decompressionContext_t dctx, * * After a frame is fully decoded, dctx can be used again to decompress another frame. */ -LZ4LIB_API size_t LZ4F_decompress(LZ4F_decompressionContext_t dctx, - void* dstBuffer, size_t* dstSizePtr, - const void* srcBuffer, size_t* srcSizePtr, - const LZ4F_decompressOptions_t* dOptPtr); +LZ4FLIB_API size_t LZ4F_decompress(LZ4F_decompressionContext_t dctx, + void* dstBuffer, size_t* dstSizePtr, + const void* srcBuffer, size_t* srcSizePtr, + const LZ4F_decompressOptions_t* dOptPtr); diff --git a/lib/lz4hc.h b/lib/lz4hc.h index 9ce9e4d..3995ada 100644 --- a/lib/lz4hc.h +++ b/lib/lz4hc.h @@ -53,12 +53,12 @@ extern "C" { */ #if defined(_WIN32) # if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) -# define LZ4LIB_API __declspec(dllexport) +# define LZ4HCLIB_API __declspec(dllexport) # else -# define LZ4LIB_API __declspec(dllimport) +# define LZ4HCLIB_API __declspec(dllimport) # endif #else -# define LZ4LIB_API +# define LZ4HCLIB_API #endif @@ -81,7 +81,7 @@ LZ4_compress_HC() : @return : the number of bytes written into buffer 'dst' or 0 if compression fails. */ -LZ4LIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); +LZ4HCLIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); /* Note : @@ -101,8 +101,8 @@ LZ4_compress_HC_extStateHC() : LZ4_compress_HC_extStateHC() is equivalent to previously described function. It just uses externally allocated memory for stateHC. */ -LZ4LIB_API int LZ4_compress_HC_extStateHC(void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); -LZ4LIB_API int LZ4_sizeofStateHC(void); +LZ4HCLIB_API int LZ4_compress_HC_extStateHC(void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); +LZ4HCLIB_API int LZ4_sizeofStateHC(void); /*-************************************ @@ -128,15 +128,15 @@ typedef struct { size_t table[LZ4_STREAMHCSIZE_SIZET]; } LZ4_streamHC_t; If you use LZ4 as a DLL, use these functions instead of static structure allocation, to avoid size mismatch between different versions. */ -LZ4LIB_API LZ4_streamHC_t* LZ4_createStreamHC(void); -LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr); +LZ4HCLIB_API LZ4_streamHC_t* LZ4_createStreamHC(void); +LZ4HCLIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr); -LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel); -LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize); +LZ4HCLIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel); +LZ4HCLIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize); -LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize); +LZ4HCLIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize); -LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize); +LZ4HCLIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize); /* These functions compress data in successive blocks of any size, using previous blocks as dictionary. @@ -185,16 +185,16 @@ LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, in /* deprecated compression functions */ /* these functions will trigger warning messages in future releases */ -LZ4LIB_API int LZ4_compressHC (const char* source, char* dest, int inputSize); -LZ4LIB_API int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize); +LZ4HCLIB_API int LZ4_compressHC (const char* source, char* dest, int inputSize); +LZ4HCLIB_API int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize); LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel); LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); -LZ4LIB_API int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize); -LZ4LIB_API int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); +LZ4HCLIB_API int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize); +LZ4HCLIB_API int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel); LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); -LZ4LIB_API int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize); -LZ4LIB_API int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize); +LZ4HCLIB_API int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize); +LZ4HCLIB_API int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize); /* Deprecated Streaming functions using older model; should no longer be used */ LZ4_DEPRECATED("use LZ4_createStreamHC() instead") void* LZ4_createHC (char* inputBuffer); -- cgit v0.12 From 829941e5a81081787217ae1a28794e546812b0b4 Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Fri, 23 Sep 2016 10:43:12 +0900 Subject: Add missing $(EXT) to lz4 program name --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d9fbb8c..930922d 100644 --- a/Makefile +++ b/Makefile @@ -41,8 +41,10 @@ LZ4DIR = lib # Define nul output ifneq (,$(filter Windows%,$(OS))) +EXT = .exe VOID = nul else +EXT = VOID = /dev/null endif @@ -58,14 +60,14 @@ lib: lz4: @$(MAKE) -C $(PRGDIR) - @cp $(PRGDIR)/lz4 . + @cp $(PRGDIR)/lz4$(EXT) . clean: @$(MAKE) -C $(PRGDIR) $@ > $(VOID) @$(MAKE) -C $(LZ4DIR) $@ > $(VOID) @$(MAKE) -C examples $@ > $(VOID) @$(MAKE) -C versionsTest $@ > $(VOID) - @$(RM) lz4 + @$(RM) lz4$(EXT) @echo Cleaning completed -- cgit v0.12 From 43b631223b2d0425a0970876974074934f89c450 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 22 Sep 2016 23:59:02 -0400 Subject: add a flag to disable static libs --- lib/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Makefile b/lib/Makefile index b5352a0..27b35c4 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -40,6 +40,7 @@ LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT)) LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT)) LIBVER := $(shell echo $(LIBVER_SCRIPT)) +BUILD_STATIC:= yes DESTDIR?= PREFIX ?= /usr/local @@ -71,9 +72,11 @@ default: liblz4 all: liblz4 liblz4: *.c +ifeq ($(BUILD_STATIC),yes) @echo compiling static library @$(CC) $(FLAGS) -c $^ @$(AR) rcs $@.a *.o +endif @echo compiling dynamic library $(LIBVER) @$(CC) $(FLAGS) -shared $^ -fPIC $(SONAME_FLAGS) -o $@.$(SHARED_EXT_VER) @echo creating versioned links @@ -104,7 +107,9 @@ install: liblz4 liblz4.pc @ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR) @ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT) @install -m 644 liblz4.pc $(DESTDIR)$(LIBDIR)/pkgconfig/ +ifeq ($(BUILD_STATIC),yes) @install -m 644 liblz4.a $(DESTDIR)$(LIBDIR)/liblz4.a +endif @install -m 644 lz4.h $(DESTDIR)$(INCLUDEDIR)/lz4.h @install -m 644 lz4hc.h $(DESTDIR)$(INCLUDEDIR)/lz4hc.h @install -m 644 lz4frame.h $(DESTDIR)$(INCLUDEDIR)/lz4frame.h -- cgit v0.12 From 92408d33819efd74be5ca0f0cf78af6e58b387c8 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 23 Sep 2016 14:09:31 -0400 Subject: README: fix minor typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a7c6e7..76a4607 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ On the other end, a high compression derivative, LZ4_HC, is also provided, trading CPU time for improved compression ratio. All versions feature the same decompression speed. -LZ4 library is provided as open-source software using BSD license.s +LZ4 library is provided as open-source software using BSD license. |Branch |Status | -- cgit v0.12 From 7e112cfa5cd3dfb6d6df97e31c5d68bff4ec0713 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Fri, 21 Oct 2016 09:49:30 -0700 Subject: fixes static compilation under Windows (#246) --- .gitignore | 1 + lib/lz4.h | 8 ++------ programs/.gitignore | 3 +++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 106915f..cd47ddd 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ *.so *.so.* *.dylib +*.dSYM # apple # Executables *.exe diff --git a/lib/lz4.h b/lib/lz4.h index dfe6f2a..3ece4dd 100644 --- a/lib/lz4.h +++ b/lib/lz4.h @@ -55,12 +55,8 @@ extern "C" { * LZ4_DLL_EXPORT : * Enable exporting of functions when building a Windows DLL */ -#if defined(_WIN32) -# if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) -# define LZ4LIB_API __declspec(dllexport) -# else -# define LZ4LIB_API __declspec(dllimport) -# endif +#if defined(_WIN32) && defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) +# define LZ4LIB_API __declspec(dllexport) #else # define LZ4LIB_API #endif diff --git a/programs/.gitignore b/programs/.gitignore index 7110922..df3423e 100644 --- a/programs/.gitignore +++ b/programs/.gitignore @@ -13,3 +13,6 @@ fuzzer32 # tests files tmp* + +# artefacts +*.dSYM -- cgit v0.12 From d05ca2ff6d7ea79ad1426c6cb3f5260ec8af26b9 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 1 Nov 2016 16:54:33 -0700 Subject: fixed #247, reported by Felix Bolte --- programs/lz4io.c | 349 +++++++++++++++++++++++-------------------------------- 1 file changed, 144 insertions(+), 205 deletions(-) diff --git a/programs/lz4io.c b/programs/lz4io.c index f8eadf0..7293d77 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -125,10 +125,10 @@ static int g_displayLevel = 0; /* 0 : no display ; 1: errors ; 2 : + result + interaction + warnings ; 3 : + progression; 4 : + information */ #define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \ - if ((LZ4IO_GetMilliSpan(g_time) > refreshRate) || (g_displayLevel>=4)) \ + if (((g_time - clock()) > refreshRate) || (g_displayLevel>=4)) \ { g_time = clock(); DISPLAY(__VA_ARGS__); \ - if (g_displayLevel>=4) fflush(stdout); } } -static const unsigned refreshRate = 150; + if (g_displayLevel>=4) fflush(stderr); } } +static const unsigned refreshRate = CLOCKS_PER_SEC / 6; static clock_t g_time = 0; @@ -150,7 +150,9 @@ static const int maxBlockSizeID = 7; /************************************** * Exceptions ***************************************/ -#define DEBUG 0 +#ifndef DEBUG +# define DEBUG 0 +#endif #define DEBUGOUTPUT(...) if (DEBUG) DISPLAY(__VA_ARGS__); #define EXM_THROW(error, ...) \ { \ @@ -232,13 +234,6 @@ int LZ4IO_setContentSize(int enable) return g_contentSizeFlag; } -static unsigned LZ4IO_GetMilliSpan(clock_t nPrevious) -{ - clock_t nCurrent = clock(); - unsigned nSpan = (unsigned)(((nCurrent - nPrevious) * 1000) / CLOCKS_PER_SEC); - return nSpan; -} - static unsigned long long LZ4IO_GetFileSize(const char* infilename) { int r; @@ -264,45 +259,34 @@ static int LZ4IO_isSkippableMagicNumber(unsigned int magic) { return (magic & LZ static int LZ4IO_getFiles(const char* input_filename, const char* output_filename, FILE** pfinput, FILE** pfoutput) { - - if (!strcmp (input_filename, stdinmark)) - { - DISPLAYLEVEL(4,"Using stdin for input\n"); + if (!strcmp (input_filename, stdinmark)) { + DISPLAYLEVEL(4,"Using stdin for input \n"); *pfinput = stdin; SET_BINARY_MODE(stdin); - } - else - { + } else { *pfinput = fopen(input_filename, "rb"); } - if ( *pfinput==0 ) - { - DISPLAYLEVEL(1, "Unable to access file for processing: %s\n", input_filename); + if ( *pfinput==0 ) { + DISPLAYLEVEL(1, "Unable to access file for processing: %s \n", input_filename); return 1; } - if (!strcmp (output_filename, stdoutmark)) - { - DISPLAYLEVEL(4,"Using stdout for output\n"); + if (!strcmp (output_filename, stdoutmark)) { + DISPLAYLEVEL(4,"Using stdout for output \n"); *pfoutput = stdout; SET_BINARY_MODE(stdout); - if (g_sparseFileSupport==1) - { + if (g_sparseFileSupport==1) { g_sparseFileSupport = 0; DISPLAYLEVEL(4, "Sparse File Support is automatically disabled on stdout ; try --sparse \n"); } - } - else - { + } else { /* Check if destination file already exists */ *pfoutput=0; if (output_filename != nulmark) *pfoutput = fopen( output_filename, "rb" ); - if (*pfoutput!=0) - { + if (*pfoutput!=0) { fclose(*pfoutput); - if (!g_overwrite) - { + if (!g_overwrite) { int ch = 'Y'; DISPLAYLEVEL(2, "Warning : %s already exists\n", output_filename); if ((g_displayLevel <= 1) || (*pfinput == stdin)) @@ -355,12 +339,10 @@ int LZ4IO_compressFilename_Legacy(const char* input_filename, const char* output const int outBuffSize = LZ4_compressBound(LEGACY_BLOCKSIZE); FILE* finput; FILE* foutput; - clock_t start, end; - size_t sizeCheck; - + clock_t end; /* Init */ - start = clock(); + clock_t const start = clock(); if (compressionlevel < 3) compressionFunction = LZ4IO_LZ4_compress; else compressionFunction = LZ4_compress_HC; if (LZ4IO_getFiles(input_filename, output_filename, &finput, &foutput)) @@ -373,16 +355,15 @@ int LZ4IO_compressFilename_Legacy(const char* input_filename, const char* output /* Write Archive Header */ LZ4IO_writeLE32(out_buff, LEGACY_MAGICNUMBER); - sizeCheck = fwrite(out_buff, 1, MAGICNUMBER_SIZE, foutput); - if (sizeCheck!=MAGICNUMBER_SIZE) EXM_THROW(22, "Write error : cannot write header"); + { size_t const sizeCheck = fwrite(out_buff, 1, MAGICNUMBER_SIZE, foutput); + if (sizeCheck!=MAGICNUMBER_SIZE) EXM_THROW(22, "Write error : cannot write header"); } /* Main Loop */ - while (1) - { + while (1) { unsigned int outSize; /* Read Block */ - int inSize = (int) fread(in_buff, (size_t)1, (size_t)LEGACY_BLOCKSIZE, finput); - if( inSize<=0 ) break; + int const inSize = (int) fread(in_buff, (size_t)1, (size_t)LEGACY_BLOCKSIZE, finput); + if (inSize <= 0) break; filesize += inSize; /* Compress Block */ @@ -392,18 +373,18 @@ int LZ4IO_compressFilename_Legacy(const char* input_filename, const char* output /* Write Block */ LZ4IO_writeLE32(out_buff, outSize); - sizeCheck = fwrite(out_buff, 1, outSize+4, foutput); - if (sizeCheck!=(size_t)(outSize+4)) EXM_THROW(23, "Write error : cannot write compressed block"); - } + { size_t const sizeCheck = fwrite(out_buff, 1, outSize+4, foutput); + if (sizeCheck!=(size_t)(outSize+4)) EXM_THROW(23, "Write error : cannot write compressed block"); + } } /* Status */ end = clock(); - DISPLAYLEVEL(2, "\r%79s\r", ""); - filesize += !filesize; /* avoid divide by zero */ + if (end==start) end+=1; /* avoid division by zero (speed) */ + filesize += !filesize; /* avoid division by zero (ratio) */ + DISPLAYLEVEL(2, "\r%79s\r", ""); /* blank line */ DISPLAYLEVEL(2,"Compressed %llu bytes into %llu bytes ==> %.2f%%\n", - (unsigned long long) filesize, (unsigned long long) compressedfilesize, (double)compressedfilesize/filesize*100); - { - double seconds = (double)(end - start)/CLOCKS_PER_SEC; + filesize, compressedfilesize, (double)compressedfilesize / filesize * 100); + { double const seconds = (double)(end - start) / CLOCKS_PER_SEC; DISPLAYLEVEL(4,"Done in %.2f s ==> %.2f MB/s\n", seconds, (double)filesize / seconds / 1024 / 1024); } @@ -433,9 +414,8 @@ static cRess_t LZ4IO_createCResources(void) { const size_t blockSize = (size_t)LZ4IO_GetBlockSize_FromBlockId (g_blockSizeId); cRess_t ress; - LZ4F_errorCode_t errorCode; - errorCode = LZ4F_createCompressionContext(&(ress.ctx), LZ4F_VERSION); + LZ4F_errorCode_t const errorCode = LZ4F_createCompressionContext(&(ress.ctx), LZ4F_VERSION); if (LZ4F_isError(errorCode)) EXM_THROW(30, "Allocation error : can't create LZ4F context : %s", LZ4F_getErrorName(errorCode)); /* Allocate Memory */ @@ -450,11 +430,10 @@ static cRess_t LZ4IO_createCResources(void) static void LZ4IO_freeCResources(cRess_t ress) { - LZ4F_errorCode_t errorCode; free(ress.srcBuffer); free(ress.dstBuffer); - errorCode = LZ4F_freeCompressionContext(ress.ctx); - if (LZ4F_isError(errorCode)) EXM_THROW(38, "Error : can't free LZ4F context resource : %s", LZ4F_getErrorName(errorCode)); + { LZ4F_errorCode_t const errorCode = LZ4F_freeCompressionContext(ress.ctx); + if (LZ4F_isError(errorCode)) EXM_THROW(38, "Error : can't free LZ4F context resource : %s", LZ4F_getErrorName(errorCode)); } } /* @@ -472,7 +451,7 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName, void* const dstBuffer = ress.dstBuffer; const size_t dstBufferSize = ress.dstBufferSize; const size_t blockSize = (size_t)LZ4IO_GetBlockSize_FromBlockId (g_blockSizeId); - size_t sizeCheck, headerSize, readSize; + size_t headerSize, readSize; LZ4F_compressionContext_t ctx = ress.ctx; /* just a pointer */ LZ4F_preferences_t prefs; @@ -489,12 +468,11 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName, prefs.frameInfo.blockMode = (LZ4F_blockMode_t)g_blockIndependence; prefs.frameInfo.blockSizeID = (LZ4F_blockSizeID_t)g_blockSizeId; prefs.frameInfo.contentChecksumFlag = (LZ4F_contentChecksum_t)g_streamChecksum; - if (g_contentSizeFlag) - { - unsigned long long fileSize = LZ4IO_GetFileSize(srcFileName); + if (g_contentSizeFlag) { + unsigned long long const fileSize = LZ4IO_GetFileSize(srcFileName); prefs.frameInfo.contentSize = fileSize; /* == 0 if input == stdin */ if (fileSize==0) - DISPLAYLEVEL(3, "Warning : cannot determine uncompressed frame content size \n"); + DISPLAYLEVEL(3, "Warning : cannot determine input content size \n"); } /* read first block */ @@ -502,19 +480,18 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName, filesize += readSize; /* single-block file */ - if (readSize < blockSize) - { + if (readSize < blockSize) { /* Compress in single pass */ - size_t cSize = LZ4F_compressFrame(dstBuffer, dstBufferSize, srcBuffer, readSize, &prefs); + size_t const cSize = LZ4F_compressFrame(dstBuffer, dstBufferSize, srcBuffer, readSize, &prefs); if (LZ4F_isError(cSize)) EXM_THROW(34, "Compression failed : %s", LZ4F_getErrorName(cSize)); - compressedfilesize += cSize; + compressedfilesize = cSize; DISPLAYUPDATE(2, "\rRead : %u MB ==> %.2f%% ", (unsigned)(filesize>>20), (double)compressedfilesize/(filesize+!filesize)*100); /* avoid division by zero */ /* Write Block */ - sizeCheck = fwrite(dstBuffer, 1, cSize, dstFile); - if (sizeCheck!=cSize) EXM_THROW(35, "Write error : cannot write compressed block"); - } + { size_t const sizeCheck = fwrite(dstBuffer, 1, cSize, dstFile); + if (sizeCheck!=cSize) EXM_THROW(35, "Write error : cannot write compressed block"); + } } else @@ -523,13 +500,12 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName, /* Write Archive Header */ headerSize = LZ4F_compressBegin(ctx, dstBuffer, dstBufferSize, &prefs); if (LZ4F_isError(headerSize)) EXM_THROW(32, "File header generation failed : %s", LZ4F_getErrorName(headerSize)); - sizeCheck = fwrite(dstBuffer, 1, headerSize, dstFile); - if (sizeCheck!=headerSize) EXM_THROW(33, "Write error : cannot write header"); + { size_t const sizeCheck = fwrite(dstBuffer, 1, headerSize, dstFile); + if (sizeCheck!=headerSize) EXM_THROW(33, "Write error : cannot write header"); } compressedfilesize += headerSize; /* Main Loop */ - while (readSize>0) - { + while (readSize>0) { size_t outSize; /* Compress Block */ @@ -539,8 +515,8 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName, DISPLAYUPDATE(2, "\rRead : %u MB ==> %.2f%% ", (unsigned)(filesize>>20), (double)compressedfilesize/filesize*100); /* Write Block */ - sizeCheck = fwrite(dstBuffer, 1, outSize, dstFile); - if (sizeCheck!=outSize) EXM_THROW(35, "Write error : cannot write compressed block"); + { size_t const sizeCheck = fwrite(dstBuffer, 1, outSize, dstFile); + if (sizeCheck!=outSize) EXM_THROW(35, "Write error : cannot write compressed block"); } /* Read next block */ readSize = fread(srcBuffer, (size_t)1, (size_t)blockSize, srcFile); @@ -551,8 +527,8 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName, headerSize = LZ4F_compressEnd(ctx, dstBuffer, dstBufferSize, NULL); if (LZ4F_isError(headerSize)) EXM_THROW(36, "End of file generation failed : %s", LZ4F_getErrorName(headerSize)); - sizeCheck = fwrite(dstBuffer, 1, headerSize, dstFile); - if (sizeCheck!=headerSize) EXM_THROW(37, "Write error : cannot write end of stream"); + { size_t const sizeCheck = fwrite(dstBuffer, 1, headerSize, dstFile); + if (sizeCheck!=headerSize) EXM_THROW(37, "Write error : cannot write end of stream"); } compressedfilesize += headerSize; } @@ -571,24 +547,17 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName, int LZ4IO_compressFilename(const char* srcFileName, const char* dstFileName, int compressionLevel) { - clock_t start, end; - cRess_t ress; - int issueWithSrcFile = 0; + clock_t const start = clock(); + cRess_t const ress = LZ4IO_createCResources(); - /* Init */ - start = clock(); - ress = LZ4IO_createCResources(); - - /* Compress File */ - issueWithSrcFile += LZ4IO_compressFilename_extRess(ress, srcFileName, dstFileName, compressionLevel); + int const issueWithSrcFile = LZ4IO_compressFilename_extRess(ress, srcFileName, dstFileName, compressionLevel); /* Free resources */ LZ4IO_freeCResources(ress); /* Final Status */ - end = clock(); - { - double seconds = (double)(end - start) / CLOCKS_PER_SEC; + { clock_t const end = clock(); + double const seconds = (double)(end - start) / CLOCKS_PER_SEC; DISPLAYLEVEL(4, "Completed in %.2f sec \n", seconds); } @@ -604,15 +573,11 @@ int LZ4IO_compressMultipleFilenames(const char** inFileNamesTable, int ifntSize, char* dstFileName = (char*)malloc(FNSPACE); size_t ofnSize = FNSPACE; const size_t suffixSize = strlen(suffix); - cRess_t ress; - - /* init */ - ress = LZ4IO_createCResources(); + cRess_t const ress = LZ4IO_createCResources(); /* loop on each file */ - for (i=0; i 1 GB) - { - int seekResult = fseek(file, 1 GB, SEEK_CUR); + if (storedSkips > 1 GB) { + int const seekResult = fseek(file, 1 GB, SEEK_CUR); if (seekResult != 0) EXM_THROW(71, "1 GB skip error (sparse file support)"); storedSkips -= 1 GB; } - while (ptrT < bufferTEnd) - { + while (ptrT < bufferTEnd) { size_t seg0SizeT = segmentSizeT; size_t nb0T; - int seekResult; /* count leading zeros */ if (seg0SizeT > bufferSizeT) seg0SizeT = bufferSizeT; @@ -677,37 +638,32 @@ static unsigned LZ4IO_fwriteSparse(FILE* file, const void* buffer, size_t buffer for (nb0T=0; (nb0T < seg0SizeT) && (ptrT[nb0T] == 0); nb0T++) ; storedSkips += (unsigned)(nb0T * sizeT); - if (nb0T != seg0SizeT) /* not all 0s */ - { - size_t sizeCheck; - seekResult = fseek(file, storedSkips, SEEK_CUR); + if (nb0T != seg0SizeT) { /* not all 0s */ + int const seekResult = fseek(file, storedSkips, SEEK_CUR); if (seekResult) EXM_THROW(72, "Sparse skip error ; try --no-sparse"); storedSkips = 0; seg0SizeT -= nb0T; ptrT += nb0T; - sizeCheck = fwrite(ptrT, sizeT, seg0SizeT, file); - if (sizeCheck != seg0SizeT) EXM_THROW(73, "Write error : cannot write decoded block"); - } + { size_t const sizeCheck = fwrite(ptrT, sizeT, seg0SizeT, file); + if (sizeCheck != seg0SizeT) EXM_THROW(73, "Write error : cannot write decoded block"); + } } ptrT += seg0SizeT; } - if (bufferSize & maskT) /* size not multiple of sizeT : implies end of block */ - { + if (bufferSize & maskT) { /* size not multiple of sizeT : implies end of block */ const char* const restStart = (const char*)bufferTEnd; const char* restPtr = restStart; - size_t restSize = bufferSize & maskT; + size_t const restSize = bufferSize & maskT; const char* const restEnd = restStart + restSize; for (; (restPtr < restEnd) && (*restPtr == 0); restPtr++) ; storedSkips += (unsigned) (restPtr - restStart); - if (restPtr != restEnd) - { - size_t sizeCheck; - int seekResult = fseek(file, storedSkips, SEEK_CUR); + if (restPtr != restEnd) { + int const seekResult = fseek(file, storedSkips, SEEK_CUR); if (seekResult) EXM_THROW(74, "Sparse skip error ; try --no-sparse"); storedSkips = 0; - sizeCheck = fwrite(restPtr, 1, restEnd - restPtr, file); - if (sizeCheck != (size_t)(restEnd - restPtr)) EXM_THROW(75, "Write error : cannot write decoded end of block"); - } + { size_t const sizeCheck = fwrite(restPtr, 1, restEnd - restPtr, file); + if (sizeCheck != (size_t)(restEnd - restPtr)) EXM_THROW(75, "Write error : cannot write decoded end of block"); + } } } return storedSkips; @@ -715,18 +671,13 @@ static unsigned LZ4IO_fwriteSparse(FILE* file, const void* buffer, size_t buffer static void LZ4IO_fwriteSparseEnd(FILE* file, unsigned storedSkips) { - char lastZeroByte[1] = { 0 }; - - if (storedSkips>0) /* implies g_sparseFileSupport */ - { - int seekResult; - size_t sizeCheck; - storedSkips --; - seekResult = fseek(file, storedSkips, SEEK_CUR); + if (storedSkips>0) { /* implies g_sparseFileSupport */ + int const seekResult = fseek(file, storedSkips-1, SEEK_CUR); if (seekResult != 0) EXM_THROW(69, "Final skip error (sparse file)\n"); - sizeCheck = fwrite(lastZeroByte, 1, 1, file); - if (sizeCheck != 1) EXM_THROW(69, "Write error : cannot write last zero\n"); - } + { const char lastZeroByte[1] = { 0 }; + size_t const sizeCheck = fwrite(lastZeroByte, 1, 1, file); + if (sizeCheck != 1) EXM_THROW(69, "Write error : cannot write last zero\n"); + } } } @@ -744,8 +695,7 @@ static unsigned long long LZ4IO_decodeLegacyStream(FILE* finput, FILE* foutput) if (!in_buff || !out_buff) EXM_THROW(51, "Allocation error : not enough memory"); /* Main Loop */ - while (1) - { + while (1) { int decodeSize; size_t sizeCheck; unsigned int blockSize; @@ -754,8 +704,8 @@ static unsigned long long LZ4IO_decodeLegacyStream(FILE* finput, FILE* foutput) sizeCheck = fread(in_buff, 1, 4, finput); if (sizeCheck==0) break; /* Nothing to read : file read is completed */ blockSize = LZ4IO_readLE32(in_buff); /* Convert to Little Endian */ - if (blockSize > LZ4_COMPRESSBOUND(LEGACY_BLOCKSIZE)) - { /* Cannot read next block : maybe new stream ? */ + if (blockSize > LZ4_COMPRESSBOUND(LEGACY_BLOCKSIZE)) { + /* Cannot read next block : maybe new stream ? */ g_magicRead = blockSize; break; } @@ -793,14 +743,12 @@ typedef struct { } dRess_t; static const size_t LZ4IO_dBufferSize = 64 KB; - static dRess_t LZ4IO_createDResources(void) { dRess_t ress; - LZ4F_errorCode_t errorCode; /* init */ - errorCode = LZ4F_createDecompressionContext(&ress.dCtx, LZ4F_VERSION); + LZ4F_errorCode_t const errorCode = LZ4F_createDecompressionContext(&ress.dCtx, LZ4F_VERSION); if (LZ4F_isError(errorCode)) EXM_THROW(60, "Can't create LZ4F context : %s", LZ4F_getErrorName(errorCode)); /* Allocate Memory */ @@ -828,9 +776,8 @@ static unsigned long long LZ4IO_decompressLZ4F(dRess_t ress, FILE* srcFile, FILE LZ4F_errorCode_t nextToLoad; unsigned storedSkips = 0; - /* Init feed with magic number (already consumed from FILE* sFile) */ - { - size_t inSize = MAGICNUMBER_SIZE; + /* Init feed with magic number (already consumed from FILE* sFile) */ + { size_t inSize = MAGICNUMBER_SIZE; size_t outSize= 0; LZ4IO_writeLE32(ress.srcBuffer, LZ4IO_MAGICNUMBER); nextToLoad = LZ4F_decompress(ress.dCtx, ress.dstBuffer, &outSize, ress.srcBuffer, &inSize, NULL); @@ -838,8 +785,7 @@ static unsigned long long LZ4IO_decompressLZ4F(dRess_t ress, FILE* srcFile, FILE } /* Main Loop */ - for (;nextToLoad;) - { + for (;nextToLoad;) { size_t readSize; size_t pos = 0; size_t decodedBytes = ress.dstBufferSize; @@ -847,11 +793,9 @@ static unsigned long long LZ4IO_decompressLZ4F(dRess_t ress, FILE* srcFile, FILE /* Read input */ if (nextToLoad > ress.srcBufferSize) nextToLoad = ress.srcBufferSize; readSize = fread(ress.srcBuffer, 1, nextToLoad, srcFile); - if (!readSize) - break; /* empty file or stream */ + if (!readSize) break; /* reached end of file or stream */ - while ((pos < readSize) || (decodedBytes == ress.dstBufferSize)) /* still to read, or still to flush */ - { + while ((pos < readSize) || (decodedBytes == ress.dstBufferSize)) { /* still to read, or still to flush */ /* Decode Input (at least partially) */ size_t remaining = readSize - pos; decodedBytes = ress.dstBufferSize; @@ -859,12 +803,11 @@ static unsigned long long LZ4IO_decompressLZ4F(dRess_t ress, FILE* srcFile, FILE if (LZ4F_isError(nextToLoad)) EXM_THROW(66, "Decompression error : %s", LZ4F_getErrorName(nextToLoad)); pos += remaining; - if (decodedBytes) - { - /* Write Block */ + /* Write Block */ + if (decodedBytes) { + storedSkips = LZ4IO_fwriteSparse(dstFile, ress.dstBuffer, decodedBytes, storedSkips); filesize += decodedBytes; DISPLAYUPDATE(2, "\rDecompressed : %u MB ", (unsigned)(filesize>>20)); - storedSkips = LZ4IO_fwriteSparse(dstFile, ress.dstBuffer, decodedBytes, storedSkips); } if (!nextToLoad) break; @@ -872,9 +815,7 @@ static unsigned long long LZ4IO_decompressLZ4F(dRess_t ress, FILE* srcFile, FILE } LZ4IO_fwriteSparseEnd(dstFile, storedSkips); - - if (nextToLoad!=0) - EXM_THROW(67, "Unfinished stream"); + if (nextToLoad!=0) EXM_THROW(67, "Unfinished stream"); return filesize; } @@ -885,15 +826,14 @@ static unsigned long long LZ4IO_decompressLZ4F(dRess_t ress, FILE* srcFile, FILE static unsigned long long LZ4IO_passThrough(FILE* finput, FILE* foutput, unsigned char MNstore[MAGICNUMBER_SIZE]) { size_t buffer[PTSIZET]; - size_t read = 1, sizeCheck; + size_t read = 1; unsigned long long total = MAGICNUMBER_SIZE; unsigned storedSkips = 0; - sizeCheck = fwrite(MNstore, 1, MAGICNUMBER_SIZE, foutput); + size_t const sizeCheck = fwrite(MNstore, 1, MAGICNUMBER_SIZE, foutput); if (sizeCheck != MAGICNUMBER_SIZE) EXM_THROW(50, "Pass-through write error"); - while (read) - { + while (read) { read = fread(buffer, 1, PTSIZE, finput); total += read; storedSkips = LZ4IO_fwriteSparse(foutput, buffer, read, storedSkips); @@ -904,27 +844,39 @@ static unsigned long long LZ4IO_passThrough(FILE* finput, FILE* foutput, unsigne } +/** Safely handle cases when (unsigned)offset > LONG_MAX */ +static int fseek_u32(FILE *fp, unsigned offset, int where) +{ + const unsigned stepMax = 1U << 30; + int errorNb = 0; + + if (where != SEEK_CUR) return -1; /* Only allows SEEK_CUR */ + while (offset > 0) { + unsigned s = offset; + if (s > stepMax) s = stepMax; + errorNb = fseek(fp, (long) s, SEEK_CUR); + if (errorNb != 0) break; + offset -= s; + } + return errorNb; +} + #define ENDOFSTREAM ((unsigned long long)-1) static unsigned long long selectDecoder(dRess_t ress, FILE* finput, FILE* foutput) { unsigned char MNstore[MAGICNUMBER_SIZE]; - unsigned magicNumber, size; - int errorNb; - size_t nbReadBytes; + unsigned magicNumber; static unsigned nbCalls = 0; /* init */ nbCalls++; /* Check Archive Header */ - if (g_magicRead) - { + if (g_magicRead) { /* magic number already read from finput (see legacy frame)*/ magicNumber = g_magicRead; g_magicRead = 0; - } - else - { - nbReadBytes = fread(MNstore, 1, MAGICNUMBER_SIZE, finput); + } else { + size_t const nbReadBytes = fread(MNstore, 1, MAGICNUMBER_SIZE, finput); if (nbReadBytes==0) return ENDOFSTREAM; /* EOF */ if (nbReadBytes != MAGICNUMBER_SIZE) EXM_THROW(40, "Unrecognized header : Magic Number unreadable"); magicNumber = LZ4IO_readLE32(MNstore); /* Little Endian format */ @@ -940,21 +892,20 @@ static unsigned long long selectDecoder(dRess_t ress, FILE* finput, FILE* foutpu return LZ4IO_decodeLegacyStream(finput, foutput); case LZ4IO_SKIPPABLE0: DISPLAYLEVEL(4, "Skipping detected skippable area \n"); - nbReadBytes = fread(MNstore, 1, 4, finput); - if (nbReadBytes != 4) EXM_THROW(42, "Stream error : skippable size unreadable"); - size = LZ4IO_readLE32(MNstore); /* Little Endian format */ - errorNb = fseek(finput, size, SEEK_CUR); - if (errorNb != 0) EXM_THROW(43, "Stream error : cannot skip skippable area"); - return selectDecoder(ress, finput, foutput); - EXTENDED_FORMAT; + { size_t const nbReadBytes = fread(MNstore, 1, 4, finput); + if (nbReadBytes != 4) EXM_THROW(42, "Stream error : skippable size unreadable"); } + { unsigned const size = LZ4IO_readLE32(MNstore); /* Little Endian format */ + int const errorNb = fseek_u32(finput, size, SEEK_CUR); + if (errorNb != 0) EXM_THROW(43, "Stream error : cannot skip skippable area"); } + return 0; + EXTENDED_FORMAT; /* macro extension for custom formats */ default: - if (nbCalls == 1) /* just started */ - { + if (nbCalls == 1) { /* just started */ if (g_overwrite) return LZ4IO_passThrough(finput, foutput, MNstore); EXM_THROW(44,"Unrecognized header : file cannot be decoded"); /* Wrong magic number at the beginning of 1st stream */ } - DISPLAYLEVEL(2, "Stream followed by unrecognized data\n"); + DISPLAYLEVEL(2, "Stream followed by undecodable data\n"); return ENDOFSTREAM; } } @@ -966,7 +917,6 @@ static int LZ4IO_decompressFile_extRess(dRess_t ress, const char* input_filename FILE* finput; FILE* foutput; - /* Init */ if (LZ4IO_getFiles(input_filename, output_filename, &finput, &foutput)) return 1; @@ -975,8 +925,7 @@ static int LZ4IO_decompressFile_extRess(dRess_t ress, const char* input_filename if (g_sparseFileSupport) { SET_SPARSE_FILE_MODE(foutput); } /* Loop over multiple streams */ - do - { + do { decodedSize = selectDecoder(ress, finput, foutput); if (decodedSize != ENDOFSTREAM) filesize += decodedSize; @@ -996,23 +945,17 @@ static int LZ4IO_decompressFile_extRess(dRess_t ress, const char* input_filename int LZ4IO_decompressFilename(const char* input_filename, const char* output_filename) { - dRess_t ress; - clock_t start, end; - int missingFiles = 0; + dRess_t const ress = LZ4IO_createDResources(); + clock_t const start = clock(); - start = clock(); + int const missingFiles = LZ4IO_decompressFile_extRess(ress, input_filename, output_filename); - ress = LZ4IO_createDResources(); - missingFiles += LZ4IO_decompressFile_extRess(ress, input_filename, output_filename); - LZ4IO_freeDResources(ress); - - end = clock(); - if (end==start) end=start+1; - { - double seconds = (double)(end - start)/CLOCKS_PER_SEC; + { clock_t const end = clock(); + double const seconds = (double)(end - start) / CLOCKS_PER_SEC; DISPLAYLEVEL(4, "Done in %.2f sec \n", seconds); } + LZ4IO_freeDResources(ress); return missingFiles; } @@ -1025,20 +968,16 @@ int LZ4IO_decompressMultipleFilenames(const char** inFileNamesTable, int ifntSiz int missingFiles = 0; char* outFileName = (char*)malloc(FNSPACE); size_t ofnSize = FNSPACE; - const size_t suffixSize = strlen(suffix); - const char* suffixPtr; - dRess_t ress; + size_t const suffixSize = strlen(suffix); + dRess_t const ress = LZ4IO_createDResources(); - if (outFileName==NULL) exit(1); /* not enough memory */ - ress = LZ4IO_createDResources(); + if (outFileName==NULL) exit(1); /* not enough memory */ - for (i=0; i Date: Tue, 1 Nov 2016 17:26:22 -0700 Subject: moved cmake and debian directories to contrib (#245) --- Makefile | 2 +- NEWS | 7 +- cmake_unofficial/CMakeLists.txt | 114 -------------------------------- contrib/cmake_unofficial/.gitignore | 7 ++ contrib/cmake_unofficial/CMakeLists.txt | 110 ++++++++++++++++++++++++++++++ contrib/debian/changelog | 10 +++ contrib/debian/compat | 1 + contrib/debian/control | 23 +++++++ contrib/debian/copyright | 9 +++ contrib/debian/dirs | 1 + contrib/debian/docs | 0 contrib/debian/liblz4-dev.install | 2 + contrib/debian/liblz4.install | 2 + contrib/debian/rules | 8 +++ debian/changelog | 8 --- debian/compat | 1 - debian/control | 23 ------- debian/copyright | 9 --- debian/dirs | 1 - debian/docs | 0 debian/liblz4-dev.install | 2 - debian/liblz4.install | 2 - debian/rules | 8 --- programs/lz4io.c | 10 +-- 24 files changed, 183 insertions(+), 177 deletions(-) delete mode 100644 cmake_unofficial/CMakeLists.txt create mode 100644 contrib/cmake_unofficial/.gitignore create mode 100644 contrib/cmake_unofficial/CMakeLists.txt create mode 100644 contrib/debian/changelog create mode 100644 contrib/debian/compat create mode 100644 contrib/debian/control create mode 100644 contrib/debian/copyright create mode 100644 contrib/debian/dirs create mode 100644 contrib/debian/docs create mode 100644 contrib/debian/liblz4-dev.install create mode 100644 contrib/debian/liblz4.install create mode 100755 contrib/debian/rules delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100644 debian/dirs delete mode 100644 debian/docs delete mode 100644 debian/liblz4-dev.install delete mode 100644 debian/liblz4.install delete mode 100755 debian/rules diff --git a/Makefile b/Makefile index 930922d..518ffbd 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ test: $(MAKE) -C $(PRGDIR) test cmake: - @cd cmake_unofficial; cmake CMakeLists.txt; $(MAKE) + @cd contrib/cmake_unofficial; cmake CMakeLists.txt; $(MAKE) gpptest: clean $(MAKE) all CC=g++ CFLAGS="-O3 -I../lib -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" diff --git a/NEWS b/NEWS index a1baead..b676d86 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,10 @@ -r132 +v1.7.2 +Changed : moved to versioning; package, cli and library have same version number Improved: Small decompression speed boost (+4%) Improved: Performance on ARMv6 and ARMv7 Added : Debianization, by Evgeniy Polyakov -Makefile: Safely protects lz4 version when selecting custom CFLAGS -Makefile: Generates intermediate object files (*.o) for faster compilation on low power systems +Makefile: Generates object files (*.o) for faster (re)compilation on low power systems +Fix : cli : crash on some invalid inputs r131 New : Dos/DJGPP target, thanks to Louis Santillan (#114) diff --git a/cmake_unofficial/CMakeLists.txt b/cmake_unofficial/CMakeLists.txt deleted file mode 100644 index c7f1dab..0000000 --- a/cmake_unofficial/CMakeLists.txt +++ /dev/null @@ -1,114 +0,0 @@ -PROJECT(LZ4 C) -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LZ4 compression library") -set(CPACK_PACKAGE_VERSION_MAJOR 1) -set(CPACK_PACKAGE_VERSION_MINOR 7) -set(CPACK_PACKAGE_VERSION_PATCH r132) -set(VERSION_STRING " \"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}\" ") -include(CPack) - -cmake_minimum_required (VERSION 2.6) -INCLUDE (CheckTypeSize) -check_type_size("void *" SIZEOF_VOID_P) -IF(SIZEOF_VOID_P STREQUAL "8") - set (CMAKE_SYSTEM_PROCESSOR "64bit") - MESSAGE( STATUS "64 bit architecture detected size of void * is " ${SIZEOF_VOID_P}) -ENDIF() - -option(BUILD_TOOLS "Build the command line tools" ON) -option(BUILD_LIBS "Build the libraries in addition to the tools" ON) -option(LINK_TOOLS_WITH_LIB "Link the command line tools with the (shared) library" OFF) - -IF(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR - CMAKE_C_COMPILER_ID STREQUAL "Clang") - SET(GNU_COMPATIBLE_COMPILER 1) -ENDIF() - - -set(LZ4_DIR ../lib/) -set(PRG_DIR ../programs/) -set(LZ4_SRCS_LIB ${LZ4_DIR}lz4.c ${LZ4_DIR}lz4hc.c ${LZ4_DIR}lz4.h ${LZ4_DIR}lz4hc.h ${LZ4_DIR}lz4frame.c ${LZ4_DIR}lz4frame.h ${LZ4_DIR}xxhash.c) -set(LZ4_SRCS ${LZ4_DIR}lz4frame.c ${LZ4_DIR}xxhash.c ${PRG_DIR}bench.c ${PRG_DIR}lz4cli.c ${PRG_DIR}lz4io.c) - -if(BUILD_TOOLS AND NOT (LINK_TOOLS_WITH_LIB AND BUILD_LIBS)) - set(LZ4_SRCS ${LZ4_SRCS} ${LZ4_SRCS_LIB}) -endif() - -if(BUILD_TOOLS) - add_executable(lz4 ${LZ4_SRCS}) - install(TARGETS lz4 RUNTIME DESTINATION "bin/") -endif() - -if(BUILD_LIBS) - - - SET(LIBS_TARGETS "") - IF(WIN32) - add_library(liblz4 STATIC ${LZ4_SRCS_LIB}) - SET(LIBS_TARGETS liblz4) - ELSE(WIN32) - add_library(liblz4 SHARED ${LZ4_SRCS_LIB}) - add_library(liblz4_static STATIC ${LZ4_SRCS_LIB}) - SET_TARGET_PROPERTIES(liblz4_static PROPERTIES OUTPUT_NAME lz4) - SET(LIBS_TARGETS liblz4 liblz4_static) - ENDIF(WIN32) - - set_target_properties(liblz4 PROPERTIES - OUTPUT_NAME lz4 - SOVERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}" - ) - - install(TARGETS ${LIBS_TARGETS} - RUNTIME DESTINATION lib #on Windows: cmake considers dlls as runtime component - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - ) - - install(FILES - ${LZ4_DIR}/lz4.h - ${LZ4_DIR}/lz4hc.h - ${LZ4_DIR}/lz4frame.h - DESTINATION include - ) - - set(PREFIX ${CMAKE_INSTALL_PREFIX}) - set(LIBDIR ${CMAKE_INSTALL_PREFIX}/lib) - set(INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include) - string(SUBSTRING ${CPACK_PACKAGE_VERSION_PATCH} 1 -1 VERSION) - configure_file(${LZ4_DIR}/liblz4.pc.in liblz4.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblz4.pc - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig" - ) - - if(BUILD_TOOLS AND LINK_TOOLS_WITH_LIB) - target_link_libraries(lz4 liblz4) - endif() -endif() - - -#warnings - -if(MSVC) - ADD_DEFINITIONS("-W4") -endif() -if(GNU_COMPATIBLE_COMPILER) - ADD_DEFINITIONS("-Wall") -endif() -if(CMAKE_COMPILER_IS_GNUCXX) - ADD_DEFINITIONS("-Wextra") - ADD_DEFINITIONS("-Wundef") - ADD_DEFINITIONS("-Wshadow") - ADD_DEFINITIONS("-Wcast-align") - ADD_DEFINITIONS("-Wstrict-prototypes") -endif(CMAKE_COMPILER_IS_GNUCXX) -if(GNU_COMPATIBLE_COMPILER) - # we need gnu99 instead of c99 on Linux and Solaris - # to get C99 and POSIX definitions - # an alternative with cmake >= 3.1/3.2 is the C_STANDARD property - ADD_DEFINITIONS("-std=gnu99") -endif() -ADD_DEFINITIONS("-DLZ4_VERSION=\"${CPACK_PACKAGE_VERSION_PATCH}\"") -INCLUDE_DIRECTORIES (${LZ4_DIR}) - - - - diff --git a/contrib/cmake_unofficial/.gitignore b/contrib/cmake_unofficial/.gitignore new file mode 100644 index 0000000..0f81929 --- /dev/null +++ b/contrib/cmake_unofficial/.gitignore @@ -0,0 +1,7 @@ +# cmake artefact + +CMakeCache.txt +CMakeFiles +*.cmake +Makefile +liblz4.pc diff --git a/contrib/cmake_unofficial/CMakeLists.txt b/contrib/cmake_unofficial/CMakeLists.txt new file mode 100644 index 0000000..6edec98 --- /dev/null +++ b/contrib/cmake_unofficial/CMakeLists.txt @@ -0,0 +1,110 @@ +PROJECT(LZ4 C) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LZ4 compression library") +set(CPACK_PACKAGE_VERSION_MAJOR 1) +set(CPACK_PACKAGE_VERSION_MINOR 7) +set(CPACK_PACKAGE_VERSION_PATCH 2) +set(VERSION_STRING " \"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}\" ") +include(CPack) + +cmake_minimum_required (VERSION 2.6) +INCLUDE (CheckTypeSize) +check_type_size("void *" SIZEOF_VOID_P) +IF(SIZEOF_VOID_P STREQUAL "8") + set (CMAKE_SYSTEM_PROCESSOR "64bit") + MESSAGE( STATUS "64 bit architecture detected size of void * is " ${SIZEOF_VOID_P}) +ENDIF() + +option(BUILD_TOOLS "Build the command line tools" ON) +option(BUILD_LIBS "Build the libraries in addition to the tools" ON) +option(LINK_TOOLS_WITH_LIB "Link the command line tools with the (shared) library" OFF) + +IF(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR + CMAKE_C_COMPILER_ID STREQUAL "Clang") + SET(GNU_COMPATIBLE_COMPILER 1) +ENDIF() + + +set(LZ4_DIR ../../lib/) +set(PRG_DIR ../../programs/) +set(LZ4_SRCS_LIB ${LZ4_DIR}lz4.c ${LZ4_DIR}lz4hc.c ${LZ4_DIR}lz4.h ${LZ4_DIR}lz4hc.h ${LZ4_DIR}lz4frame.c ${LZ4_DIR}lz4frame.h ${LZ4_DIR}xxhash.c) +set(LZ4_SRCS ${LZ4_DIR}lz4frame.c ${LZ4_DIR}xxhash.c ${PRG_DIR}bench.c ${PRG_DIR}lz4cli.c ${PRG_DIR}lz4io.c) + +if(BUILD_TOOLS AND NOT (LINK_TOOLS_WITH_LIB AND BUILD_LIBS)) + set(LZ4_SRCS ${LZ4_SRCS} ${LZ4_SRCS_LIB}) +endif() + +if(BUILD_TOOLS) + add_executable(lz4 ${LZ4_SRCS}) + install(TARGETS lz4 RUNTIME DESTINATION "bin/") +endif() + +if(BUILD_LIBS) + + + SET(LIBS_TARGETS "") + IF(WIN32) + add_library(liblz4 STATIC ${LZ4_SRCS_LIB}) + SET(LIBS_TARGETS liblz4) + ELSE(WIN32) + add_library(liblz4 SHARED ${LZ4_SRCS_LIB}) + add_library(liblz4_static STATIC ${LZ4_SRCS_LIB}) + SET_TARGET_PROPERTIES(liblz4_static PROPERTIES OUTPUT_NAME lz4) + SET(LIBS_TARGETS liblz4 liblz4_static) + ENDIF(WIN32) + + set_target_properties(liblz4 PROPERTIES + OUTPUT_NAME lz4 + SOVERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}" + ) + + install(TARGETS ${LIBS_TARGETS} + RUNTIME DESTINATION lib #on Windows: cmake considers dlls as runtime component + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + ) + + install(FILES + ${LZ4_DIR}/lz4.h + ${LZ4_DIR}/lz4hc.h + ${LZ4_DIR}/lz4frame.h + DESTINATION include + ) + + set(PREFIX ${CMAKE_INSTALL_PREFIX}) + set(LIBDIR ${CMAKE_INSTALL_PREFIX}/lib) + set(INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include) + string(SUBSTRING ${CPACK_PACKAGE_VERSION_PATCH} 1 -1 VERSION) + configure_file(${LZ4_DIR}/liblz4.pc.in liblz4.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblz4.pc + DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig" + ) + + if(BUILD_TOOLS AND LINK_TOOLS_WITH_LIB) + target_link_libraries(lz4 liblz4) + endif() +endif() + + +#warnings + +if(MSVC) + ADD_DEFINITIONS("-W4") +endif() +if(GNU_COMPATIBLE_COMPILER) + ADD_DEFINITIONS("-Wall") +endif() +if(CMAKE_COMPILER_IS_GNUCXX) + ADD_DEFINITIONS("-Wextra") + ADD_DEFINITIONS("-Wundef") + ADD_DEFINITIONS("-Wshadow") + ADD_DEFINITIONS("-Wcast-align") + ADD_DEFINITIONS("-Wstrict-prototypes") +endif(CMAKE_COMPILER_IS_GNUCXX) +if(GNU_COMPATIBLE_COMPILER) + # we need gnu99 instead of c99 on Linux and Solaris + # to get C99 and POSIX definitions + # an alternative with cmake >= 3.1/3.2 is the C_STANDARD property + ADD_DEFINITIONS("-std=gnu99") +endif() +ADD_DEFINITIONS("-DLZ4_VERSION=\"${CPACK_PACKAGE_VERSION_PATCH}\"") +INCLUDE_DIRECTORIES (${LZ4_DIR}) diff --git a/contrib/debian/changelog b/contrib/debian/changelog new file mode 100644 index 0000000..87ac016 --- /dev/null +++ b/contrib/debian/changelog @@ -0,0 +1,10 @@ +liblz4 (1.7.2) unstable; urgency=low + + * Changed : moved to versioning; package, cli and library have same version number + * Improved: Small decompression speed boost (+4%) + * Improved: Performance on ARMv6 and ARMv7 + * Added : Debianization, by Evgeniy Polyakov + * Makefile: Generates object files (*.o) for faster (re)compilation on low power systems + * Fix : cli : crash on some invalid inputs + + -- Yann Collet Sun, 28 Jun 2015 01:00:00 +0000 diff --git a/contrib/debian/compat b/contrib/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/contrib/debian/compat @@ -0,0 +1 @@ +7 diff --git a/contrib/debian/control b/contrib/debian/control new file mode 100644 index 0000000..ac3b460 --- /dev/null +++ b/contrib/debian/control @@ -0,0 +1,23 @@ +Source: liblz4 +Section: devel +Priority: optional +Maintainer: Evgeniy Polyakov +Build-Depends: + cmake (>= 2.6), + debhelper (>= 7.0.50~), + cdbs +Standards-Version: 3.8.0 +Homepage: http://www.lz4.org/ +Vcs-Git: git://github.com/lz4/lz4.git +Vcs-Browser: https://github.com/lz4/lz4 + +Package: liblz4 +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Extremely Fast Compression algorithm http://www.lz4.org + +Package: liblz4-dev +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Extremely Fast Compression algorithm http://www.lz4.org + Development files. diff --git a/contrib/debian/copyright b/contrib/debian/copyright new file mode 100644 index 0000000..18a7f48 --- /dev/null +++ b/contrib/debian/copyright @@ -0,0 +1,9 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: liblz4 +Upstream-Contact: Yann Collet +Source: https://github.com/lz4/lz4 + +Files: * +Copyright: (C) 2011+ Yann Collet +License: GPL-2+ + The full text of license: https://github.com/Cyan4973/lz4/blob/master/lib/LICENSE diff --git a/contrib/debian/dirs b/contrib/debian/dirs new file mode 100644 index 0000000..e772481 --- /dev/null +++ b/contrib/debian/dirs @@ -0,0 +1 @@ +usr/bin diff --git a/contrib/debian/docs b/contrib/debian/docs new file mode 100644 index 0000000..e69de29 diff --git a/contrib/debian/liblz4-dev.install b/contrib/debian/liblz4-dev.install new file mode 100644 index 0000000..3a02909 --- /dev/null +++ b/contrib/debian/liblz4-dev.install @@ -0,0 +1,2 @@ +usr/include/lz4* +usr/lib/liblz4.so diff --git a/contrib/debian/liblz4.install b/contrib/debian/liblz4.install new file mode 100644 index 0000000..e444956 --- /dev/null +++ b/contrib/debian/liblz4.install @@ -0,0 +1,2 @@ +usr/lib/liblz4.so.* +usr/bin/* diff --git a/contrib/debian/rules b/contrib/debian/rules new file mode 100755 index 0000000..748e68d --- /dev/null +++ b/contrib/debian/rules @@ -0,0 +1,8 @@ +#!/usr/bin/make -f + +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/cmake.mk + + +DEB_CMAKE_EXTRA_FLAGS := -DCMAKE_BUILD_TYPE=RelWithDebInfo ../cmake_unofficial + diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 7a4bac6..0000000 --- a/debian/changelog +++ /dev/null @@ -1,8 +0,0 @@ -liblz4 (0.131) unstable; urgency=low - - * New : Dos/DJGPP target, thanks to Louis Santillan (#114) - * Added : Example using lz4frame library, by Zbigniew Jędrzejewski-Szmek (#118) - * Changed: xxhash symbols are modified (namespace emulation) within liblz4 - - -- Yann Collet Sun, 28 Jun 2015 01:00:00 +0000 - diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 7f8f011..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -7 diff --git a/debian/control b/debian/control deleted file mode 100644 index 1a5a077..0000000 --- a/debian/control +++ /dev/null @@ -1,23 +0,0 @@ -Source: liblz4 -Section: devel -Priority: optional -Maintainer: Evgeniy Polyakov -Build-Depends: - cmake (>= 2.6), - debhelper (>= 7.0.50~), - cdbs -Standards-Version: 3.8.0 -Homepage: https://code.google.com/p/lz4/ -Vcs-Git: git://github.com/Cyan4973/lz4.git -Vcs-Browser: https://github.com/Cyan4973/lz4 - -Package: liblz4 -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Extremely Fast Compression algorithm http://www.lz4.org - -Package: liblz4-dev -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Extremely Fast Compression algorithm http://www.lz4.org - Development files. diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index da22555..0000000 --- a/debian/copyright +++ /dev/null @@ -1,9 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: liblz4 -Upstream-Contact: Yann Collet -Source: https://github.com/Cyan4973/lz4 - -Files: * -Copyright: (C) 2011+ Yann Collet -License: GPL-2+ - The full text of license: https://github.com/Cyan4973/lz4/blob/master/lib/LICENSE diff --git a/debian/dirs b/debian/dirs deleted file mode 100644 index e772481..0000000 --- a/debian/dirs +++ /dev/null @@ -1 +0,0 @@ -usr/bin diff --git a/debian/docs b/debian/docs deleted file mode 100644 index e69de29..0000000 diff --git a/debian/liblz4-dev.install b/debian/liblz4-dev.install deleted file mode 100644 index 3a02909..0000000 --- a/debian/liblz4-dev.install +++ /dev/null @@ -1,2 +0,0 @@ -usr/include/lz4* -usr/lib/liblz4.so diff --git a/debian/liblz4.install b/debian/liblz4.install deleted file mode 100644 index e444956..0000000 --- a/debian/liblz4.install +++ /dev/null @@ -1,2 +0,0 @@ -usr/lib/liblz4.so.* -usr/bin/* diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 748e68d..0000000 --- a/debian/rules +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/make -f - -include /usr/share/cdbs/1/rules/debhelper.mk -include /usr/share/cdbs/1/class/cmake.mk - - -DEB_CMAKE_EXTRA_FLAGS := -DCMAKE_BUILD_TYPE=RelWithDebInfo ../cmake_unofficial - diff --git a/programs/lz4io.c b/programs/lz4io.c index 7293d77..f90cb50 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -697,12 +697,12 @@ static unsigned long long LZ4IO_decodeLegacyStream(FILE* finput, FILE* foutput) /* Main Loop */ while (1) { int decodeSize; - size_t sizeCheck; unsigned int blockSize; /* Block Size */ - sizeCheck = fread(in_buff, 1, 4, finput); - if (sizeCheck==0) break; /* Nothing to read : file read is completed */ + { size_t const sizeCheck = fread(in_buff, 1, 4, finput); + if (sizeCheck == 0) break; /* Nothing to read : file read is completed */ + if (sizeCheck != 4) EXM_THROW(52, "Read error : cannot access block size "); } blockSize = LZ4IO_readLE32(in_buff); /* Convert to Little Endian */ if (blockSize > LZ4_COMPRESSBOUND(LEGACY_BLOCKSIZE)) { /* Cannot read next block : maybe new stream ? */ @@ -711,8 +711,8 @@ static unsigned long long LZ4IO_decodeLegacyStream(FILE* finput, FILE* foutput) } /* Read Block */ - sizeCheck = fread(in_buff, 1, blockSize, finput); - if (sizeCheck!=blockSize) EXM_THROW(52, "Read error : cannot access compressed block !"); + { size_t const sizeCheck = fread(in_buff, 1, blockSize, finput); + if (sizeCheck!=blockSize) EXM_THROW(52, "Read error : cannot access compressed block !"); } /* Decode Block */ decodeSize = LZ4_decompress_safe(in_buff, out_buff, blockSize, LEGACY_BLOCKSIZE); -- cgit v0.12 From 67500142c16972e8d15f71f74adda1ce966a7a35 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 1 Nov 2016 19:14:04 -0700 Subject: Clarified license (#115, #244) --- LICENSE | 15 +++ README.md | 2 +- examples/COPYING | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++ examples/README.md | 2 + lib/README.md | 33 ++++-- programs/README.md | 7 ++ 6 files changed, 390 insertions(+), 8 deletions(-) create mode 100644 LICENSE create mode 100644 examples/COPYING create mode 100644 programs/README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..df1edbc --- /dev/null +++ b/LICENSE @@ -0,0 +1,15 @@ +This repository uses 2 different licenses : +- all files in the `lib` directory use a BSD 2-Clause license +- all other files use a GPLv2 license, unless explicitly stated otherwise + +Relevant license is reminded at the top of each source file, +and with the presence of COPYING or LICENSE file. + +This model emphasizes the fact that +only files in the `lib` directory are designed to be included into 3rd party projects. + +Other files, such as those from `programs` or `examples` directory, +are not intended to be compiled outside of their context. +They can serve as source of inspiration, +but they should not be copy/pasted into 3rd party projects, +as this scenario is not supported. diff --git a/README.md b/README.md index 76a4607..753f11d 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ On the other end, a high compression derivative, LZ4_HC, is also provided, trading CPU time for improved compression ratio. All versions feature the same decompression speed. -LZ4 library is provided as open-source software using BSD license. +LZ4 library is provided as open-source software using BSD 2-Clause license. |Branch |Status | diff --git a/examples/COPYING b/examples/COPYING new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/examples/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/examples/README.md b/examples/README.md index 1b62d9e..74527d4 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,5 +1,7 @@ # LZ4 examples +All examples are GPL-v2 licensed. + ## Documents - [Streaming API Basics](streaming_api_basics.md) diff --git a/lib/README.md b/lib/README.md index f6ebf5e..f932d42 100644 --- a/lib/README.md +++ b/lib/README.md @@ -1,21 +1,40 @@ LZ4 - Library Files ================================ -The __lib__ directory contains several files, but you don't necessarily need them all. +All source material within __lib__ directory are BSD 2-Clause licensed. +See [LICENSE](LICENSE) for details. +The license is also repeated at the top of each source file. -To integrate fast LZ4 compression/decompression into your program, you basically just need "**lz4.c**" and "**lz4.h**". +The directory contains many files, but depending on project's objectives, +not all of them are necessary. -For more compression at the cost of compression speed (while preserving decompression speed), use **lz4hc** on top of regular lz4. `lz4hc` only provides compression functions. It also needs `lz4` to compile properly. +The minimum required is **`lz4.c`** and **`lz4.h`**, +which will provide the fast compression and decompression algorithm. -If you want to produce files or data streams compatible with `lz4` command line utility, use **lz4frame**. This library encapsulates lz4-compressed blocks into the [official interoperable frame format]. In order to work properly, lz4frame needs lz4 and lz4hc, and also **xxhash**, which provides error detection algorithm. -(_Advanced stuff_ : It's possible to hide xxhash symbols into a local namespace. This is what `liblz4` does, to avoid symbol duplication in case a user program would link to several libraries containing xxhash symbols.) +For more compression at the cost of compression speed, +the High Compression variant **lz4hc** is available. +It's necessary to add **`lz4hc.c`** and **`lz4hc.h`**. +The variant still depends on regular `lz4` source files. +In particular, the decompression is still provided by `lz4.c`. -A more complex "lz4frame_static.h" is also provided, although its usage is not recommended. It contains definitions which are not guaranteed to remain stable within future versions. Use for static linking ***only***. +In order to produce files or streams compatible with `lz4` command line utility, +it's necessary to encode lz4-compressed blocks using the [official interoperable frame format]. +This format is generated and decoded automatically by the **lz4frame** library. +In order to work properly, lz4frame needs lz4 and lz4hc, and also **xxhash**, +which provides error detection. +(_Advanced stuff_ : It's possible to hide xxhash symbols into a local namespace. +This is what `liblz4` does, to avoid symbol duplication +in case a user program would link to several libraries containing xxhash symbols.) -The other files are not source code. There are : +A more complex `lz4frame_static.h` is also provided. +It contains definitions which are not guaranteed to remain stable within future versions. +It must be used with static linking ***only***. + +Other files present in the directory are not source code. There are : - LICENSE : contains the BSD license text - Makefile : script to compile or install lz4 library (static or dynamic) - liblz4.pc.in : for pkg-config (make install) + - README.md : this file [official interoperable frame format]: ../lz4_Frame_format.md diff --git a/programs/README.md b/programs/README.md new file mode 100644 index 0000000..a952c2f --- /dev/null +++ b/programs/README.md @@ -0,0 +1,7 @@ +This directory `programs` contains source files +to generate `lz4` command line utility, +and many test tools, such as `fuzzer`, `fullbench` and such. + +All files in this directory are licensed under GPL-v2. +See [COPYING](COPYING) for details. +The text of the license is also included at the top of each source file. -- cgit v0.12 From 59adfd82d6c00c005a88ef5bdd405204d71d5729 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 1 Nov 2016 21:04:56 -0700 Subject: fix for ARM platform --- programs/lz4io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/lz4io.c b/programs/lz4io.c index f90cb50..492363f 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -125,10 +125,10 @@ static int g_displayLevel = 0; /* 0 : no display ; 1: errors ; 2 : + result + interaction + warnings ; 3 : + progression; 4 : + information */ #define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \ - if (((g_time - clock()) > refreshRate) || (g_displayLevel>=4)) \ + if (((clock_t)(g_time - clock()) > refreshRate) || (g_displayLevel>=4)) \ { g_time = clock(); DISPLAY(__VA_ARGS__); \ if (g_displayLevel>=4) fflush(stderr); } } -static const unsigned refreshRate = CLOCKS_PER_SEC / 6; +static const clock_t refreshRate = CLOCKS_PER_SEC / 6; static clock_t g_time = 0; -- cgit v0.12