From 2c4b6fe6b3d53eff421841200dead4dc314bf077 Mon Sep 17 00:00:00 2001 From: Sean Purcell Date: Tue, 25 Apr 2017 11:00:54 -0700 Subject: [PATCH] Make lz4 compression/decompression compatible with library r123 --- programs/Makefile | 2 +- programs/fileio.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/programs/Makefile b/programs/Makefile index b3763484e..2619614c5 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -118,7 +118,7 @@ LZMA_MSG := $(NO_LZMA_MSG) endif # lz4 detection NO_LZ4_MSG := ==> no liblz4, building zstd without .lz4 support -HAVE_LZ4 := $(shell printf '\#include \nint main(void) { return 0; }' | $(CC) $(FLAGS) -o have_lz4$(EXT) -x c - -llz4 2> $(VOID) && rm have_lz4$(EXT) && echo 1 || echo 0) +HAVE_LZ4 := $(shell printf '\#include \n\#include \nint main(void) { return 0; }' | $(CC) $(FLAGS) -o have_lz4$(EXT) -x c - -llz4 2> $(VOID) && rm have_lz4$(EXT) && echo 1 || echo 0) ifeq ($(HAVE_LZ4), 1) LZ4_MSG := ==> building zstd with .lz4 compression support LZ4CPP = -DZSTD_LZ4COMPRESS -DZSTD_LZ4DECOMPRESS diff --git a/programs/fileio.c b/programs/fileio.c index 1b54256ec..2bf5cb209 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -56,6 +56,7 @@ #define LZ4_MAGICNUMBER 0x184D2204 #if defined(ZSTD_LZ4COMPRESS) || defined(ZSTD_LZ4DECOMPRESS) # include +# include #endif @@ -526,7 +527,7 @@ static unsigned long long FIO_compressLz4Frame(cRess_t* ress, const char* srcFil unsigned long long inFileSize = 0, outFileSize = 0; LZ4F_preferences_t prefs; - LZ4F_cctx* ctx; + LZ4F_compressionContext_t ctx; LZ4F_errorCode_t const errorCode = LZ4F_createCompressionContext(&ctx, LZ4F_VERSION); if (LZ4F_isError(errorCode)) EXM_THROW(31, "zstd: failed to create lz4 compression context"); @@ -535,13 +536,15 @@ static unsigned long long FIO_compressLz4Frame(cRess_t* ress, const char* srcFil prefs.autoFlush = 1; prefs.compressionLevel = compressionLevel; - prefs.frameInfo.blockMode = LZ4F_blockIndependent; /* stick to defaults for lz4 cli */ - prefs.frameInfo.blockSizeID = LZ4F_max4MB; - prefs.frameInfo.contentChecksumFlag = (LZ4F_contentChecksum_t)g_checksumFlag; + prefs.frameInfo.blockMode = blockIndependent; /* stick to defaults for lz4 cli */ + prefs.frameInfo.blockSizeID = max4MB; + prefs.frameInfo.contentChecksumFlag = (contentChecksum_t)g_checksumFlag; +#if LZ4_VERSION_NUMBER >= 10600 prefs.frameInfo.contentSize = srcFileSize; +#endif { - size_t blockSize = FIO_LZ4_GetBlockSize_FromBlockId(LZ4F_max4MB); + size_t blockSize = FIO_LZ4_GetBlockSize_FromBlockId(max4MB); size_t readSize; size_t headerSize = LZ4F_compressBegin(ctx, ress->dstBuffer, ress->dstBufferSize, &prefs); if (LZ4F_isError(headerSize)) EXM_THROW(33, "File header generation failed : %s", LZ4F_getErrorName(headerSize)); @@ -1127,7 +1130,7 @@ static unsigned long long FIO_decompressLz4Frame(dRess_t* ress, FILE* srcFile, c { unsigned long long filesize = 0; LZ4F_errorCode_t nextToLoad; - LZ4F_dctx* dCtx; + LZ4F_decompressionContext_t dCtx; LZ4F_errorCode_t const errorCode = LZ4F_createDecompressionContext(&dCtx, LZ4F_VERSION); if (LZ4F_isError(errorCode)) EXM_THROW(61, "zstd: failed to create lz4 decompression context"); -- 2.47.2