summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrzemyslaw Skibinski <inikep@gmail.com>2016-11-15 08:43:59 (GMT)
committerPrzemyslaw Skibinski <inikep@gmail.com>2016-11-15 08:43:59 (GMT)
commitd84a80e668f1798663a041536f744d48fb8647c8 (patch)
tree33db4abff62e9a6ec43bd87e7d8cc7ee3c73e74c
parent9ad7508db0cfd5473ae722deab981cc9bbcafb79 (diff)
parent4c5c711b7a7553def6b400df9efed5e8381e8e87 (diff)
downloadlz4-d84a80e668f1798663a041536f744d48fb8647c8.zip
lz4-d84a80e668f1798663a041536f744d48fb8647c8.tar.gz
lz4-d84a80e668f1798663a041536f744d48fb8647c8.tar.bz2
Merge remote-tracking branch 'refs/remotes/lz4/dev' into dev
-rw-r--r--.travis.yml32
-rw-r--r--Makefile25
-rw-r--r--lib/Makefile4
-rw-r--r--lib/lz4.c8
-rw-r--r--lib/lz4.h20
-rw-r--r--lib/lz4hc.h6
-rw-r--r--programs/Makefile10
-rw-r--r--programs/lz4io.c3
-rw-r--r--tests/Makefile10
-rw-r--r--tests/frametest.c26
-rw-r--r--tests/fuzzer.c36
11 files changed, 89 insertions, 91 deletions
diff --git a/.travis.yml b/.travis.yml
index 4bef528..f4facad 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,21 +5,21 @@ matrix:
# OS X Mavericks
- os: osx
env: Ubu=OS_X_Mavericks Cmd='make -C tests test-lz4 CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion"' COMPILER=clang
-
+
# Container-based 12.04 LTS Server Edition 64 bit (doesn't support 32-bit includes)
- os: linux
sudo: false
env: Ubu=12.04cont Cmd='make -C tests test-lz4 test-lz4c test-fasttest test-fullbench' COMPILER=cc
-
+
- os: linux
sudo: false
env: Ubu=12.04cont Cmd='make -C tests test-frametest test-fuzzer' COMPILER=cc
-
+
- os: linux
sudo: false
- env: Ubu=12.04cont Cmd="make gpptest && make clean && make examples && make clean && make cmake && make clean && make travis-install && make clean && make clangtest" COMPILER=cc
-
-
+ env: Ubu=12.04cont Cmd="make gpptest-native && make clean && make examples && make clean && make cmake && make clean && make travis-install && make clean && make clangtest-native" COMPILER=cc
+
+
# 14.04 LTS Server Edition 64 bit
- env: Ubu=14.04 Cmd='make -C tests test-lz4c32 test-fullbench32 versionsTest' COMPILER=cc
dist: trusty
@@ -30,7 +30,7 @@ matrix:
- python3
- libc6-dev-i386
- gcc-multilib
-
+
- env: Ubu=14.04 Cmd='make -C tests test-frametest32 test-fuzzer32' COMPILER=cc
dist: trusty
sudo: required
@@ -39,7 +39,7 @@ matrix:
packages:
- libc6-dev-i386
- gcc-multilib
-
+
- env: Ubu=14.04 Cmd='make sanitize' COMPILER=clang
dist: trusty
sudo: required
@@ -47,7 +47,7 @@ matrix:
apt:
packages:
- valgrind
-
+
- env: Ubu=14.04 Cmd='make staticAnalyze' COMPILER=clang
dist: trusty
sudo: required
@@ -55,7 +55,7 @@ matrix:
apt:
packages:
- clang
-
+
- env: Ubu=14.04 Cmd='make platformTest CC=arm-linux-gnueabi-gcc QEMU_SYS=qemu-arm-static && make platformTest CC=aarch64-linux-gnu-gcc QEMU_SYS=qemu-aarch64-static' COMPILER=arm-linux-gnueabi-gcc
dist: trusty
sudo: required
@@ -65,10 +65,10 @@ matrix:
- qemu-system-arm
- qemu-user-static
- gcc-arm-linux-gnueabi
- - libc6-dev-armel-cross
+ - libc6-dev-armel-cross
- gcc-aarch64-linux-gnu
- libc6-dev-arm64-cross
-
+
- env: Ubu=14.04 Cmd='make platformTest CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc-static && make platformTest CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc64-static MOREFLAGS=-m64' COMPILER=powerpc-linux-gnu-gcc
dist: trusty
sudo: required
@@ -78,7 +78,7 @@ matrix:
- qemu-system-ppc
- qemu-user-static
- gcc-powerpc-linux-gnu
-
+
- env: Ubu=14.04 Cmd='make c_standards && make -C tests test-lz4 test-mem' COMPILER=cc
dist: trusty
sudo: required
@@ -86,7 +86,7 @@ matrix:
apt:
packages:
- valgrind
-
+
- env: Ubu=14.04 Cmd='make -C tests test-lz4 test-lz4c32 CC=gcc-5 MOREFLAGS=-Werror' COMPILER=gcc-5
dist: trusty
sudo: required
@@ -99,7 +99,7 @@ matrix:
- gcc-multilib
- gcc-5
- gcc-5-multilib
-
+
- env: Ubu=14.04 Cmd='make c_standards CC=gcc-6 && make -C tests test-lz4 CC=gcc-6 MOREFLAGS=-Werror' COMPILER=gcc-6
dist: trusty
sudo: required
@@ -109,7 +109,7 @@ matrix:
- ubuntu-toolchain-r-test
packages:
- gcc-6
-
+
- env: Ubu=14.04 Cmd='make -C tests test-lz4 CC=clang-3.8' COMPILER=clang-3.8
dist: trusty
sudo: required
diff --git a/Makefile b/Makefile
index e92ae8d..c6454b0 100644
--- a/Makefile
+++ b/Makefile
@@ -93,7 +93,15 @@ test:
clangtest: clean
clang -v
- CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) all CC=clang
+ @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(LZ4DIR) all CC=clang
+ @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(PRGDIR) all CC=clang
+ @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(TESTDIR) all CC=clang
+
+clangtest-native: clean
+ clang -v
+ @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(LZ4DIR) all CC=clang
+ @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(PRGDIR) native CC=clang
+ @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(TESTDIR) native CC=clang
sanitize: clean
CFLAGS="-O3 -g -fsanitize=undefined" $(MAKE) test CC=clang FUZZER_TIME="-T1mn" NB_LOOPS=-i1
@@ -105,8 +113,8 @@ platformTest: clean
@echo "\n ---- test lz4 with $(CC) compiler ----"
@$(CC) -v
CFLAGS="-O3 -Werror" $(MAKE) -C $(LZ4DIR) all
- CFLAGS="-O3 -Werror -static" $(MAKE) -C $(PRGDIR) bins
- CFLAGS="-O3 -Werror -static" $(MAKE) -C $(TESTDIR) bins
+ CFLAGS="-O3 -Werror -static" $(MAKE) -C $(PRGDIR) native
+ CFLAGS="-O3 -Werror -static" $(MAKE) -C $(TESTDIR) native
$(MAKE) -C $(TESTDIR) test-platform
versionsTest: clean
@@ -135,7 +143,16 @@ cmake:
@cd contrib/cmake_unofficial; cmake $(CMAKE_PARAMS) CMakeLists.txt; $(MAKE)
gpptest: clean
- CC=g++ $(MAKE) all CFLAGS="-O3 -I../lib -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
+ g++ -v
+ CC=g++ $(MAKE) -C $(LZ4DIR) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
+ CC=g++ $(MAKE) -C $(PRGDIR) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
+ CC=g++ $(MAKE) -C $(TESTDIR) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
+
+gpptest-native: clean
+ g++ -v
+ CC=g++ $(MAKE) -C $(LZ4DIR) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
+ CC=g++ $(MAKE) -C $(PRGDIR) native CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
+ CC=g++ $(MAKE) -C $(TESTDIR) native CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
c_standards: clean
$(MAKE) all MOREFLAGS="-std=gnu90 -Werror"
diff --git a/lib/Makefile b/lib/Makefile
index 6551dd9..d098846 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -48,7 +48,7 @@ CPPFLAGS= -DXXH_NAMESPACE=LZ4_
CFLAGS ?= -O3
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef \
- -Wpointer-arith # -Wstrict-aliasing=1
+ -Wpointer-arith -Wstrict-aliasing=1
CFLAGS += $(MOREFLAGS)
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
@@ -85,7 +85,7 @@ endif
liblz4: *.c
@echo compiling dynamic library $(LIBVER)
-ifneq (,$(filter Windows%,$(OS)))
+ifneq (,$(filter Windows%,$(OS)))
@$(CC) $(FLAGS) -DLZ4_DLL_EXPORT=1 -shared $^ -o $@.dll
dlltool -D liblz4.dll -d liblz4.def -l liblz4.dll.a
else
diff --git a/lib/lz4.c b/lib/lz4.c
index 276c15a..89e3a0f 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -159,7 +159,7 @@ static unsigned LZ4_64bits(void) { return sizeof(void*)==8; }
static unsigned LZ4_isLittleEndian(void)
{
- const union { U32 i; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */
+ const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */
return one.c[0];
}
@@ -1113,7 +1113,7 @@ FORCE_INLINE int LZ4_decompress_generic(
const BYTE* const lowLimit = lowPrefix - dictSize;
const BYTE* const dictEnd = (const BYTE*)dictStart + dictSize;
- const unsigned dec32table[] = {4, 1, 2, 1, 4, 4, 4, 4};
+ const unsigned dec32table[] = {0, 1, 2, 1, 4, 4, 4, 4};
const int dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3};
const int safeDecode = (endOnInput==endOnInputSize);
@@ -1127,13 +1127,12 @@ FORCE_INLINE int LZ4_decompress_generic(
/* Main Loop : decode sequences */
while (1) {
- unsigned token;
size_t length;
const BYTE* match;
size_t offset;
/* get literal length */
- token = *ip++;
+ unsigned const token = *ip++;
if ((length=(token>>ML_BITS)) == RUN_MASK) {
unsigned s;
do {
@@ -1168,6 +1167,7 @@ FORCE_INLINE int LZ4_decompress_generic(
offset = LZ4_readLE16(ip); ip+=2;
match = op - offset;
if ((checkOffset) && (unlikely(match < lowLimit))) goto _output_error; /* Error : offset outside buffers */
+ LZ4_write32(op, (U32)offset); /* costs ~1%; silence an msan warning when offset==0 */
/* get matchlength */
length = token & ML_MASK;
diff --git a/lib/lz4.h b/lib/lz4.h
index 17abd52..c1ea91a 100644
--- a/lib/lz4.h
+++ b/lib/lz4.h
@@ -1,7 +1,7 @@
/*
- LZ4 - Fast LZ compression algorithm
- Header File
- Copyright (C) 2011-2016, Yann Collet.
+ * LZ4 - Fast LZ compression algorithm
+ * Header File
+ * Copyright (C) 2011-2016, Yann Collet.
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
@@ -226,7 +226,7 @@ LZ4LIB_API int LZ4_decompress_safe_partial (const char* source, char* dest, int
/*-*********************************************
* Streaming Compression Functions
***********************************************/
-typedef struct LZ4_stream_s LZ4_stream_t; /* incomplete type (defined later) */
+typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
/*! LZ4_createStream() and LZ4_freeStream() :
* LZ4_createStream() will allocate and initialize an `LZ4_stream_t` structure.
@@ -272,7 +272,7 @@ LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int dict
* Streaming Decompression Functions
* Bufferless synchronous API
************************************************/
-typedef struct LZ4_streamDecode_s LZ4_streamDecode_t; /* incomplete type (defined later) */
+typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* incomplete type (defined later) */
/* creation / destruction of streaming decompression tracking structure */
LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void);
@@ -378,11 +378,9 @@ typedef struct {
*/
#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4)
#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(unsigned long long))
-struct LZ4_stream_s {
- union {
+union LZ4_stream_u {
unsigned long long table[LZ4_STREAMSIZE_U64];
LZ4_stream_t_internal internal_donotuse;
- };
} ; /* previously typedef'd to LZ4_stream_t */
@@ -396,11 +394,9 @@ struct LZ4_stream_s {
*/
#define LZ4_STREAMDECODESIZE_U64 4
#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
-struct LZ4_streamDecode_s {
- union {
+union LZ4_streamDecode_u {
unsigned long long table[LZ4_STREAMDECODESIZE_U64];
LZ4_streamDecode_t_internal internal_donotuse;
- };
} ; /* previously typedef'd to LZ4_streamDecode_t */
@@ -423,7 +419,7 @@ struct LZ4_streamDecode_s {
# elif defined(_MSC_VER)
# define LZ4_DEPRECATED(message) __declspec(deprecated(message))
# else
-# warning "WARNING: You need to implement LZ4_DEPRECATED for this compiler"
+# pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler")
# define LZ4_DEPRECATED(message)
# endif
#endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
diff --git a/lib/lz4hc.h b/lib/lz4hc.h
index 7adc8fa..d8ac3c0 100644
--- a/lib/lz4hc.h
+++ b/lib/lz4hc.h
@@ -83,7 +83,7 @@ LZ4LIB_API int LZ4_sizeofStateHC(void);
* Streaming Compression
* Bufferless synchronous API
**************************************/
- typedef struct LZ4_streamHC_s LZ4_streamHC_t; /* incomplete type (defined later) */
+ typedef union LZ4_streamHC_u LZ4_streamHC_t; /* incomplete type (defined later) */
/*! LZ4_createStreamHC() and LZ4_freeStreamHC() :
* These functions create and release memory for LZ4 HC streaming state.
@@ -176,11 +176,9 @@ typedef struct
#define LZ4_STREAMHCSIZE 262192
#define LZ4_STREAMHCSIZE_SIZET (LZ4_STREAMHCSIZE / sizeof(size_t))
-struct LZ4_streamHC_s {
- union {
+union LZ4_streamHC_u {
size_t table[LZ4_STREAMHCSIZE_SIZET];
LZ4HC_CCtx_internal internal_donotuse;
- };
}; /* previously typedef'd to LZ4_streamHC_t */
/*
LZ4_streamHC_t :
diff --git a/programs/Makefile b/programs/Makefile
index 5c2bdcd..de18f78 100644
--- a/programs/Makefile
+++ b/programs/Makefile
@@ -34,8 +34,10 @@ BINDIR := $(PREFIX)/bin
MANDIR := $(PREFIX)/share/man/man1
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 -Wpointer-arith
+CFLAGS ?= -O3 # allows custom optimization flags. For example : CFLAGS="-O2 -g" make
+CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \
+ -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \
+ -Wpointer-arith -Wstrict-aliasing=1
CFLAGS += $(MOREFLAGS)
CPPFLAGS:= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_
FLAGS := $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
@@ -54,9 +56,9 @@ default: lz4
m32: lz4c32
-bins: lz4 lz4c
+native: lz4 lz4c
-all: bins m32
+all: native m32
lz4: $(LZ4DIR)/lz4.o $(LZ4DIR)/lz4hc.o $(LZ4DIR)/lz4frame.o $(LZ4DIR)/xxhash.o bench.o lz4io.o lz4cli.o datagen.o
$(CC) $(FLAGS) $^ -o $@$(EXT)
diff --git a/programs/lz4io.c b/programs/lz4io.c
index 00576c2..5a366a4 100644
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -824,7 +824,8 @@ static unsigned long long LZ4IO_decompressLZ4F(dRess_t ress, FILE* srcFile, FILE
/* Write Block */
if (decodedBytes) {
- if (!g_testMode) storedSkips = LZ4IO_fwriteSparse(dstFile, ress.dstBuffer, decodedBytes, storedSkips);
+ if (!g_testMode)
+ storedSkips = LZ4IO_fwriteSparse(dstFile, ress.dstBuffer, decodedBytes, storedSkips);
filesize += decodedBytes;
DISPLAYUPDATE(2, "\rDecompressed : %u MB ", (unsigned)(filesize>>20));
}
diff --git a/tests/Makefile b/tests/Makefile
index 4481392..a11cf9b 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -42,7 +42,9 @@ TESTDIR := versionsTest
PYTHON ?= python3
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 += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum \
+ -Wdeclaration-after-statement -Wstrict-prototypes \
+ -Wpointer-arith -Wstrict-aliasing=1
CFLAGS += $(MOREFLAGS)
CPPFLAGS:= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_
FLAGS := $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
@@ -62,13 +64,13 @@ FUZZER_TIME := -T3mn
NB_LOOPS ?= -i1
-default: bins
+default: native
m32: fullbench32 fuzzer32 frametest32
-bins: fullbench fuzzer frametest datagen fasttest
+native: fullbench fuzzer frametest datagen fasttest
-all: bins m32
+all: native m32
lz4:
diff --git a/tests/frametest.c b/tests/frametest.c
index d4afc58..a99728f 100644
--- a/tests/frametest.c
+++ b/tests/frametest.c
@@ -139,10 +139,10 @@ unsigned int FUZ_rand(unsigned int* src)
#define FUZ_RAND15BITS (FUZ_rand(seed) & 0x7FFF)
#define FUZ_RANDLENGTH ( (FUZ_rand(seed) & 3) ? (FUZ_rand(seed) % 15) : (FUZ_rand(seed) % 510) + 15)
-static void FUZ_fillCompressibleNoiseBuffer(void* buffer, unsigned bufferSize, double proba, U32* seed)
+static void FUZ_fillCompressibleNoiseBuffer(void* buffer, size_t bufferSize, double proba, U32* seed)
{
BYTE* BBuffer = (BYTE*)buffer;
- unsigned pos = 0;
+ size_t pos = 0;
U32 P32 = (U32)(32768 * proba);
/* First Byte */
@@ -152,20 +152,18 @@ static void FUZ_fillCompressibleNoiseBuffer(void* buffer, unsigned bufferSize, d
/* Select : Literal (noise) or copy (within 64K) */
if (FUZ_RAND15BITS < P32) {
/* Copy (within 64K) */
- unsigned match, end;
- unsigned length = FUZ_RANDLENGTH + 4;
- unsigned offset = FUZ_RAND15BITS + 1;
- if (offset > pos) offset = pos;
- if (pos + length > bufferSize) length = bufferSize - pos;
- match = pos - offset;
- end = pos + length;
+ size_t const lengthRand = FUZ_RANDLENGTH + 4;
+ size_t const length = MIN(lengthRand, bufferSize - pos);
+ size_t const end = pos + length;
+ size_t const offsetRand = FUZ_RAND15BITS + 1;
+ size_t const offset = MIN(offsetRand, pos);
+ size_t match = pos - offset;
while (pos < end) BBuffer[pos++] = BBuffer[match++];
} else {
/* Literal (noise) */
- unsigned end;
- unsigned length = FUZ_RANDLENGTH;
- if (pos + length > bufferSize) length = bufferSize - pos;
- end = pos + length;
+ size_t const lengthRand = FUZ_RANDLENGTH + 4;
+ size_t const length = MIN(lengthRand, bufferSize - pos);
+ size_t const end = pos + length;
while (pos < end) BBuffer[pos++] = (BYTE)(FUZ_rand(seed) >> 5);
}
}
@@ -606,7 +604,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
/* main fuzzer test loop */
for ( ; (testNb < nbTests) || (clockDuration > FUZ_GetClockSpan(startClock)) ; testNb++) {
U32 randState = coreRand ^ prime1;
- unsigned const srcBits = (FUZ_rand(&randState) % (FUZ_highbit(srcDataLength-1) - 1)) + 1;
+ unsigned const srcBits = (FUZ_rand(&randState) % (FUZ_highbit((U32)(srcDataLength-1)) - 1)) + 1;
size_t const srcSize = (FUZ_rand(&randState) & ((1<<srcBits)-1)) + 1;
size_t const srcStartId = FUZ_rand(&randState) % (srcDataLength - srcSize);
const BYTE* const srcStart = (const BYTE*)srcBuffer + srcStartId;
diff --git a/tests/fuzzer.c b/tests/fuzzer.c
index 4d8d8dd..301b01a 100644
--- a/tests/fuzzer.c
+++ b/tests/fuzzer.c
@@ -300,24 +300,8 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
}
/* move to startCycle */
- for (cycleNb = 0; cycleNb < startCycle; cycleNb++) {
- U32 randState = FUZ_rand(&coreRandState) ^ PRIME3;
-
- if (0) { /* some problems can be related to dictionary re-use; in this case, enable this loop */
- int const blockSize = FUZ_rand(&randState) % FUZ_MAX_BLOCK_SIZE;
- int const blockStart = FUZ_rand(&randState) % (COMPRESSIBLE_NOISE_LENGTH - blockSize);
- int const dictSizeRand = FUZ_rand(&randState) % FUZ_MAX_DICT_SIZE;
- int const dictSize = MIN(dictSizeRand, blockStart);
- char* const block = ((char*)CNBuffer) + blockStart;
- const char* const dict = block - dictSize;
- FUZ_displayUpdate(cycleNb);
- LZ4_loadDict(&LZ4dict, dict, dictSize);
- LZ4_compress_fast_continue(&LZ4dict, block, compressedBuffer, blockSize, compressedBufferSize, 1);
- LZ4_loadDict(&LZ4dict, dict, dictSize);
- LZ4_compress_fast_continue(&LZ4dict, block, compressedBuffer, blockSize, compressedBufferSize, 1);
- LZ4_loadDict(&LZ4dict, dict, dictSize);
- LZ4_compress_fast_continue(&LZ4dict, block, compressedBuffer, blockSize, compressedBufferSize, 1);
- } }
+ for (cycleNb = 0; cycleNb < startCycle; cycleNb++)
+ (void) FUZ_rand(&coreRandState); /* sync coreRandState */
/* Main test loop */
for (cycleNb = startCycle;
@@ -375,23 +359,23 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
/* Test compression HC */
FUZ_DISPLAYTEST;
- ret = LZ4_compress_HC(block, compressedBuffer, blockSize, compressedBufferSize, 9);
+ ret = LZ4_compress_HC(block, compressedBuffer, blockSize, (int)compressedBufferSize, 9);
FUZ_CHECKTEST(ret==0, "LZ4_compressHC() failed");
HCcompressedSize = ret;
/* Test compression HC using external state */
FUZ_DISPLAYTEST;
- ret = LZ4_compress_HC_extStateHC(stateLZ4HC, block, compressedBuffer, blockSize, compressedBufferSize, 9);
+ ret = LZ4_compress_HC_extStateHC(stateLZ4HC, block, compressedBuffer, blockSize, (int)compressedBufferSize, 9);
FUZ_CHECKTEST(ret==0, "LZ4_compressHC_withStateHC() failed");
/* Test compression using external state */
FUZ_DISPLAYTEST;
- ret = LZ4_compress_fast_extState(stateLZ4, block, compressedBuffer, blockSize, compressedBufferSize, 9);
+ ret = LZ4_compress_fast_extState(stateLZ4, block, compressedBuffer, blockSize, (int)compressedBufferSize, 9);
FUZ_CHECKTEST(ret==0, "LZ4_compress_withState() failed");
/* Test compression */
FUZ_DISPLAYTEST;
- ret = LZ4_compress_default(block, compressedBuffer, blockSize, compressedBufferSize);
+ ret = LZ4_compress_default(block, compressedBuffer, blockSize, (int)compressedBufferSize);
FUZ_CHECKTEST(ret==0, "LZ4_compress() failed");
compressedSize = ret;
@@ -531,8 +515,8 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
FUZ_DISPLAYTEST;
{ LZ4_stream_t LZ4_stream;
LZ4_resetStream(&LZ4_stream);
- LZ4_compress_fast_continue (&LZ4_stream, dict, compressedBuffer, dictSize, compressedBufferSize, 1); /* Just to fill hash tables */
- blockContinueCompressedSize = LZ4_compress_fast_continue (&LZ4_stream, block, compressedBuffer, blockSize, compressedBufferSize, 1);
+ LZ4_compress_fast_continue (&LZ4_stream, dict, compressedBuffer, dictSize, (int)compressedBufferSize, 1); /* Just to fill hash tables */
+ blockContinueCompressedSize = LZ4_compress_fast_continue (&LZ4_stream, block, compressedBuffer, blockSize, (int)compressedBufferSize, 1);
FUZ_CHECKTEST(blockContinueCompressedSize==0, "LZ4_compress_continue failed");
}
@@ -561,7 +545,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
dict -= (FUZ_rand(&randState) & 0xF) + 1; /* Separation, so it is an ExtDict */
if (dict < (char*)CNBuffer) dict = (char*)CNBuffer;
LZ4_loadDict(&LZ4dict, dict, dictSize);
- blockContinueCompressedSize = LZ4_compress_fast_continue(&LZ4dict, block, compressedBuffer, blockSize, compressedBufferSize, 1);
+ blockContinueCompressedSize = LZ4_compress_fast_continue(&LZ4dict, block, compressedBuffer, blockSize, (int)compressedBufferSize, 1);
FUZ_CHECKTEST(blockContinueCompressedSize==0, "LZ4_compress_continue failed");
FUZ_DISPLAYTEST;
@@ -620,7 +604,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
if (dict < (char*)CNBuffer) dict = (char*)CNBuffer;
LZ4_resetStreamHC (&LZ4dictHC, FUZ_rand(&randState) & 0x7);
LZ4_loadDictHC(&LZ4dictHC, dict, dictSize);
- blockContinueCompressedSize = LZ4_compress_HC_continue(&LZ4dictHC, block, compressedBuffer, blockSize, compressedBufferSize);
+ blockContinueCompressedSize = LZ4_compress_HC_continue(&LZ4dictHC, block, compressedBuffer, blockSize, (int)compressedBufferSize);
FUZ_CHECKTEST(blockContinueCompressedSize==0, "LZ4_compressHC_continue failed");
FUZ_DISPLAYTEST;