From 849ecf35103a3ea76f41196e63ccf2f076278fa4 Mon Sep 17 00:00:00 2001 From: Nick Terrell Date: Fri, 23 Jun 2017 16:54:16 -0700 Subject: [PATCH] [zstdcli] Support xz by default when liblzma is available --- programs/Makefile | 17 +++++++---------- programs/fileio.c | 14 +++++++------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/programs/Makefile b/programs/Makefile index ab2db728..e956a7df 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -139,16 +139,13 @@ all: zstd $(ZSTDDECOMP_O): CFLAGS += $(ALIGN_LOOP) -zstd xzstd zstd4 xzstd4 : CPPFLAGS += $(THREAD_CPP) $(ZLIBCPP) -zstd xzstd zstd4 xzstd4 : LDFLAGS += $(THREAD_LD) $(ZLIBLD) -xzstd xzstd4 : CPPFLAGS += $(LZMACPP) -xzstd xzstd4 : LDFLAGS += $(LZMALD) -zstd4 xzstd4 : CPPFLAGS += $(LZ4CPP) -zstd4 xzstd4 : LDFLAGS += $(LZ4LD) -zstd zstd4 : LZMA_MSG := - xz/lzma support is disabled -zstd xzstd : LZ4_MSG := - lz4 support is disabled -zstd xzstd zstd4 xzstd4 : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) -zstd xzstd zstd4 xzstd4 : $(ZSTDLIB_FILES) zstdcli.o fileio.o bench.o datagen.o dibio.o +zstd zstd4 : CPPFLAGS += $(THREAD_CPP) $(ZLIBCPP) $(LZMACPP) +zstd zstd4 : LDFLAGS += $(THREAD_LD) $(ZLIBLD) $(LZMALD) +zstd4 : CPPFLAGS += $(LZ4CPP) +zstd4 : LDFLAGS += $(LZ4LD) +zstd : LZ4_MSG := - lz4 support is disabled +zstd zstd4 : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) +zstd zstd4 : $(ZSTDLIB_FILES) zstdcli.o fileio.o bench.o datagen.o dibio.o @echo "$(THREAD_MSG)" @echo "$(ZLIB_MSG)" @echo "$(LZMA_MSG)" diff --git a/programs/fileio.c b/programs/fileio.c index 78ac3ba6..77943717 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -559,7 +559,7 @@ static unsigned long long FIO_compressLzmaFrame(cRess_t* ress, strm.next_in = 0; strm.avail_in = 0; - strm.next_out = ress->dstBuffer; + strm.next_out = (BYTE*)ress->dstBuffer; strm.avail_out = ress->dstBufferSize; while (1) { @@ -567,7 +567,7 @@ static unsigned long long FIO_compressLzmaFrame(cRess_t* ress, size_t const inSize = fread(ress->srcBuffer, 1, ress->srcBufferSize, ress->srcFile); if (inSize == 0) action = LZMA_FINISH; inFileSize += inSize; - strm.next_in = ress->srcBuffer; + strm.next_in = (BYTE const*)ress->srcBuffer; strm.avail_in = inSize; } @@ -580,7 +580,7 @@ static unsigned long long FIO_compressLzmaFrame(cRess_t* ress, if (fwrite(ress->dstBuffer, 1, compBytes, ress->dstFile) != compBytes) EXM_THROW(73, "Write error : cannot write to output file"); outFileSize += compBytes; - strm.next_out = ress->dstBuffer; + strm.next_out = (BYTE*)ress->dstBuffer; strm.avail_out = ress->dstBufferSize; } } if (!srcFileSize) @@ -1490,16 +1490,16 @@ static unsigned long long FIO_decompressLzmaFrame(dRess_t* ress, FILE* srcFile, EXM_THROW(71, "zstd: %s: lzma_alone_decoder/lzma_stream_decoder error %d", srcFileName, ret); - strm.next_out = ress->dstBuffer; + strm.next_out = (BYTE*)ress->dstBuffer; strm.avail_out = ress->dstBufferSize; + strm.next_in = (BYTE const*)ress->srcBuffer; strm.avail_in = ress->srcBufferLoaded; - strm.next_in = ress->srcBuffer; for ( ; ; ) { if (strm.avail_in == 0) { ress->srcBufferLoaded = fread(ress->srcBuffer, 1, ress->srcBufferSize, srcFile); if (ress->srcBufferLoaded == 0) action = LZMA_FINISH; - strm.next_in = ress->srcBuffer; + strm.next_in = (BYTE const*)ress->srcBuffer; strm.avail_in = ress->srcBufferLoaded; } ret = lzma_code(&strm, action); @@ -1515,7 +1515,7 @@ static unsigned long long FIO_decompressLzmaFrame(dRess_t* ress, FILE* srcFile, if (fwrite(ress->dstBuffer, 1, decompBytes, ress->dstFile) != decompBytes) EXM_THROW(31, "Write error : cannot write to output file"); outFileSize += decompBytes; - strm.next_out = ress->dstBuffer; + strm.next_out = (BYTE*)ress->dstBuffer; strm.avail_out = ress->dstBufferSize; } } if (ret == LZMA_STREAM_END) break;