[zstdcli] Support xz by default when liblzma is available

This commit is contained in:
Nick Terrell 2017-06-23 16:54:16 -07:00
parent 379f9d874d
commit 849ecf3510
2 changed files with 14 additions and 17 deletions

View File

@ -139,16 +139,13 @@ all: zstd
$(ZSTDDECOMP_O): CFLAGS += $(ALIGN_LOOP) $(ZSTDDECOMP_O): CFLAGS += $(ALIGN_LOOP)
zstd xzstd zstd4 xzstd4 : CPPFLAGS += $(THREAD_CPP) $(ZLIBCPP) zstd zstd4 : CPPFLAGS += $(THREAD_CPP) $(ZLIBCPP) $(LZMACPP)
zstd xzstd zstd4 xzstd4 : LDFLAGS += $(THREAD_LD) $(ZLIBLD) zstd zstd4 : LDFLAGS += $(THREAD_LD) $(ZLIBLD) $(LZMALD)
xzstd xzstd4 : CPPFLAGS += $(LZMACPP) zstd4 : CPPFLAGS += $(LZ4CPP)
xzstd xzstd4 : LDFLAGS += $(LZMALD) zstd4 : LDFLAGS += $(LZ4LD)
zstd4 xzstd4 : CPPFLAGS += $(LZ4CPP) zstd : LZ4_MSG := - lz4 support is disabled
zstd4 xzstd4 : LDFLAGS += $(LZ4LD) zstd zstd4 : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
zstd zstd4 : LZMA_MSG := - xz/lzma support is disabled zstd zstd4 : $(ZSTDLIB_FILES) zstdcli.o fileio.o bench.o datagen.o dibio.o
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
@echo "$(THREAD_MSG)" @echo "$(THREAD_MSG)"
@echo "$(ZLIB_MSG)" @echo "$(ZLIB_MSG)"
@echo "$(LZMA_MSG)" @echo "$(LZMA_MSG)"

View File

@ -559,7 +559,7 @@ static unsigned long long FIO_compressLzmaFrame(cRess_t* ress,
strm.next_in = 0; strm.next_in = 0;
strm.avail_in = 0; strm.avail_in = 0;
strm.next_out = ress->dstBuffer; strm.next_out = (BYTE*)ress->dstBuffer;
strm.avail_out = ress->dstBufferSize; strm.avail_out = ress->dstBufferSize;
while (1) { 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); size_t const inSize = fread(ress->srcBuffer, 1, ress->srcBufferSize, ress->srcFile);
if (inSize == 0) action = LZMA_FINISH; if (inSize == 0) action = LZMA_FINISH;
inFileSize += inSize; inFileSize += inSize;
strm.next_in = ress->srcBuffer; strm.next_in = (BYTE const*)ress->srcBuffer;
strm.avail_in = inSize; 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) if (fwrite(ress->dstBuffer, 1, compBytes, ress->dstFile) != compBytes)
EXM_THROW(73, "Write error : cannot write to output file"); EXM_THROW(73, "Write error : cannot write to output file");
outFileSize += compBytes; outFileSize += compBytes;
strm.next_out = ress->dstBuffer; strm.next_out = (BYTE*)ress->dstBuffer;
strm.avail_out = ress->dstBufferSize; strm.avail_out = ress->dstBufferSize;
} } } }
if (!srcFileSize) 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", EXM_THROW(71, "zstd: %s: lzma_alone_decoder/lzma_stream_decoder error %d",
srcFileName, ret); srcFileName, ret);
strm.next_out = ress->dstBuffer; strm.next_out = (BYTE*)ress->dstBuffer;
strm.avail_out = ress->dstBufferSize; strm.avail_out = ress->dstBufferSize;
strm.next_in = (BYTE const*)ress->srcBuffer;
strm.avail_in = ress->srcBufferLoaded; strm.avail_in = ress->srcBufferLoaded;
strm.next_in = ress->srcBuffer;
for ( ; ; ) { for ( ; ; ) {
if (strm.avail_in == 0) { if (strm.avail_in == 0) {
ress->srcBufferLoaded = fread(ress->srcBuffer, 1, ress->srcBufferSize, srcFile); ress->srcBufferLoaded = fread(ress->srcBuffer, 1, ress->srcBufferSize, srcFile);
if (ress->srcBufferLoaded == 0) action = LZMA_FINISH; if (ress->srcBufferLoaded == 0) action = LZMA_FINISH;
strm.next_in = ress->srcBuffer; strm.next_in = (BYTE const*)ress->srcBuffer;
strm.avail_in = ress->srcBufferLoaded; strm.avail_in = ress->srcBufferLoaded;
} }
ret = lzma_code(&strm, action); 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) if (fwrite(ress->dstBuffer, 1, decompBytes, ress->dstFile) != decompBytes)
EXM_THROW(31, "Write error : cannot write to output file"); EXM_THROW(31, "Write error : cannot write to output file");
outFileSize += decompBytes; outFileSize += decompBytes;
strm.next_out = ress->dstBuffer; strm.next_out = (BYTE*)ress->dstBuffer;
strm.avail_out = ress->dstBufferSize; strm.avail_out = ress->dstBufferSize;
} } } }
if (ret == LZMA_STREAM_END) break; if (ret == LZMA_STREAM_END) break;