diff --git a/lib/compress/zstd_compress_internal.h b/lib/compress/zstd_compress_internal.h index 8111fb22..798dad14 100644 --- a/lib/compress/zstd_compress_internal.h +++ b/lib/compress/zstd_compress_internal.h @@ -751,10 +751,10 @@ MEM_STATIC double ZSTD_fWeight(U32 rawStat) { U32 const fp_accuracy = 8; U32 const fp_multiplier = (1 << fp_accuracy); - U32 const stat = rawStat + 1; - U32 const hb = ZSTD_highbit32(stat); + U32 const newStat = rawStat + 1; + U32 const hb = ZSTD_highbit32(newStat); U32 const BWeight = hb * fp_multiplier; - U32 const FWeight = (stat << fp_accuracy) >> hb; + U32 const FWeight = (newStat << fp_accuracy) >> hb; U32 const weight = BWeight + FWeight; assert(hb + fp_accuracy < 31); return (double)weight / fp_multiplier; diff --git a/lib/dictBuilder/fastcover.c b/lib/dictBuilder/fastcover.c index dfee4574..cf8eb50a 100644 --- a/lib/dictBuilder/fastcover.c +++ b/lib/dictBuilder/fastcover.c @@ -159,15 +159,15 @@ static COVER_segment_t FASTCOVER_selectSegment(const FASTCOVER_ctx_t *ctx, */ while (activeSegment.end < end) { /* Get hash value of current dmer */ - const size_t index = FASTCOVER_hashPtrToIndex(ctx->samples + activeSegment.end, f, d); + const size_t idx = FASTCOVER_hashPtrToIndex(ctx->samples + activeSegment.end, f, d); /* Add frequency of this index to score if this is the first occurence of index in active segment */ - if (segmentFreqs[index] == 0) { - activeSegment.score += freqs[index]; + if (segmentFreqs[idx] == 0) { + activeSegment.score += freqs[idx]; } /* Increment end of segment and segmentFreqs*/ activeSegment.end += 1; - segmentFreqs[index] += 1; + segmentFreqs[idx] += 1; /* If the window is now too large, drop the first position */ if (activeSegment.end - activeSegment.begin == dmersInK + 1) { /* Get hash value of the dmer to be eliminated from active segment */ diff --git a/programs/fileio.c b/programs/fileio.c index d5cd3416..4070fa9c 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -270,9 +270,9 @@ void FIO_addAbortHandler() static FIO_compressionType_t g_compressionType = FIO_zstdCompression; void FIO_setCompressionType(FIO_compressionType_t compressionType) { g_compressionType = compressionType; } static U32 g_overwrite = 0; -void FIO_overwriteMode(void) { g_overwrite=1; } -static U32 g_sparseFileSupport = 1; /* 0: no sparse allowed; 1: auto (file yes, stdout no); 2: force sparse */ -void FIO_setSparseWrite(unsigned sparse) { g_sparseFileSupport=sparse; } +void FIO_overwriteMode(void) { g_overwrite = 1; } +static U32 g_sparseFileSupport = ZSTD_SPARSE_DEFAULT; /* 0: no sparse allowed; 1: auto (file yes, stdout no); 2: force sparse */ +void FIO_setSparseWrite(unsigned sparse) { g_sparseFileSupport = sparse; } static U32 g_dictIDFlag = 1; void FIO_setDictIDFlag(unsigned dictIDFlag) { g_dictIDFlag = dictIDFlag; } static U32 g_checksumFlag = 1; @@ -365,7 +365,7 @@ void FIO_setNoProgress(unsigned noProgress) { static int FIO_remove(const char* path) { if (!UTIL_isRegularFile(path)) { - DISPLAYLEVEL(2, "zstd: Refusing to remove non-regular file %s\n", path); + DISPLAYLEVEL(2, "zstd: Refusing to remove non-regular file %s \n", path); return 0; } #if defined(_WIN32) || defined(WIN32) @@ -383,11 +383,17 @@ static FILE* FIO_openSrcFile(const char* srcFileName) { assert(srcFileName != NULL); if (!strcmp (srcFileName, stdinmark)) { - DISPLAYLEVEL(4,"Using stdin for input\n"); + DISPLAYLEVEL(4,"Using stdin for input \n"); SET_BINARY_MODE(stdin); return stdin; } + if (!UTIL_fileExist(srcFileName)) { + DISPLAYLEVEL(1, "zstd: can't stat %s : %s -- ignored \n", + srcFileName, strerror(errno)); + return NULL; + } + if (!UTIL_isRegularFile(srcFileName)) { DISPLAYLEVEL(1, "zstd: %s is not a regular file -- ignored \n", srcFileName); @@ -408,36 +414,37 @@ static FILE* FIO_openDstFile(const char* srcFileName, const char* dstFileName) { assert(dstFileName != NULL); if (!strcmp (dstFileName, stdoutmark)) { - DISPLAYLEVEL(4,"Using stdout for output\n"); + DISPLAYLEVEL(4,"Using stdout for output \n"); 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"); } return stdout; } + if (srcFileName != NULL) { stat_t srcStat; stat_t dstStat; - if (UTIL_getFileStat(srcFileName, &srcStat) && UTIL_getFileStat(dstFileName, &dstStat)) { - if (srcStat.st_dev == dstStat.st_dev && srcStat.st_ino == dstStat.st_ino) { + if ( UTIL_getFileStat(srcFileName, &srcStat) + && UTIL_getFileStat(dstFileName, &dstStat) ) { + if ( srcStat.st_dev == dstStat.st_dev + && srcStat.st_ino == dstStat.st_ino ) { DISPLAYLEVEL(1, "zstd: Refusing to open a output file which will overwrite the input file \n"); return NULL; - } - } - } + } } } if (g_sparseFileSupport == 1) { g_sparseFileSupport = ZSTD_SPARSE_DEFAULT; } if (UTIL_isRegularFile(dstFileName)) { - FILE* fCheck; - if (!strcmp(dstFileName, nulmark)) { - EXM_THROW(40, "%s is unexpectedly a regular file", dstFileName); - } /* Check if destination file already exists */ - fCheck = fopen( dstFileName, "rb" ); + FILE* const fCheck = fopen( dstFileName, "rb" ); + if (!strcmp(dstFileName, nulmark)) { + EXM_THROW(40, "%s is unexpectedly categorized as a regular file", + dstFileName); + } if (fCheck != NULL) { /* dst file exists, authorization prompt */ fclose(fCheck); if (!g_overwrite) { @@ -803,26 +810,28 @@ FIO_compressLz4Frame(cRess_t* ress, /* Main Loop */ while (readSize>0) { - size_t outSize; - - /* Compress Block */ - outSize = LZ4F_compressUpdate(ctx, ress->dstBuffer, ress->dstBufferSize, ress->srcBuffer, readSize, NULL); + size_t const outSize = LZ4F_compressUpdate(ctx, + ress->dstBuffer, ress->dstBufferSize, + ress->srcBuffer, readSize, NULL); if (LZ4F_isError(outSize)) EXM_THROW(35, "zstd: %s: lz4 compression failed : %s", srcFileName, LZ4F_getErrorName(outSize)); outFileSize += outSize; - if (srcFileSize == UTIL_FILESIZE_UNKNOWN) + if (srcFileSize == UTIL_FILESIZE_UNKNOWN) { DISPLAYUPDATE(2, "\rRead : %u MB ==> %.2f%%", (U32)(inFileSize>>20), (double)outFileSize/inFileSize*100) - else + } else { DISPLAYUPDATE(2, "\rRead : %u / %u MB ==> %.2f%%", (U32)(inFileSize>>20), (U32)(srcFileSize>>20), (double)outFileSize/inFileSize*100); + } /* Write Block */ - { size_t const sizeCheck = fwrite(ress->dstBuffer, 1, outSize, ress->dstFile); - if (sizeCheck!=outSize) EXM_THROW(36, "Write error : %s", strerror(errno)); } + { size_t const sizeCheck = fwrite(ress->dstBuffer, 1, outSize, ress->dstFile); + if (sizeCheck != outSize) + EXM_THROW(36, "Write error : %s", strerror(errno)); + } /* Read next block */ readSize = fread(ress->srcBuffer, (size_t)1, (size_t)blockSize, ress->srcFile); @@ -837,7 +846,7 @@ FIO_compressLz4Frame(cRess_t* ress, srcFileName, LZ4F_getErrorName(headerSize)); { size_t const sizeCheck = fwrite(ress->dstBuffer, 1, headerSize, ress->dstFile); - if (sizeCheck!=headerSize) + if (sizeCheck != headerSize) EXM_THROW(39, "Write error : %s (cannot write end of stream)", strerror(errno)); } @@ -1431,12 +1440,14 @@ static unsigned FIO_fwriteSparse(FILE* file, const void* buffer, size_t bufferSi static void FIO_fwriteSparseEnd(FILE* file, unsigned storedSkips) { - if (storedSkips-->0) { /* implies g_sparseFileSupport>0 */ - int const seekResult = LONG_SEEK(file, storedSkips, SEEK_CUR); - if (seekResult != 0) EXM_THROW(69, "Final skip error (sparse file)"); + if (storedSkips>0) { + assert(g_sparseFileSupport > 0); /* storedSkips>0 implies sparse support is enabled */ + if (LONG_SEEK(file, storedSkips-1, SEEK_CUR) != 0) + EXM_THROW(69, "Final skip error (sparse file support)"); + /* last zero must be explicitly written, + * so that skipped ones get implicitly translated as zero by FS */ { const char lastZeroByte[1] = { 0 }; - size_t const sizeCheck = fwrite(lastZeroByte, 1, 1, file); - if (sizeCheck != 1) + if (fwrite(lastZeroByte, 1, 1, file) != 1) EXM_THROW(69, "Write error : cannot write last zero"); } } } @@ -2323,7 +2334,7 @@ FIO_listFile(fileInfo_t* total, const char* inFileName, int displayLevel) } displayInfo(inFileName, &info, displayLevel); *total = FIO_addFInfo(*total, info); - assert(error>=0 || error<=1); + assert(error == info_success || error == info_frame_error); return error; } } diff --git a/programs/util.c b/programs/util.c index 5c5e1960..34634318 100644 --- a/programs/util.c +++ b/programs/util.c @@ -16,7 +16,21 @@ extern "C" { /*-**************************************** * Dependencies ******************************************/ -#include "util.h" +#include "util.h" /* note : ensure that platform.h is included first ! */ +#include +#include + + +int UTIL_fileExist(const char* filename) +{ + stat_t statbuf; +#if defined(_MSC_VER) + int const stat_error = _stat64(filename, &statbuf); +#else + int const stat_error = stat(filename, &statbuf); +#endif + return !stat_error; +} int UTIL_isRegularFile(const char* infilename) { @@ -161,21 +175,23 @@ int UTIL_prepareFileList(const char *dirName, char** bufStart, size_t* pos, char pathLength = dirLength+1+fnameLength; path[pathLength] = 0; if (cFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - if (strcmp (cFile.cFileName, "..") == 0 || - strcmp (cFile.cFileName, ".") == 0) continue; - - nbFiles += UTIL_prepareFileList(path, bufStart, pos, bufEnd, followLinks); /* Recursively call "UTIL_prepareFileList" with the new path. */ + if ( strcmp (cFile.cFileName, "..") == 0 + || strcmp (cFile.cFileName, ".") == 0 ) + continue; + /* Recursively call "UTIL_prepareFileList" with the new path. */ + nbFiles += UTIL_prepareFileList(path, bufStart, pos, bufEnd, followLinks); if (*bufStart == NULL) { free(path); FindClose(hFile); return 0; } - } - else if ((cFile.dwFileAttributes & FILE_ATTRIBUTE_NORMAL) || (cFile.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) || (cFile.dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED)) { + } else if ( (cFile.dwFileAttributes & FILE_ATTRIBUTE_NORMAL) + || (cFile.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) + || (cFile.dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED) ) { if (*bufStart + *pos + pathLength >= *bufEnd) { - ptrdiff_t newListSize = (*bufEnd - *bufStart) + LIST_SIZE_INCREASE; + ptrdiff_t const newListSize = (*bufEnd - *bufStart) + LIST_SIZE_INCREASE; *bufStart = (char*)UTIL_realloc(*bufStart, newListSize); - *bufEnd = *bufStart + newListSize; if (*bufStart == NULL) { free(path); FindClose(hFile); return 0; } + *bufEnd = *bufStart + newListSize; } if (*bufStart + *pos + pathLength < *bufEnd) { - strncpy(*bufStart + *pos, path, *bufEnd - (*bufStart + *pos)); + memcpy(*bufStart + *pos, path, pathLength+1 /* include final \0 */); *pos += pathLength + 1; nbFiles++; } @@ -232,7 +248,7 @@ int UTIL_prepareFileList(const char *dirName, char** bufStart, size_t* pos, char if (*bufStart == NULL) { free(path); closedir(dir); return 0; } } if (*bufStart + *pos + pathLength < *bufEnd) { - strncpy(*bufStart + *pos, path, *bufEnd - (*bufStart + *pos)); + memcpy(*bufStart + *pos, path, pathLength + 1); /* with final \0 */ *pos += pathLength + 1; nbFiles++; } @@ -290,7 +306,7 @@ UTIL_createFileList(const char **inputNames, unsigned inputNamesNb, if (!buf) return NULL; } if (buf + pos + len < bufend) { - strncpy(buf + pos, inputNames[i], bufend - (buf + pos)); + memcpy(buf+pos, inputNames[i], len+1); /* with final \0 */ pos += len + 1; nbFiles++; } @@ -322,6 +338,7 @@ UTIL_createFileList(const char **inputNames, unsigned inputNamesNb, ******************************************/ int g_utilDisplayLevel; + /*-**************************************** * Time functions ******************************************/ @@ -340,6 +357,7 @@ U64 UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd) } return 1000000ULL*(clockEnd.QuadPart - clockStart.QuadPart)/ticksPerSecond.QuadPart; } + U64 UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd) { static LARGE_INTEGER ticksPerSecond; @@ -353,7 +371,9 @@ U64 UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd) } #elif defined(__APPLE__) && defined(__MACH__) + UTIL_time_t UTIL_getTime(void) { return mach_absolute_time(); } + U64 UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd) { static mach_timebase_info_data_t rate; @@ -422,11 +442,11 @@ U64 UTIL_getSpanTimeNano(UTIL_time_t begin, UTIL_time_t end) } #else /* relies on standard C (note : clock_t measurements can be wrong when using multi-threading) */ -typedef clock_t UTIL_time_t; -#define UTIL_TIME_INITIALIZER 0 + UTIL_time_t UTIL_getTime(void) { return clock(); } U64 UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000ULL * (clockEnd - clockStart) / CLOCKS_PER_SEC; } U64 UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000000ULL * (clockEnd - clockStart) / CLOCKS_PER_SEC; } + #endif /* returns time span in microseconds */ @@ -651,4 +671,3 @@ int UTIL_countPhysicalCores(void) #if defined (__cplusplus) } #endif - diff --git a/programs/util.h b/programs/util.h index d61ff526..f78bcbe1 100644 --- a/programs/util.h +++ b/programs/util.h @@ -20,10 +20,9 @@ extern "C" { * Dependencies ******************************************/ #include "platform.h" /* PLATFORM_POSIX_VERSION, ZSTD_NANOSLEEP_SUPPORT, ZSTD_SETPRIORITY_SUPPORT */ -#include /* malloc */ +#include /* malloc, realloc, free */ #include /* size_t, ptrdiff_t */ #include /* fprintf */ -#include /* strncmp */ #include /* stat, utime */ #include /* stat, chmod */ #if defined(_MSC_VER) @@ -34,7 +33,6 @@ extern "C" { # include /* utime */ #endif #include /* clock_t, clock, CLOCKS_PER_SEC, nanosleep */ -#include #include "mem.h" /* U32, U64 */ @@ -118,12 +116,16 @@ extern int g_utilDisplayLevel; * Time functions ******************************************/ #if defined(_WIN32) /* Windows */ + #define UTIL_TIME_INITIALIZER { { 0, 0 } } typedef LARGE_INTEGER UTIL_time_t; + #elif defined(__APPLE__) && defined(__MACH__) + #include #define UTIL_TIME_INITIALIZER 0 typedef U64 UTIL_time_t; + #elif (PLATFORM_POSIX_VERSION >= 200112L) \ && (defined(__UCLIBC__) \ || (defined(__GLIBC__) \ @@ -135,10 +137,14 @@ extern int g_utilDisplayLevel; typedef struct timespec UTIL_time_t; UTIL_time_t UTIL_getSpanTime(UTIL_time_t begin, UTIL_time_t end); + #else /* relies on standard C (note : clock_t measurements can be wrong when using multi-threading) */ + typedef clock_t UTIL_time_t; #define UTIL_TIME_INITIALIZER 0 + #endif + UTIL_time_t UTIL_getTime(void); U64 UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd); U64 UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd); @@ -163,10 +169,11 @@ void UTIL_waitForNextTick(void); #endif +int UTIL_fileExist(const char* filename); int UTIL_isRegularFile(const char* infilename); -int UTIL_setFileStat(const char *filename, stat_t *statbuf); +int UTIL_setFileStat(const char* filename, stat_t* statbuf); U32 UTIL_isDirectory(const char* infilename); -int UTIL_getFileStat(const char* infilename, stat_t *statbuf); +int UTIL_getFileStat(const char* infilename, stat_t* statbuf); U32 UTIL_isLink(const char* infilename); #define UTIL_FILESIZE_UNKNOWN ((U64)(-1)) @@ -178,7 +185,7 @@ U64 UTIL_getTotalFileSize(const char* const * const fileNamesTable, unsigned nbF * A modified version of realloc(). * If UTIL_realloc() fails the original block is freed. */ -UTIL_STATIC void *UTIL_realloc(void *ptr, size_t size) +UTIL_STATIC void* UTIL_realloc(void *ptr, size_t size) { void *newptr = realloc(ptr, size); if (newptr) return newptr; @@ -186,7 +193,7 @@ UTIL_STATIC void *UTIL_realloc(void *ptr, size_t size) return NULL; } -int UTIL_prepareFileList(const char *dirName, char** bufStart, size_t* pos, char** bufEnd, int followLinks); +int UTIL_prepareFileList(const char* dirName, char** bufStart, size_t* pos, char** bufEnd, int followLinks); #ifdef _WIN32 # define UTIL_HAS_CREATEFILELIST #elif defined(__linux__) || (PLATFORM_POSIX_VERSION >= 200112L) /* opendir, readdir require POSIX.1-2001 */ diff --git a/tests/paramgrill.c b/tests/paramgrill.c index 7c52a92e..9f8c894e 100644 --- a/tests/paramgrill.c +++ b/tests/paramgrill.c @@ -12,7 +12,7 @@ /*-************************************ * Dependencies **************************************/ -#include "util.h" /* Compiler options, UTIL_GetFileSize */ +#include "util.h" /* Ensure platform.h is compiled first; also : compiler options, UTIL_GetFileSize */ #include /* malloc */ #include /* fprintf, fopen, ftello64 */ #include /* strcmp */ @@ -24,7 +24,6 @@ #include "zstd.h" #include "datagen.h" #include "xxhash.h" -#include "util.h" #include "benchfn.h" #include "benchzstd.h" #include "zstd_errors.h" @@ -879,12 +878,12 @@ BMK_printWinner(FILE* f, const int cLevel, const BMK_benchResult_t result, const if(TIMED) { const U64 mn_in_ns = 60ULL * TIMELOOP_NANOSEC; - const U64 time = UTIL_clockSpanNano(g_time); - const U64 minutes = time / mn_in_ns; + const U64 time_ns = UTIL_clockSpanNano(g_time); + const U64 minutes = time_ns / mn_in_ns; fprintf(f, "%1lu:%2lu:%05.2f - ", (unsigned long) minutes / 60, (unsigned long) minutes % 60, - (double)(time - (minutes * mn_in_ns)) / TIMELOOP_NANOSEC ); + (double)(time_ns - (minutes * mn_in_ns)) / TIMELOOP_NANOSEC ); } fprintf(f, "/* %s */ ", lvlstr); diff --git a/tests/playTests.sh b/tests/playTests.sh index e77f10e5..051833b4 100755 --- a/tests/playTests.sh +++ b/tests/playTests.sh @@ -196,9 +196,10 @@ $ZSTD tmpro -c --no-progress | $ZSTD -d -o "$INTOVOID" --no-progress $ZSTD tmpro -cv --no-progress | $ZSTD -dv -o "$INTOVOID" --no-progress rm -f tmpro tmpro.zst $ECHO "test: overwrite input file (must fail)" -$ZSTD tmp -fo tmp && die "zstd overwrote the input file" -$ZSTD tmp.zst -dfo tmp.zst && die "zstd overwrote the input file" - +$ZSTD tmp -fo tmp && die "zstd compression overwrote the input file" +$ZSTD tmp.zst -dfo tmp.zst && die "zstd decompression overwrote the input file" +$ECHO "test: detect that input file does not exist" +$ZSTD nothere && die "zstd hasn't detected that input file does not exist" $ECHO "test : file removal" $ZSTD -f --rm tmp diff --git a/zlibWrapper/Makefile b/zlibWrapper/Makefile index ba69f199..0c19107b 100644 --- a/zlibWrapper/Makefile +++ b/zlibWrapper/Makefile @@ -71,25 +71,25 @@ valgrindTest: clean example fitblk example_zstd fitblk_zstd zwrapbench # $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< minigzip: $(EXAMPLE_PATH)/minigzip.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY) - $(CC) $(LDFLAGS) $^ $(ZSTDLIBRARY) $(ZLIB_LIBRARY) -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZSTDLIBRARY) $(ZLIB_LIBRARY) -o $@ minigzip_zstd: $(EXAMPLE_PATH)/minigzip.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY) - $(CC) $(LDFLAGS) $^ $(ZSTDLIBRARY) $(ZLIB_LIBRARY) -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZSTDLIBRARY) $(ZLIB_LIBRARY) -o $@ example: $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY) - $(CC) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ example_zstd: $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY) - $(CC) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ fitblk: $(EXAMPLE_PATH)/fitblk.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(ZSTDLIBRARY) - $(CC) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ fitblk_zstd: $(EXAMPLE_PATH)/fitblk.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(ZSTDLIBRARY) - $(CC) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ zwrapbench: $(EXAMPLE_PATH)/zwrapbench.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(PROGRAMS_PATH)/util.o $(PROGRAMS_PATH)/datagen.o $(ZSTDLIBRARY) - $(CC) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o: $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.h diff --git a/zlibWrapper/examples/zwrapbench.c b/zlibWrapper/examples/zwrapbench.c index d2d6073f..40e9ed55 100644 --- a/zlibWrapper/examples/zwrapbench.c +++ b/zlibWrapper/examples/zwrapbench.c @@ -17,6 +17,7 @@ #include /* fprintf, fopen, ftello64 */ #include /* clock_t, clock, CLOCKS_PER_SEC */ #include /* toupper */ +#include /* errno */ #include "mem.h" #define ZSTD_STATIC_LINKING_ONLY