diff --git a/lib/common/zbuff_static.h b/lib/common/zbuff_static.h index 6a4287e4d..c50a3e166 100644 --- a/lib/common/zbuff_static.h +++ b/lib/common/zbuff_static.h @@ -47,9 +47,7 @@ extern "C" { #include "zstd_static.h" /* ZSTD_parameters */ #include "zbuff.h" -#ifndef MIN - #define MIN(a,b) ((a)<(b) ? (a) : (b)) -#endif +#define ZBUFF_MIN(a,b) ((a)<(b) ? (a) : (b)) /*-************************************* @@ -73,7 +71,7 @@ ZSTDLIB_API size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* cctx, MEM_STATIC size_t ZBUFF_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize) { - size_t length = MIN(dstCapacity, srcSize); + size_t length = ZBUFF_MIN(dstCapacity, srcSize); memcpy(dst, src, length); return length; } diff --git a/programs/bench.c b/programs/bench.c index a2721552e..52c64d525 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -26,7 +26,7 @@ /* ************************************* * Includes ***************************************/ -#include "util.h" /* Compiler options, UTIL_GetFileSize, UTIL_HAS_CREATEFILELIST, UTIL_sleep */ +#include "util.h" /* Compiler options, UTIL_GetFileSize, UTIL_sleep */ #include /* malloc, free */ #include /* memset */ #include /* fprintf, fopen, ftello64 */ @@ -495,32 +495,14 @@ static void BMK_syntheticTest(int cLevel, int cLevelLast, double compressibility int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles, - const char* dictFileName, int cLevel, int cLevelLast, int recursive) + const char* dictFileName, int cLevel, int cLevelLast) { double const compressibility = (double)g_compressibilityDefault / 100; if (nbFiles == 0) BMK_syntheticTest(cLevel, cLevelLast, compressibility); else - { -#ifdef UTIL_HAS_CREATEFILELIST - if (recursive) { - char* buf; - const char** filenameTable; - unsigned i; - filenameTable = UTIL_createFileList(fileNamesTable, nbFiles, &buf, &nbFiles); - if (filenameTable) { - for (i=0; i= bufend) { ptrdiff_t newListSize = (bufend - buf) + LIST_SIZE_INCREASE; diff --git a/programs/zbufftest.c b/programs/zbufftest.c index c780b8f4e..fce0ab275 100644 --- a/programs/zbufftest.c +++ b/programs/zbufftest.c @@ -262,6 +262,8 @@ static size_t FUZ_randomLength(U32* seed, U32 maxLog) return FUZ_rLogLength(seed, logLength); } +#define MIN(a,b) ( (a) < (b) ? (a) : (b) ) + #define CHECK(cond, ...) if (cond) { DISPLAY("Error => "); DISPLAY(__VA_ARGS__); \ DISPLAY(" (seed %u, test nb %u) \n", seed, testNb); goto _output_error; } diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 215157873..f367f49af 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -129,6 +129,9 @@ static int usage_advanced(const char* programName) DISPLAY( " -v : verbose mode\n"); DISPLAY( " -q : suppress warnings; specify twice to suppress errors too\n"); DISPLAY( " -c : force write to standard output, even if it is the console\n"); +#ifdef UTIL_HAS_CREATEFILELIST + DISPLAY( " -r : operate recursively on directories\n"); +#endif #ifndef ZSTD_NOCOMPRESS DISPLAY( "--ultra : enable ultra modes (requires more memory to decompress)\n"); #endif @@ -147,9 +150,6 @@ static int usage_advanced(const char* programName) DISPLAY( " -b# : benchmark file(s), using # compression level (default : 1) \n"); DISPLAY( " -e# : test all compression levels from -bX to # (default: 1)\n"); DISPLAY( " -i# : iteration loops [1-9](default : 3)\n"); -#ifdef UTIL_HAS_CREATEFILELIST - DISPLAY( " -r : operate recursively on directories\n"); -#endif DISPLAY( " -B# : cut file into independent blocks of size # (default: no block)\n"); #endif return 0; @@ -198,6 +198,11 @@ int main(int argCount, const char** argv) unsigned maxDictSize = g_defaultMaxDictSize; unsigned dictCLevel = g_defaultDictCLevel; unsigned dictSelect = g_defaultSelectivityLevel; +#ifdef UTIL_HAS_CREATEFILELIST + const char** fileNamesTable = NULL; + char* fileNamesBuf; + unsigned fileNamesNb; +#endif /* init */ (void)recursive; (void)cLevelLast; (void)dictCLevel; /* not used when ZSTD_NOBENCH / ZSTD_NODICT set */ @@ -296,6 +301,9 @@ int main(int argCount, const char** argv) /* dictionary name */ case 'o': nextArgumentIsOutFileName=1; argument++; break; + /* recursive */ + case 'r': recursive=1; argument++; break; + #ifndef ZSTD_NOBENCH /* Benchmark */ case 'b': bench=1; argument++; break; @@ -322,9 +330,6 @@ int main(int argCount, const char** argv) } break; - /* recursive */ - case 'r': recursive=1; argument++; break; - /* cut input into blocks (benchmark only) */ case 'B': { size_t bSize = 0; @@ -395,11 +400,24 @@ int main(int argCount, const char** argv) /* Welcome message (if verbose) */ DISPLAYLEVEL(3, WELCOME_MESSAGE); +#ifdef UTIL_HAS_CREATEFILELIST + if (recursive) { + fileNamesTable = UTIL_createFileList(filenameTable, filenameIdx, &fileNamesBuf, &fileNamesNb); + if (fileNamesTable) { + unsigned i; + for (i=0; i