summaryrefslogtreecommitdiffstats
path: root/programs
diff options
context:
space:
mode:
authorinikep <inikep@gmail.com>2016-09-03 06:10:16 (GMT)
committerinikep <inikep@gmail.com>2016-09-03 06:10:16 (GMT)
commit58a1616d7b272e624f78e713fcd37172f845f576 (patch)
tree579df140753d421293418ba6b112c4d68df0e085 /programs
parentc77fdb44f101c81ef7740d67fdf77a5f065bc04f (diff)
parent28f98647e3349a4a0a9c8975199aa89f2a02f6b9 (diff)
downloadlz4-58a1616d7b272e624f78e713fcd37172f845f576.zip
lz4-58a1616d7b272e624f78e713fcd37172f845f576.tar.gz
lz4-58a1616d7b272e624f78e713fcd37172f845f576.tar.bz2
Merge remote-tracking branch 'refs/remotes/Cyan4973/dev' into dev
# Conflicts: # programs/Makefile
Diffstat (limited to 'programs')
-rw-r--r--programs/Makefile8
-rw-r--r--programs/bench.c6
-rw-r--r--programs/frametest.c79
-rw-r--r--programs/fullbench.c351
-rw-r--r--programs/fuzzer.c72
-rw-r--r--programs/lz4cli.c69
6 files changed, 151 insertions, 434 deletions
diff --git a/programs/Makefile b/programs/Makefile
index 372d7b0..290361f 100644
--- a/programs/Makefile
+++ b/programs/Makefile
@@ -34,18 +34,16 @@
# datagen : generates synthetic data samples for tests & benchmarks
# ##########################################################################
-RELEASE ?= r132
-
+DESTDIR ?=
+PREFIX ?= /usr/local
BINDIR := $(PREFIX)/bin
MANDIR := $(PREFIX)/share/man/man1
LZ4DIR := ../lib
-DESTDIR ?=
-PREFIX ?= /usr/local
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_ -DLZ4_VERSION=\"$(RELEASE)\"
+CPPFLAGS:= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_
FLAGS := $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
diff --git a/programs/bench.c b/programs/bench.c
index 81118c0..5952f47 100644
--- a/programs/bench.c
+++ b/programs/bench.c
@@ -282,7 +282,7 @@ int BMK_benchLevel(const char** fileNamesTable, int nbFiles, int cLevel)
/* Fill input buffer */
DISPLAY("Loading %s... \r", inFileName);
- if (strlen(inFileName)>16) inFileName += strlen(inFileName)-16; /* can only display 16 characters */
+ if (strlen(inFileName)>16) inFileName += strlen(inFileName)-16; /* can only display 16 characters */
readSize = fread(orig_buff, 1, benchedSize, inFile);
fclose(inFile);
@@ -398,11 +398,11 @@ int BMK_benchFiles(const char** fileNamesTable, int nbFiles, int cLevel, int cLe
if (cLevelLast > LZ4HC_MAX_CLEVEL) cLevelLast = LZ4HC_MAX_CLEVEL;
if (cLevelLast < cLevel) cLevelLast = cLevel;
- DISPLAY("Benchmarking levels from %d to %d\n", cLevel, cLevelLast);
+ if (cLevelLast > cLevel) DISPLAY("Benchmarking levels from %d to %d\n", cLevel, cLevelLast);
for (i=cLevel; i<=cLevelLast; i++) {
res = BMK_benchLevel(fileNamesTable, nbFiles, i);
if (res != 0) break;
}
-
+
return res;
}
diff --git a/programs/frametest.c b/programs/frametest.c
index 1aa6bc7..d9f2566 100644
--- a/programs/frametest.c
+++ b/programs/frametest.c
@@ -31,11 +31,6 @@
# pragma warning(disable : 4146) /* disable: C4146: minus unsigned expression */
#endif
-/* S_ISREG & gettimeofday() are not supported by MSVC */
-#if defined(_MSC_VER) || defined(_WIN32)
-# define FUZ_LEGACY_TIMER 1
-#endif
-
/*-************************************
* Includes
@@ -43,17 +38,12 @@
#include <stdlib.h> /* malloc, free */
#include <stdio.h> /* fprintf */
#include <string.h> /* strcmp */
+#include <time.h> /* clock_t, clock(), CLOCKS_PER_SEC */
#include "lz4frame_static.h"
+#include "lz4.h" /* LZ4_VERSION_STRING */
#define XXH_STATIC_LINKING_ONLY
#include "xxhash.h" /* XXH64 */
-/* Use ftime() if gettimeofday() is not available on your target */
-#if defined(FUZ_LEGACY_TIMER)
-# include <sys/timeb.h> /* timeb, ftime */
-#else
-# include <sys/time.h> /* gettimeofday */
-#endif
-
/*-************************************
* Basic Types
@@ -88,10 +78,6 @@ static void FUZ_writeLE32 (void* dstVoidPtr, U32 value32)
/*-************************************
* Constants
**************************************/
-#ifndef LZ4_VERSION
-# define LZ4_VERSION ""
-#endif
-
#define LZ4F_MAGIC_SKIPPABLE_START 0x184D2A50U
#define KB *(1U<<10)
@@ -112,11 +98,11 @@ static const U32 prime2 = 2246822519U;
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
#define DISPLAYLEVEL(l, ...) if (displayLevel>=l) { DISPLAY(__VA_ARGS__); }
#define DISPLAYUPDATE(l, ...) if (displayLevel>=l) { \
- if ((FUZ_GetMilliSpan(g_time) > refreshRate) || (displayLevel>=4)) \
- { g_time = FUZ_GetMilliStart(); DISPLAY(__VA_ARGS__); \
+ if ((FUZ_GetClockSpan(g_clockTime) > refreshRate) || (displayLevel>=4)) \
+ { g_clockTime = clock(); DISPLAY(__VA_ARGS__); \
if (displayLevel>=4) fflush(stdout); } }
-static const U32 refreshRate = 150;
-static U32 g_time = 0;
+static const clock_t refreshRate = CLOCKS_PER_SEC / 6;
+static clock_t g_clockTime = 0;
/*-***************************************
@@ -131,42 +117,13 @@ static U32 pause = 0;
/*-*******************************************************
* Fuzzer functions
*********************************************************/
-#if defined(FUZ_LEGACY_TIMER)
-
-static U32 FUZ_GetMilliStart(void)
+static clock_t FUZ_GetClockSpan(clock_t clockStart)
{
- struct timeb tb;
- U32 nCount;
- ftime( &tb );
- nCount = (U32) (((tb.time & 0xFFFFF) * 1000) + tb.millitm);
- return nCount;
+ return clock() - clockStart; /* works even if overflow; max span ~ 30 mn */
}
-#else
-static U32 FUZ_GetMilliStart(void)
-{
- struct timeval tv;
- U32 nCount;
- gettimeofday(&tv, NULL);
- nCount = (U32) (tv.tv_usec/1000 + (tv.tv_sec & 0xfffff) * 1000);
- return nCount;
-}
-
-#endif
-
-
-static U32 FUZ_GetMilliSpan(U32 nTimeStart)
-{
- U32 nCurrent = FUZ_GetMilliStart();
- U32 nSpan = nCurrent - nTimeStart;
- if (nTimeStart > nCurrent)
- nSpan += 0x100000 * 1000;
- return nSpan;
-}
-
-
-# define FUZ_rotl32(x,r) ((x << r) | (x >> (32 - r)))
+#define FUZ_rotl32(x,r) ((x << r) | (x >> (32 - r)))
unsigned int FUZ_rand(unsigned int* src)
{
U32 rand32 = *src;
@@ -586,7 +543,7 @@ static void locateBuffDiff(const void* buff1, const void* buff2, size_t size, un
static const U32 srcDataLength = 9 MB; /* needs to be > 2x4MB to test large blocks */
-int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressibility, U32 duration)
+int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressibility, U32 duration_s)
{
unsigned testResult = 0;
unsigned testNb = 0;
@@ -597,14 +554,12 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
LZ4F_decompressionContext_t dCtx = NULL;
LZ4F_compressionContext_t cCtx = NULL;
size_t result;
- const U32 startTime = FUZ_GetMilliStart();
+ clock_t const startClock = clock();
+ clock_t const clockDuration = duration_s * CLOCKS_PER_SEC;
XXH64_state_t xxh64;
# define CHECK(cond, ...) if (cond) { DISPLAY("Error => "); DISPLAY(__VA_ARGS__); \
DISPLAY(" (seed %u, test nb %u) \n", seed, testNb); goto _output_error; }
- /* Init */
- duration *= 1000;
-
/* Create buffers */
result = LZ4F_createDecompressionContext(&dCtx, LZ4F_VERSION);
CHECK(LZ4F_isError(result), "Allocation failed (error %i)", (int)result);
@@ -622,7 +577,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
for (testNb =0; (testNb < startTest); testNb++) (void)FUZ_rand(&coreRand); // sync randomizer
/* main fuzzer test loop */
- for ( ; (testNb < nbTests) || (duration > FUZ_GetMilliSpan(startTime)) ; testNb++) {
+ for ( ; (testNb < nbTests) || (clockDuration > FUZ_GetClockSpan(startClock)) ; testNb++) {
U32 randState = coreRand ^ prime1;
unsigned BSId = 4 + (FUZ_rand(&randState) & 3);
unsigned BMId = FUZ_rand(&randState) & 1;
@@ -893,9 +848,13 @@ int main(int argc, char** argv)
}
/* Get Seed */
- printf("Starting lz4frame tester (%i-bits, %s)\n", (int)(sizeof(size_t)*8), LZ4_VERSION);
+ printf("Starting lz4frame tester (%i-bits, %s)\n", (int)(sizeof(size_t)*8), LZ4_VERSION_STRING);
- if (!seedset) seed = FUZ_GetMilliStart() % 10000;
+ if (!seedset) {
+ time_t const t = time(NULL);
+ U32 const h = XXH32(&t, sizeof(t), 1);
+ seed = h % 10000;
+ }
printf("Seed = %u\n", seed);
if (proba!=FUZ_COMPRESSIBILITY_DEFAULT) printf("Compressibility : %i%%\n", proba);
diff --git a/programs/fullbench.c b/programs/fullbench.c
index 0d08a40..ab6bba1 100644
--- a/programs/fullbench.c
+++ b/programs/fullbench.c
@@ -52,13 +52,7 @@
#include <sys/types.h> /* stat64 */
#include <sys/stat.h> /* stat64 */
#include <string.h> /* strcmp */
-
-/* Use ftime() if gettimeofday() is not available on your target */
-#if defined(BMK_LEGACY_TIMER)
-# include <sys/timeb.h> /* timeb, ftime */
-#else
-# include <sys/time.h> /* gettimeofday */
-#endif
+#include <time.h> /* clock_t, clock(), CLOCKS_PER_SEC */
#include "lz4.h"
#include "lz4hc.h"
@@ -99,14 +93,11 @@
* Constants
**************************************/
#define PROGRAM_DESCRIPTION "LZ4 speed analyzer"
-#ifndef LZ4_VERSION
-# define LZ4_VERSION ""
-#endif
#define AUTHOR "Yann Collet"
-#define WELCOME_MESSAGE "*** %s %s %i-bits, by %s (%s) ***\n", PROGRAM_DESCRIPTION, LZ4_VERSION, (int)(sizeof(void*)*8), AUTHOR, __DATE__
+#define WELCOME_MESSAGE "*** %s v%s %i-bits, by %s ***\n", PROGRAM_DESCRIPTION, LZ4_VERSION_STRING, (int)(sizeof(void*)*8), AUTHOR
#define NBLOOPS 6
-#define TIMELOOP 2500
+#define TIMELOOP (CLOCKS_PER_SEC * 25 / 10)
#define KB *(1 <<10)
#define MB *(1 <<20)
@@ -173,43 +164,9 @@ static void BMK_setPause(void)
/*********************************************************
* Private functions
*********************************************************/
-
-#if defined(BMK_LEGACY_TIMER)
-
-static int BMK_GetMilliStart(void)
-{
- /* Based on Legacy ftime()
- * Rolls over every ~ 12.1 days (0x100000/24/60/60)
- * Use GetMilliSpan to correct for rollover */
- struct timeb tb;
- int nCount;
- ftime( &tb );
- nCount = (int) (tb.millitm + (tb.time & 0xfffff) * 1000);
- return nCount;
-}
-
-#else
-
-static int BMK_GetMilliStart(void)
+static clock_t BMK_GetClockSpan( clock_t clockStart )
{
- /* Based on newer gettimeofday()
- * Use GetMilliSpan to correct for rollover */
- struct timeval tv;
- int nCount;
- gettimeofday(&tv, NULL);
- nCount = (int) (tv.tv_usec/1000 + (tv.tv_sec & 0xfffff) * 1000);
- return nCount;
-}
-
-#endif
-
-
-static int BMK_GetMilliSpan( int nTimeStart )
-{
- int nSpan = BMK_GetMilliStart() - nTimeStart;
- if ( nSpan < 0 )
- nSpan += 0x100000 * 1000;
- return nSpan;
+ return clock() - clockStart; /* works even if overflow; max span ~30 mn */
}
@@ -222,8 +179,7 @@ static size_t BMK_findMaxMem(U64 requiredMem)
requiredMem += 2*step;
if (requiredMem > MAX_MEM) requiredMem = MAX_MEM;
- while (!testmem)
- {
+ while (!testmem) {
if (requiredMem > step) requiredMem -= step;
else requiredMem >>= 1;
testmem = (BYTE*) malloc ((size_t)requiredMem);
@@ -238,7 +194,7 @@ static size_t BMK_findMaxMem(U64 requiredMem)
}
-static U64 BMK_GetFileSize(char* infilename)
+static U64 BMK_GetFileSize(const char* infilename)
{
int r;
#if defined(_MSC_VER)
@@ -256,126 +212,6 @@ static U64 BMK_GetFileSize(char* infilename)
/*********************************************************
* Benchmark function
*********************************************************/
-#ifdef __SSSE3__
-
-#include <tmmintrin.h>
-
-/* Idea proposed by Terje Mathisen */
-static BYTE stepSize16[17] = {16,16,16,15,16,15,12,14,16,9,10,11,12,13,14,15,16};
-static __m128i replicateTable[17] = {
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1},
- {0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0},
- {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3},
- {0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0},
- {0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3},
- {0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1},
- {0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7},
- {0,1,2,3,4,5,6,7,8,0,1,2,3,4,5,6},
- {0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5},
- {0,1,2,3,4,5,6,7,8,9,10,0,1,2,3,4},
- {0,1,2,3,4,5,6,7,8,9,10,11,0,1,2,3},
- {0,1,2,3,4,5,6,7,8,9,10,11,12,0,1,2},
- {0,1,2,3,4,5,6,7,8,9,10,11,12,13,0,1},
- {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,0},
- {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}};
-static BYTE stepSize32[17] = {32,32,32,30,32,30,30,28,32,27,30,22,24,26,28,30,16};
-static __m128i replicateTable2[17] = {
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1},
- {1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1},
- {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3},
- {1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1},
- {4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1},
- {2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3},
- {0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7},
- {7,8,0,1,2,3,4,5,6,7,8,0,1,2,3,4},
- {6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1},
- {5,6,7,8,9,10,0,1,2,3,4,5,6,7,8,9},
- {4,5,6,7,8,9,10,11,0,1,2,3,4,5,6,7},
- {3,4,5,6,7,8,9,10,11,12,0,1,2,3,4,5},
- {2,3,4,5,6,7,8,9,10,11,12,13,0,1,2,3},
- {1,2,3,4,5,6,7,8,9,10,11,12,13,14,0,1},
- {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}};
-
-U32 lz4_decode_sse(BYTE* dest, BYTE* src, U32 srcLength)
-{
- BYTE* d = dest, *e = src+srcLength;
- unsigned token, lit_len, mat_len;
- __m128i a;
- BYTE* dstore, *msrc;
-
- if (!srcLength) return 0;
- goto start;
-
- do {
- U32 step;
- unsigned mat_offset = src[0] + (src[1] << 8);
- src += 2;
- msrc = d - mat_offset;
- if (mat_len == 15) {
- do {
- token = *src++;
- mat_len += token;
- } while (token == 255);
- }
- mat_len += 4;
-
- dstore = d;
- d += mat_len;
-
- if (mat_offset <= 16)
- { // Bulk store only!
- __m128i a2;
- a = _mm_loadu_si128((const __m128i *)msrc);
- a2 = _mm_shuffle_epi8(a, replicateTable2[mat_offset]);
- a = _mm_shuffle_epi8(a, replicateTable[mat_offset]);
- step = stepSize32[mat_offset];
- do {
- _mm_storeu_si128((__m128i *)dstore, a);
- _mm_storeu_si128((__m128i *)(dstore+16), a2);
- dstore += step;
- } while (dstore < d);
- }
- else
- {
- do
- {
- a = _mm_loadu_si128((const __m128i *)msrc);
- _mm_storeu_si128((__m128i *)dstore, a);
- msrc += sizeof(a);
- dstore += sizeof(a);
- } while (dstore < d);
- }
-start:
- token = *src++;
- lit_len = token >> 4;
- mat_len = token & 15;
- if (token >= 0xf0) { // lit_len == 15
- do {
- token = *src++;
- lit_len += token;
- } while (token == 255);
- }
- dstore = d;
- msrc = src;
- d += lit_len;
- src += lit_len;
- do {
- a = _mm_loadu_si128((const __m128i *)msrc);
- _mm_storeu_si128((__m128i *)dstore, a);
- msrc += sizeof(a);
- dstore += sizeof(a);
- } while (dstore < d);
- } while (src < e);
-
- return (U32)(d-dest);
-}
-#endif // __SSSE3__
-
-
static LZ4_stream_t LZ4_stream;
static void local_LZ4_resetDictT(void)
{
@@ -565,23 +401,21 @@ static int local_LZ4F_decompress(const char* in, char* out, int inSize, int outS
#define NB_COMPRESSION_ALGORITHMS 100
#define NB_DECOMPRESSION_ALGORITHMS 100
-int fullSpeedBench(char** fileNamesTable, int nbFiles)
+int fullSpeedBench(const char** fileNamesTable, int nbFiles)
{
- int fileIdx=0;
- size_t errorCode;
+ int fileIdx=0;
- /* Init */
- errorCode = LZ4F_createDecompressionContext(&g_dCtx, LZ4F_VERSION);
- if (LZ4F_isError(errorCode)) { DISPLAY("dctx allocation issue \n"); return 10; }
+ /* Init */
+ { size_t const errorCode = LZ4F_createDecompressionContext(&g_dCtx, LZ4F_VERSION);
+ if (LZ4F_isError(errorCode)) { DISPLAY("dctx allocation issue \n"); return 10; } }
- /* Loop for each fileName */
- while (fileIdx<nbFiles)
- {
- FILE* inFile;
+ /* Loop for each fileName */
+ while (fileIdx<nbFiles) {
char* orig_buff = NULL;
struct chunkParameters* chunkP = NULL;
char* compressed_buff=NULL;
- char* inFileName;
+ const char* const inFileName = fileNamesTable[fileIdx++];
+ FILE* const inFile = fopen( inFileName, "rb" );
U64 inFileSize;
size_t benchedSize;
int nbChunks;
@@ -589,16 +423,15 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
size_t readSize;
int compressedBuffSize;
U32 crcOriginal;
+ size_t errorCode;
/* Check file existence */
- inFileName = fileNamesTable[fileIdx++];
- inFile = fopen( inFileName, "rb" );
if (inFile==NULL) { DISPLAY( "Pb opening %s\n", inFileName); return 11; }
/* Memory size adjustments */
inFileSize = BMK_GetFileSize(inFileName);
if (inFileSize==0) { DISPLAY( "file is empty\n"); fclose(inFile); return 11; }
- benchedSize = (size_t) BMK_findMaxMem(inFileSize*2) / 2; /* because 2 buffers */
+ benchedSize = BMK_findMaxMem(inFileSize*2) / 2; /* because 2 buffers */
if (benchedSize==0) { DISPLAY( "not enough memory\n"); fclose(inFile); return 11; }
if ((U64)benchedSize > inFileSize) benchedSize = (size_t)inFileSize;
if (benchedSize < inFileSize)
@@ -611,8 +444,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
maxCompressedChunkSize = LZ4_compressBound(g_chunkSize);
compressedBuffSize = nbChunks * maxCompressedChunkSize;
compressed_buff = (char*)malloc((size_t)compressedBuffSize);
- if(!chunkP || !orig_buff || !compressed_buff)
- {
+ if(!chunkP || !orig_buff || !compressed_buff) {
DISPLAY("\nError: not enough memory!\n");
fclose(inFile);
free(orig_buff);
@@ -626,8 +458,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
readSize = fread(orig_buff, 1, benchedSize, inFile);
fclose(inFile);
- if(readSize != benchedSize)
- {
+ if (readSize != benchedSize) {
DISPLAY("\nError: problem reading file '%s' !! \n", inFileName);
free(orig_buff);
free(compressed_buff);
@@ -640,8 +471,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
/* Bench */
- {
- int loopNb, nb_loops, chunkNb, cAlgNb, dAlgNb;
+ { int loopNb, nb_loops, chunkNb, cAlgNb, dAlgNb;
size_t cSize=0;
double ratio=0.;
@@ -649,8 +479,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
DISPLAY(" %s : \n", inFileName);
/* Bench Compression Algorithms */
- for (cAlgNb=0; (cAlgNb <= NB_COMPRESSION_ALGORITHMS) && (g_compressionTest); cAlgNb++)
- {
+ for (cAlgNb=0; (cAlgNb <= NB_COMPRESSION_ALGORITHMS) && (g_compressionTest); cAlgNb++) {
const char* compressorName;
int (*compressionFunction)(const char*, char*, int);
void (*initFunction)(void) = NULL;
@@ -660,20 +489,18 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
if ((g_compressionAlgo != ALL_COMPRESSORS) && (g_compressionAlgo != cAlgNb)) continue;
/* Init data chunks */
- {
- int i;
- size_t remaining = benchedSize;
- char* in = orig_buff;
- char* out = compressed_buff;
+ { int i;
+ size_t remaining = benchedSize;
+ char* in = orig_buff;
+ char* out = compressed_buff;
nbChunks = (int) (((int)benchedSize + (g_chunkSize-1))/ g_chunkSize);
- for (i=0; i<nbChunks; i++)
- {
- chunkP[i].id = i;
- chunkP[i].origBuffer = in; in += g_chunkSize;
- if ((int)remaining > g_chunkSize) { chunkP[i].origSize = g_chunkSize; remaining -= g_chunkSize; } else { chunkP[i].origSize = (int)remaining; remaining = 0; }
- chunkP[i].compressedBuffer = out; out += maxCompressedChunkSize;
- chunkP[i].compressedSize = 0;
- }
+ for (i=0; i<nbChunks; i++) {
+ chunkP[i].id = i;
+ chunkP[i].origBuffer = in; in += g_chunkSize;
+ if ((int)remaining > g_chunkSize) { chunkP[i].origSize = g_chunkSize; remaining -= g_chunkSize; } else { chunkP[i].origSize = (int)remaining; remaining = 0; }
+ chunkP[i].compressedBuffer = out; out += maxCompressedChunkSize;
+ chunkP[i].compressedSize = 0;
+ }
}
switch(cAlgNb)
@@ -715,55 +542,50 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
continue; /* unknown ID : just skip */
}
- for (loopNb = 1; loopNb <= g_nbIterations; loopNb++)
- {
+ for (loopNb = 1; loopNb <= g_nbIterations; loopNb++) {
double averageTime;
- int milliTime;
+ clock_t clockTime;
PROGRESS("%1i- %-28.28s :%9i ->\r", loopNb, compressorName, (int)benchedSize);
{ size_t i; for (i=0; i<benchedSize; i++) compressed_buff[i]=(char)i; } /* warming up memory */
nb_loops = 0;
- milliTime = BMK_GetMilliStart();
- while(BMK_GetMilliStart() == milliTime);
- milliTime = BMK_GetMilliStart();
- while(BMK_GetMilliSpan(milliTime) < TIMELOOP)
- {
+ clockTime = clock();
+ while(clock() == clockTime);
+ clockTime = clock();
+ while(BMK_GetClockSpan(clockTime) < TIMELOOP) {
if (initFunction!=NULL) initFunction();
- for (chunkNb=0; chunkNb<nbChunks; chunkNb++)
- {
+ for (chunkNb=0; chunkNb<nbChunks; chunkNb++) {
chunkP[chunkNb].compressedSize = compressionFunction(chunkP[chunkNb].origBuffer, chunkP[chunkNb].compressedBuffer, chunkP[chunkNb].origSize);
if (chunkP[chunkNb].compressedSize==0) DISPLAY("ERROR ! %s() = 0 !! \n", compressorName), exit(1);
}
nb_loops++;
}
- milliTime = BMK_GetMilliSpan(milliTime);
+ clockTime = BMK_GetClockSpan(clockTime);
nb_loops += !nb_loops; /* avoid division by zero */
- averageTime = (double)milliTime / nb_loops;
+ averageTime = ((double)clockTime) / nb_loops / CLOCKS_PER_SEC;
if (averageTime < bestTime) bestTime = averageTime;
cSize=0; for (chunkNb=0; chunkNb<nbChunks; chunkNb++) cSize += chunkP[chunkNb].compressedSize;
ratio = (double)cSize/(double)benchedSize*100.;
- PROGRESS("%1i- %-28.28s :%9i ->%9i (%5.2f%%),%7.1f MB/s\r", loopNb, compressorName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 1000.);
+ PROGRESS("%1i- %-28.28s :%9i ->%9i (%5.2f%%),%7.1f MB/s\r", loopNb, compressorName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 1000000);
}
if (ratio<100.)
- DISPLAY("%2i-%-28.28s :%9i ->%9i (%5.2f%%),%7.1f MB/s\n", cAlgNb, compressorName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 1000.);
+ DISPLAY("%2i-%-28.28s :%9i ->%9i (%5.2f%%),%7.1f MB/s\n", cAlgNb, compressorName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 1000000);
else
- DISPLAY("%2i-%-28.28s :%9i ->%9i (%5.1f%%),%7.1f MB/s\n", cAlgNb, compressorName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 1000.);
+ DISPLAY("%2i-%-28.28s :%9i ->%9i (%5.1f%%),%7.1f MB/s\n", cAlgNb, compressorName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 100000);
}
/* Prepare layout for decompression */
/* Init data chunks */
- {
- int i;
+ { int i;
size_t remaining = benchedSize;
char* in = orig_buff;
char* out = compressed_buff;
nbChunks = (int) (((int)benchedSize + (g_chunkSize-1))/ g_chunkSize);
- for (i=0; i<nbChunks; i++)
- {
+ for (i=0; i<nbChunks; i++) {
chunkP[i].id = i;
chunkP[i].origBuffer = in; in += g_chunkSize;
if ((int)remaining > g_chunkSize) { chunkP[i].origSize = g_chunkSize; remaining -= g_chunkSize; } else { chunkP[i].origSize = (int)remaining; remaining = 0; }
@@ -771,15 +593,13 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
chunkP[i].compressedSize = 0;
}
}
- for (chunkNb=0; chunkNb<nbChunks; chunkNb++)
- {
+ for (chunkNb=0; chunkNb<nbChunks; chunkNb++) {
chunkP[chunkNb].compressedSize = LZ4_compress(chunkP[chunkNb].origBuffer, chunkP[chunkNb].compressedBuffer, chunkP[chunkNb].origSize);
if (chunkP[chunkNb].compressedSize==0) DISPLAY("ERROR ! %s() = 0 !! \n", "LZ4_compress"), exit(1);
}
/* Decompression Algorithms */
- for (dAlgNb=0; (dAlgNb <= NB_DECOMPRESSION_ALGORITHMS) && (g_decompressionTest); dAlgNb++)
- {
+ for (dAlgNb=0; (dAlgNb <= NB_DECOMPRESSION_ALGORITHMS) && (g_decompressionTest); dAlgNb++) {
const char* dName;
int (*decompressionFunction)(const char*, char*, int, int);
double bestTime = 100000000.;
@@ -797,8 +617,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
case 8: decompressionFunction = local_LZ4_decompress_safe_forceExtDict; dName = "LZ4_decompress_safe_forceExtDict"; break;
case 9: decompressionFunction = local_LZ4F_decompress; dName = "LZ4F_decompress";
errorCode = LZ4F_compressFrame(compressed_buff, compressedBuffSize, orig_buff, benchedSize, NULL);
- if (LZ4F_isError(errorCode))
- {
+ if (LZ4F_isError(errorCode)) {
DISPLAY("Error while preparing compressed frame\n");
free(orig_buff);
free(compressed_buff);
@@ -815,56 +634,53 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
{ size_t i; for (i=0; i<benchedSize; i++) orig_buff[i]=0; } /* zeroing source area, for CRC checking */
- for (loopNb = 1; loopNb <= g_nbIterations; loopNb++)
- {
+ for (loopNb = 1; loopNb <= g_nbIterations; loopNb++) {
double averageTime;
- int milliTime;
+ clock_t clockTime;
U32 crcDecoded;
PROGRESS("%1i- %-29.29s :%10i ->\r", loopNb, dName, (int)benchedSize);
nb_loops = 0;
- milliTime = BMK_GetMilliStart();
- while(BMK_GetMilliStart() == milliTime);
- milliTime = BMK_GetMilliStart();
- while(BMK_GetMilliSpan(milliTime) < TIMELOOP)
- {
- for (chunkNb=0; chunkNb<nbChunks; chunkNb++)
- {
+ clockTime = clock();
+ while(clock() == clockTime);
+ clockTime = clock();
+ while(BMK_GetClockSpan(clockTime) < TIMELOOP) {
+ for (chunkNb=0; chunkNb<nbChunks; chunkNb++) {
int decodedSize = decompressionFunction(chunkP[chunkNb].compressedBuffer, chunkP[chunkNb].origBuffer, chunkP[chunkNb].compressedSize, chunkP[chunkNb].origSize);
if (chunkP[chunkNb].origSize != decodedSize) DISPLAY("ERROR ! %s() == %i != %i !! \n", dName, decodedSize, chunkP[chunkNb].origSize), exit(1);
}
nb_loops++;
}
- milliTime = BMK_GetMilliSpan(milliTime);
+ clockTime = BMK_GetClockSpan(clockTime);
nb_loops += !nb_loops; /* Avoid division by zero */
- averageTime = (double)milliTime / nb_loops;
+ averageTime = (double)clockTime / nb_loops / CLOCKS_PER_SEC;
if (averageTime < bestTime) bestTime = averageTime;
- PROGRESS("%1i- %-29.29s :%10i -> %7.1f MB/s\r", loopNb, dName, (int)benchedSize, (double)benchedSize / bestTime / 1000.);
+ PROGRESS("%1i- %-29.29s :%10i -> %7.1f MB/s\r", loopNb, dName, (int)benchedSize, (double)benchedSize / bestTime / 1000000);
/* CRC Checking */
crcDecoded = XXH32(orig_buff, (int)benchedSize, 0);
if (crcOriginal!=crcDecoded) { DISPLAY("\n!!! WARNING !!! %14s : Invalid Checksum : %x != %x\n", inFileName, (unsigned)crcOriginal, (unsigned)crcDecoded); exit(1); }
}
- DISPLAY("%2i-%-29.29s :%10i -> %7.1f MB/s\n", dAlgNb, dName, (int)benchedSize, (double)benchedSize / bestTime / 1000.);
+ DISPLAY("%2i-%-29.29s :%10i -> %7.1f MB/s\n", dAlgNb, dName, (int)benchedSize, (double)benchedSize / bestTime / 1000000);
}
}
free(orig_buff);
free(compressed_buff);
free(chunkP);
- }
+ }
- LZ4F_freeDecompressionContext(g_dCtx);
- if (g_pause) { printf("press enter...\n"); (void)getchar(); }
+ LZ4F_freeDecompressionContext(g_dCtx);
+ if (g_pause) { printf("press enter...\n"); (void)getchar(); }
- return 0;
+ return 0;
}
-static int usage(char* exename)
+static int usage(const char* exename)
{
DISPLAY( "Usage :\n");
DISPLAY( " %s [arg] file1 file2 ... fileX\n", exename);
@@ -885,41 +701,37 @@ static int usage_advanced(void)
return 0;
}
-static int badusage(char* exename)
+static int badusage(const char* exename)
{
DISPLAY("Wrong parameters\n");
usage(exename);
return 0;
}
-int main(int argc, char** argv)
+int main(int argc, const char** argv)
{
int i,
filenamesStart=2;
- char* exename=argv[0];
- char* input_filename=0;
+ const char* exename = argv[0];
+ const char* input_filename=0;
// Welcome message
DISPLAY(WELCOME_MESSAGE);
if (argc<2) { badusage(exename); return 1; }
- for(i=1; i<argc; i++)
- {
- char* argument = argv[i];
+ for(i=1; i<argc; i++) {
+ const char* argument = argv[i];
if(!argument) continue; // Protection if argument empty
- if (!strcmp(argument, "--no-prompt"))
- {
+ if (!strcmp(argument, "--no-prompt")) {
g_noPrompt = 1;
continue;
}
// Decode command (note : aggregated commands are allowed)
- if (argument[0]=='-')
- {
- while (argument[1]!=0)
- {
+ if (argument[0]=='-') {
+ while (argument[1]!=0) {
argument ++;
switch(argument[0])
@@ -927,8 +739,7 @@ int main(int argc, char** argv)
// Select compression algorithm only
case 'c':
g_decompressionTest = 0;
- while ((argument[1]>= '0') && (argument[1]<= '9'))
- {
+ while ((argument[1]>= '0') && (argument[1]<= '9')) {
g_compressionAlgo *= 10;
g_compressionAlgo += argument[1] - '0';
argument++;
@@ -938,8 +749,7 @@ int main(int argc, char** argv)
// Select decompression algorithm only
case 'd':
g_compressionTest = 0;
- while ((argument[1]>= '0') && (argument[1]<= '9'))
- {
+ while ((argument[1]>= '0') && (argument[1]<= '9')) {
g_decompressionAlgo *= 10;
g_decompressionAlgo += argument[1] - '0';
argument++;
@@ -959,8 +769,7 @@ int main(int argc, char** argv)
case '5':
case '6':
case '7':
- {
- int B = argument[1] - '0';
+ { int B = argument[1] - '0';
int S = 1 << (8 + 2*B);
BMK_setBlocksize(S);
argument++;
@@ -974,8 +783,7 @@ _exit_blockProperties:
// Modify Nb Iterations
case 'i':
- if ((argument[1] >='0') && (argument[1] <='9'))
- {
+ if ((argument[1] >='0') && (argument[1] <='9')) {
int iters = argument[1] - '0';
BMK_setNbIterations(iters);
argument++;
@@ -1003,4 +811,3 @@ _exit_blockProperties:
return fullSpeedBench(argv+filenamesStart, argc-filenamesStart);
}
-
diff --git a/programs/fuzzer.c b/programs/fuzzer.c
index 822e2ec..db7ad07 100644
--- a/programs/fuzzer.c
+++ b/programs/fuzzer.c
@@ -45,18 +45,12 @@
#include <stdlib.h>
#include <stdio.h> /* fgets, sscanf */
#include <string.h> /* strcmp */
-#include "lz4.h"
+#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
+#include "lz4.h" /* LZ4_VERSION_STRING */
#include "lz4hc.h"
#define XXH_STATIC_LINKING_ONLY
#include "xxhash.h"
-/* Use ftime() if gettimeofday() is not available on your target */
-#if defined(FUZ_LEGACY_TIMER)
-# include <sys/timeb.h> /* timeb, ftime */
-#else
-# include <sys/time.h> /* gettimeofday */
-#endif
-
/*-************************************
* Basic Types
@@ -80,10 +74,6 @@ typedef unsigned long long U64;
/*-************************************
* Constants
**************************************/
-#ifndef LZ4_VERSION
-# define LZ4_VERSION ""
-#endif
-
#define NB_ATTEMPTS (1<<16)
#define COMPRESSIBLE_NOISE_LENGTH (1 << 21)
#define FUZ_MAX_BLOCK_SIZE (1 << 17)
@@ -104,45 +94,16 @@ typedef unsigned long long U64;
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
#define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); }
static int g_displayLevel = 2;
-static const U32 g_refreshRate = 250;
-static U32 g_time = 0;
+static const clock_t g_refreshRate = CLOCKS_PER_SEC * 25 / 100;
+static clock_t g_time = 0;
/*-*******************************************************
* Fuzzer functions
*********************************************************/
-#if defined(FUZ_LEGACY_TIMER)
-
-static U32 FUZ_GetMilliStart(void)
+static clock_t FUZ_GetClockSpan(clock_t clockStart)
{
- struct timeb tb;
- U32 nCount;
- ftime( &tb );
- nCount = (U32) (((tb.time & 0xFFFFF) * 1000) + tb.millitm);
- return nCount;
-}
-
-#else
-
-static U32 FUZ_GetMilliStart(void)
-{
- struct timeval tv;
- U32 nCount;
- gettimeofday(&tv, NULL);
- nCount = (U32) (tv.tv_usec/1000 + (tv.tv_sec & 0xfffff) * 1000);
- return nCount;
-}
-
-#endif
-
-
-static U32 FUZ_GetMilliSpan(U32 nTimeStart)
-{
- U32 nCurrent = FUZ_GetMilliStart();
- U32 nSpan = nCurrent - nTimeStart;
- if (nTimeStart > nCurrent)
- nSpan += 0x100000 * 1000;
- return nSpan;
+ return clock() - clockStart; /* works even if overflow; max span ~ 30mn */
}
static U32 FUZ_rotl32(U32 u32, U32 nbBits)
@@ -291,8 +252,8 @@ _overflowError:
static void FUZ_displayUpdate(unsigned testNb)
{
- if ((FUZ_GetMilliSpan(g_time) > g_refreshRate) | (g_displayLevel>=3)) {
- g_time = FUZ_GetMilliStart();
+ if ((FUZ_GetClockSpan(g_time) > g_refreshRate) | (g_displayLevel>=3)) {
+ g_time = clock();
DISPLAY("\r%5u ", testNb);
if (g_displayLevel>=3) fflush(stdout);
}
@@ -315,7 +276,7 @@ static void FUZ_findDiff(const void* buff1, const void* buff2)
}
-static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double compressibility, U32 duration)
+static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double compressibility, U32 duration_s)
{
unsigned long long bytes = 0;
unsigned long long cbytes = 0;
@@ -338,12 +299,12 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
U32 coreRandState = seed;
U32 randState = coreRandState ^ PRIME3;
int result = 0;
- const U32 startTime = FUZ_GetMilliStart();
+ clock_t const clockStart = clock();
+ clock_t const clockDuration = (clock_t)duration_s * CLOCKS_PER_SEC;
/* init */
memset(&LZ4dict, 0, sizeof(LZ4dict));
- duration *= 1000;
/* Create compressible test buffer */
CNBuffer = malloc(COMPRESSIBLE_NOISE_LENGTH);
@@ -376,7 +337,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
} }
/* Main test loop */
- for (cycleNb = startCycle; (cycleNb < nbCycles) || (FUZ_GetMilliSpan(startTime) < duration) ; cycleNb++) {
+ for (cycleNb = startCycle; (cycleNb < nbCycles) || (FUZ_GetClockSpan(clockStart) < clockDuration) ; cycleNb++) {
U32 testNb = 0;
char* dict;
char* block;
@@ -1183,10 +1144,15 @@ int main(int argc, char** argv)
}
}
- printf("Starting LZ4 fuzzer (%i-bits, %s)\n", (int)(sizeof(size_t)*8), LZ4_VERSION);
+ printf("Starting LZ4 fuzzer (%i-bits, v%s)\n", (int)(sizeof(size_t)*8), LZ4_VERSION_STRING);
- if (!seedset) seed = FUZ_GetMilliStart() % 10000;
+ if (!seedset) {
+ time_t const t = time(NULL);
+ U32 const h = XXH32(&t, sizeof(t), 1);
+ seed = h % 10000;
+ }
printf("Seed = %u\n", seed);
+
if (proba!=FUZ_COMPRESSIBILITY_DEFAULT) printf("Compressibility : %i%%\n", proba);
if ((seedset==0) && (testNb==0)) FUZ_unitTests();
diff --git a/programs/lz4cli.c b/programs/lz4cli.c
index 3e952c6..961bea1 100644
--- a/programs/lz4cli.c
+++ b/programs/lz4cli.c
@@ -62,6 +62,8 @@
#include "bench.h" /* BMK_benchFile, BMK_SetNbIterations, BMK_SetBlocksize, BMK_SetPause */
#include "lz4io.h" /* LZ4IO_compressFilename, LZ4IO_decompressFilename, LZ4IO_compressMultipleFilenames */
#include "lz4hc.h" /* LZ4HC_DEFAULT_CLEVEL */
+#include "lz4.h" /* LZ4_VERSION_STRING */
+
/****************************
* OS-specific Includes
@@ -84,11 +86,8 @@
* Constants
******************************/
#define COMPRESSOR_NAME "LZ4 command line interface"
-#ifndef LZ4_VERSION
-# define LZ4_VERSION "r132"
-#endif
#define AUTHOR "Yann Collet"
-#define WELCOME_MESSAGE "*** %s %i-bits %s, by %s (%s) ***\n", COMPRESSOR_NAME, (int)(sizeof(void*)*8), LZ4_VERSION, AUTHOR, __DATE__
+#define WELCOME_MESSAGE "*** %s %i-bits v%s, by %s ***\n", COMPRESSOR_NAME, (int)(sizeof(void*)*8), LZ4_VERSION_STRING, AUTHOR
#define LZ4_EXTENSION ".lz4"
#define LZ4CAT "lz4cat"
#define UNLZ4 "unlz4"
@@ -342,7 +341,6 @@ int main(int argc, const char** argv)
if (!strcmp(argument, "--version")) { DISPLAY(WELCOME_MESSAGE); return 0; }
if (!strcmp(argument, "--keep")) { continue; } /* keep source file (default anyway; just for xz/lzma compatibility) */
-
/* Short commands (note : aggregated short commands are allowed) */
if (argument[0]=='-') {
/* '-' means stdin/stdout */
@@ -411,8 +409,7 @@ int main(int argc, const char** argv)
/* Modify Block Properties */
case 'B':
- while (argument[1]!=0)
- {
+ while (argument[1]!=0) {
int exitBlockProperties=0;
switch(argument[1])
{
@@ -448,13 +445,10 @@ int main(int argc, const char** argv)
/* Modify Nb Iterations (benchmark only) */
case 'i':
- { unsigned iters = 0;
- while ((argument[1] >='0') && (argument[1] <='9'))
- {
- iters *= 10;
- iters += argument[1] - '0';
- argument++;
- }
+ { unsigned iters;
+ argument++;
+ iters = readU32FromChar(&argument);
+ argument--;
BMK_setNbIterations(iters);
}
break;
@@ -479,8 +473,7 @@ int main(int argc, const char** argv)
if (!input_filename) { input_filename=argument; continue; }
/* Second non-option arg in output_filename to preserve original cli logic. */
- if (!output_filename)
- {
+ if (!output_filename) {
output_filename=argument;
if (!strcmp (output_filename, nullOutput)) output_filename = nulmark;
continue;
@@ -498,31 +491,26 @@ int main(int argc, const char** argv)
if(!input_filename) { input_filename=stdinmark; }
/* Check if input is defined as console; trigger an error in this case */
- if (!strcmp(input_filename, stdinmark) && IS_CONSOLE(stdin) )
- {
+ if (!strcmp(input_filename, stdinmark) && IS_CONSOLE(stdin) ) {
DISPLAYLEVEL(1, "refusing to read from a console\n");
exit(1);
}
/* Check if benchmark is selected */
- if (bench)
- {
+ if (bench) {
int bmkResult = BMK_benchFiles(inFileNames, ifnIdx, cLevel, cLevelLast);
free((void*)inFileNames);
return bmkResult;
}
/* No output filename ==> try to select one automatically (when possible) */
- while (!output_filename)
- {
+ while (!output_filename) {
if (!IS_CONSOLE(stdout)) { output_filename=stdoutmark; break; } /* Default to stdout whenever possible (i.e. not a console) */
- if ((!decode) && !(forceCompress)) /* auto-determine compression or decompression, based on file extension */
- {
+ if ((!decode) && !(forceCompress)) { /* auto-determine compression or decompression, based on file extension */
size_t const l = strlen(input_filename);
if (!strcmp(input_filename+(l-4), LZ4_EXTENSION)) decode=1;
}
- if (!decode) /* compression to file */
- {
+ if (!decode) { /* compression to file */
size_t const l = strlen(input_filename);
dynNameSpace = (char*)calloc(1,l+5);
if (dynNameSpace==NULL) exit(1);
@@ -533,8 +521,7 @@ int main(int argc, const char** argv)
break;
}
/* decompression to file (automatic name will work only if input filename has correct format extension) */
- {
- size_t outl;
+ { size_t outl;
size_t inl = strlen(input_filename);
dynNameSpace = (char*)calloc(1,inl+1);
strcpy(dynNameSpace, input_filename);
@@ -560,21 +547,21 @@ int main(int argc, const char** argv)
/* IO Stream/File */
LZ4IO_setNotificationLevel(displayLevel);
if (decode) {
- if (multiple_inputs)
- operationResult = LZ4IO_decompressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION);
- else
- DEFAULT_DECOMPRESSOR(input_filename, output_filename);
- } else {
- /* compression is default action */
- if (legacy_format) {
- DISPLAYLEVEL(3, "! Generating compressed LZ4 using Legacy format (deprecated) ! \n");
- LZ4IO_compressFilename_Legacy(input_filename, output_filename, cLevel);
- } else {
if (multiple_inputs)
- operationResult = LZ4IO_compressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION, cLevel);
+ operationResult = LZ4IO_decompressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION);
else
- DEFAULT_COMPRESSOR(input_filename, output_filename, cLevel);
- }
+ DEFAULT_DECOMPRESSOR(input_filename, output_filename);
+ } else {
+ /* compression is default action */
+ if (legacy_format) {
+ DISPLAYLEVEL(3, "! Generating compressed LZ4 using Legacy format (deprecated) ! \n");
+ LZ4IO_compressFilename_Legacy(input_filename, output_filename, cLevel);
+ } else {
+ if (multiple_inputs)
+ operationResult = LZ4IO_compressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION, cLevel);
+ else
+ DEFAULT_COMPRESSOR(input_filename, output_filename, cLevel);
+ }
}
_cleanup: