Merge branch 'dev' of github.com:Cyan4973/lz4 into dev
This commit is contained in:
commit
f6a7c6b578
114
.travis.yml
114
.travis.yml
@ -4,57 +4,29 @@ matrix:
|
||||
include:
|
||||
# OS X Mavericks
|
||||
- os: osx
|
||||
env: Ubu="OS X Mavericks" PARAMS='-C tests test-lz4 CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion"' COMPILER=clang
|
||||
env: Ubu=OS_X_Mavericks Cmd='make -C tests test-lz4 CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion"' COMPILER=clang
|
||||
|
||||
# Container-based 12.04 LTS Server Edition 64 bit (doesn't support 32-bit includes)
|
||||
- os: linux
|
||||
sudo: false
|
||||
env: Ubu="12.04cont" PARAMS="install PREFIX=~/install_test_dir" COMPILER=cc
|
||||
env: Ubu=12.04cont Cmd="make gpptest && make clean && make examples && make clean && make cmake && make clean && make travis-install" COMPILER=cc
|
||||
- os: linux
|
||||
sudo: false
|
||||
env: Ubu="12.04cont" PARAMS="examples" COMPILER=cc
|
||||
env: Ubu=12.04cont Cmd='make test' COMPILER=cc
|
||||
- os: linux
|
||||
sudo: false
|
||||
env: Ubu="12.04cont" PARAMS="cmake" COMPILER=cc
|
||||
- os: linux
|
||||
sudo: false
|
||||
env: Ubu="12.04cont" PARAMS=clangtest COMPILER=clang
|
||||
- os: linux
|
||||
sudo: false
|
||||
env: Ubu="12.04cont" PARAMS=gpptest COMPILER=cc
|
||||
- os: linux
|
||||
sudo: false
|
||||
env: Ubu="12.04cont" PARAMS='-C tests test-lz4' COMPILER=cc
|
||||
- os: linux
|
||||
sudo: false
|
||||
env: Ubu="12.04cont" PARAMS='-C tests test-lz4 MOREFLAGS="-std=c99"' COMPILER=cc
|
||||
- os: linux
|
||||
sudo: false
|
||||
env: Ubu="12.04cont" PARAMS='-C tests test-lz4c' COMPILER=cc
|
||||
- os: linux
|
||||
sudo: false
|
||||
env: Ubu="12.04cont" PARAMS='-C tests test-fullbench' COMPILER=cc
|
||||
- os: linux
|
||||
sudo: false
|
||||
env: Ubu="12.04cont" PARAMS='-C tests test-fuzzer' COMPILER=cc
|
||||
- os: linux
|
||||
sudo: false
|
||||
env: Ubu="12.04cont" PARAMS='-C tests test-frametest' COMPILER=cc
|
||||
env: Ubu=12.04cont Cmd='make clangtest' COMPILER=clang
|
||||
|
||||
# 14.04 LTS Server Edition 64 bit
|
||||
- env: Ubu="14.04" PARAMS=sanitize COMPILER=clang
|
||||
- env: Ubu=14.04 Cmd='make staticAnalyze sanitize' COMPILER=clang
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- valgrind
|
||||
- env: Ubu="14.04" PARAMS=staticAnalyze COMPILER=clang
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang
|
||||
- env: Ubu="14.04" PARAMS=armtest COMPILER=arm-linux-gnueabi-gcc
|
||||
- env: Ubu=14.04 Cmd='make armtest' COMPILER=arm-linux-gnueabi-gcc
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
@ -63,7 +35,14 @@ matrix:
|
||||
- gcc-arm-linux-gnueabi
|
||||
- libc6-dev-armel-cross
|
||||
- linux-libc-dev-armel-cross
|
||||
- env: Ubu="14.04" PARAMS=versionsTest COMPILER=cc
|
||||
- env: Ubu=14.04 Cmd='make c_standards && make -C tests test-lz4 test-mem' COMPILER=cc
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- valgrind
|
||||
- env: Ubu=14.04 Cmd='make -C tests test32 versionsTest' COMPILER=cc
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
@ -72,27 +51,7 @@ matrix:
|
||||
- python3
|
||||
- libc6-dev-i386
|
||||
- gcc-multilib
|
||||
- env: Ubu="14.04" PARAMS='-C tests test-lz4' COMPILER=cc
|
||||
dist: trusty
|
||||
sudo: required
|
||||
- env: Ubu="14.04" PARAMS='-C tests test-lz4c32' COMPILER=cc
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc6-dev-i386
|
||||
- gcc-multilib
|
||||
- env: Ubu="14.04" PARAMS='-C tests test-lz4 CC=gcc-5' COMPILER=gcc-5
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- gcc-5
|
||||
- env: Ubu="14.04" PARAMS='-C tests test-lz4c32 CC=gcc-5' COMPILER=gcc-5
|
||||
- env: Ubu=14.04 Cmd='make -C tests test-lz4 test-lz4c32 CC=gcc-5 MOREFLAGS="-Werror"' COMPILER=gcc-5
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
@ -104,7 +63,7 @@ matrix:
|
||||
- gcc-multilib
|
||||
- gcc-5
|
||||
- gcc-5-multilib
|
||||
- env: Ubu="14.04" PARAMS='-C tests test-lz4 CC=gcc-6' COMPILER=gcc-6
|
||||
- env: Ubu=14.04 Cmd='make c_standards CC=gcc-6 && make -C tests test-lz4 CC=gcc-6 MOREFLAGS="-Werror"' COMPILER=gcc-6
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
@ -113,7 +72,7 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- gcc-6
|
||||
- env: Ubu="14.04" PARAMS='-C tests test-lz4 CC=clang-3.8' COMPILER=clang-3.8
|
||||
- env: Ubu=14.04 Cmd='make -C tests test-lz4 CC=clang-3.8' COMPILER=clang-3.8
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
@ -123,39 +82,8 @@ matrix:
|
||||
- llvm-toolchain-precise-3.8
|
||||
packages:
|
||||
- clang-3.8
|
||||
- env: Ubu="14.04" PARAMS='-C tests test-fullbench32' COMPILER=cc
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc6-dev-i386
|
||||
- gcc-multilib
|
||||
- env: Ubu="14.04" PARAMS='-C tests test-fuzzer32' COMPILER=cc
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc6-dev-i386
|
||||
- gcc-multilib
|
||||
- env: Ubu="14.04" PARAMS='-C tests test-frametest32' COMPILER=cc
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc6-dev-i386
|
||||
- gcc-multilib
|
||||
- env: Ubu="14.04" PARAMS='-C tests test-mem' COMPILER=cc
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- valgrind
|
||||
|
||||
script:
|
||||
- echo PARAMS=$PARAMS
|
||||
- echo Cmd=$Cmd
|
||||
- $COMPILER -v
|
||||
- sh -c "make $PARAMS"
|
||||
- sh -c "$Cmd"
|
||||
|
24
Makefile
24
Makefile
@ -85,7 +85,7 @@ uninstall:
|
||||
@$(MAKE) -C $(PRGDIR) $@
|
||||
|
||||
travis-install:
|
||||
sudo $(MAKE) install
|
||||
$(MAKE) install PREFIX=~/install_test_dir
|
||||
|
||||
test:
|
||||
$(MAKE) -C $(TESTDIR) test
|
||||
@ -96,19 +96,29 @@ cmake:
|
||||
gpptest: clean
|
||||
$(MAKE) all CC=g++ CFLAGS="-O3 -I../lib -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
|
||||
|
||||
c_standards: clean
|
||||
$(MAKE) all CFLAGS="-std=gnu90"
|
||||
$(MAKE) clean
|
||||
$(MAKE) all CFLAGS="-std=c99"
|
||||
$(MAKE) clean
|
||||
$(MAKE) all CFLAGS="-std=gnu99"
|
||||
$(MAKE) clean
|
||||
$(MAKE) all CFLAGS="-std=c11"
|
||||
$(MAKE) clean
|
||||
|
||||
clangtest: clean
|
||||
CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) all CC=clang
|
||||
$(MAKE) all CC=clang CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion"
|
||||
|
||||
sanitize: clean
|
||||
CFLAGS="-O3 -g -fsanitize=undefined" $(MAKE) test CC=clang FUZZER_TIME="-T1mn" NB_LOOPS=-i1
|
||||
$(MAKE) test CC=clang FUZZER_TIME="-T1mn" NB_LOOPS=-i1 CFLAGS="-O3 -g -fsanitize=undefined"
|
||||
|
||||
staticAnalyze: clean
|
||||
CFLAGS=-g scan-build --status-bugs -v $(MAKE) all
|
||||
scan-build --status-bugs -v $(MAKE) all CFLAGS=-g
|
||||
|
||||
armtest: clean
|
||||
CFLAGS="-O3 -Werror" $(MAKE) -C $(LZ4DIR) all CC=arm-linux-gnueabi-gcc
|
||||
CFLAGS="-O3 -Werror" $(MAKE) -C $(PRGDIR) bins CC=arm-linux-gnueabi-gcc
|
||||
CFLAGS="-O3 -Werror" $(MAKE) -C $(TESTDIR) bins CC=arm-linux-gnueabi-gcc
|
||||
$(MAKE) -C $(LZ4DIR) all CC=arm-linux-gnueabi-gcc CFLAGS="-O3 -Werror"
|
||||
$(MAKE) -C $(PRGDIR) bins CC=arm-linux-gnueabi-gcc CFLAGS="-O3 -Werror"
|
||||
$(MAKE) -C $(TESTDIR) bins CC=arm-linux-gnueabi-gcc CFLAGS="-O3 -Werror"
|
||||
|
||||
versionsTest: clean
|
||||
$(MAKE) -C $(TESTDIR) $@
|
||||
|
13
appveyor.yml
13
appveyor.yml
@ -14,13 +14,10 @@ environment:
|
||||
CONFIGURATION: "Release"
|
||||
PLATFORM: "Win32"
|
||||
- COMPILER: "gcc"
|
||||
MAKE_PARAMS: "-C programs lz4 fullbench"
|
||||
PLATFORM: "mingw64"
|
||||
- COMPILER: "gcc"
|
||||
MAKE_PARAMS: "-C programs lz4 fullbench"
|
||||
PLATFORM: "mingw32"
|
||||
- COMPILER: "gcc"
|
||||
MAKE_PARAMS: '-C programs lz4 fullbench CC=clang MOREFLAGS="--target=x86_64-w64-mingw32 -Werror -Wconversion -Wno-sign-conversion"'
|
||||
PLATFORM: "clang"
|
||||
|
||||
install:
|
||||
@ -48,9 +45,15 @@ build_script:
|
||||
echo ----- &&
|
||||
make -v &&
|
||||
echo ----- &&
|
||||
ECHO make -%MAKE_PARAMS%- &&
|
||||
make %MAKE_PARAMS%
|
||||
if not [%PLATFORM%]==[clang] (
|
||||
make -C programs lz4 && make -C tests fullbench
|
||||
) ELSE (
|
||||
make -C programs lz4 CC=clang MOREFLAGS="--target=x86_64-w64-mingw32 -Werror -Wconversion -Wno-sign-conversion" &&
|
||||
make -C tests fullbench CC=clang MOREFLAGS="--target=x86_64-w64-mingw32 -Werror -Wconversion -Wno-sign-conversion"
|
||||
)
|
||||
)
|
||||
- if [%COMPILER%]==[gcc] (COPY tests\fullbench.exe programs\)
|
||||
- if [%COMPILER%]==[visual] (
|
||||
ECHO *** &&
|
||||
ECHO *** Building Visual Studio 2010 %PLATFORM%\%CONFIGURATION% &&
|
||||
ECHO *** &&
|
||||
|
@ -1366,7 +1366,7 @@ int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const ch
|
||||
lz4sd->prefixEnd += originalSize;
|
||||
} else {
|
||||
lz4sd->extDictSize = lz4sd->prefixSize;
|
||||
lz4sd->externalDict = (BYTE*)dest - lz4sd->extDictSize;
|
||||
lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize;
|
||||
result = LZ4_decompress_generic(source, dest, 0, originalSize,
|
||||
endOnOutputSize, full, 0,
|
||||
usingExtDict, (BYTE*)dest, lz4sd->externalDict, lz4sd->extDictSize);
|
||||
|
@ -66,7 +66,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define LZ4F_DEPRECATE(x) __declspec(deprecated) x
|
||||
# define LZ4F_DEPRECATE(x) x /* __declspec(deprecated) x - only works with C++ */
|
||||
#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6))
|
||||
# define LZ4F_DEPRECATE(x) x __attribute__((deprecated))
|
||||
#else
|
||||
@ -274,7 +274,7 @@ typedef struct {
|
||||
* That is, it should be == 0 if decompression has been completed fully and correctly.
|
||||
*/
|
||||
LZ4FLIB_API LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx** dctxPtr, unsigned version);
|
||||
LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx* dctx);
|
||||
LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx* const dctx);
|
||||
|
||||
|
||||
/*====== Decompression ======*/
|
||||
|
@ -149,6 +149,7 @@ static int usage(void)
|
||||
DISPLAY( " -d : decompression (default for %s extension)\n", LZ4_EXTENSION);
|
||||
DISPLAY( " -z : force compression\n");
|
||||
DISPLAY( " -f : overwrite output without prompting \n");
|
||||
DISPLAY( "--rm : remove source file(s) after successful de/compression \n");
|
||||
DISPLAY( " -h/-H : display help/long help and exit\n");
|
||||
return 0;
|
||||
}
|
||||
@ -326,7 +327,7 @@ int main(int argc, const char** argv)
|
||||
if ((!strcmp(argument, "--decompress"))
|
||||
|| (!strcmp(argument, "--uncompress"))) { decode = 1; continue; }
|
||||
if (!strcmp(argument, "--multiple")) { multiple_inputs = 1; if (inFileNames==NULL) inFileNames = (const char**)malloc(argc * sizeof(char*)); continue; }
|
||||
if (!strcmp(argument, "--test")) { decode = 1; LZ4IO_setOverwrite(1); output_filename=nulmark; continue; }
|
||||
if (!strcmp(argument, "--test")) { decode = 1; LZ4IO_setTestMode(1); output_filename=nulmark; continue; }
|
||||
if (!strcmp(argument, "--force")) { LZ4IO_setOverwrite(1); continue; }
|
||||
if (!strcmp(argument, "--no-force")) { LZ4IO_setOverwrite(0); continue; }
|
||||
if ((!strcmp(argument, "--stdout"))
|
||||
@ -340,7 +341,8 @@ int main(int argc, const char** argv)
|
||||
if (!strcmp(argument, "--verbose")) { displayLevel=4; continue; }
|
||||
if (!strcmp(argument, "--quiet")) { if (displayLevel) displayLevel--; continue; }
|
||||
if (!strcmp(argument, "--version")) { DISPLAY(WELCOME_MESSAGE); return 0; }
|
||||
if (!strcmp(argument, "--keep")) { continue; } /* keep source file (default anyway; just for xz/lzma compatibility) */
|
||||
if (!strcmp(argument, "--keep")) { LZ4IO_setRemoveSrcFile(0); continue; } /* keep source file (default anyway; just for xz/lzma compatibility) */
|
||||
if (!strcmp(argument, "--rm")) { LZ4IO_setRemoveSrcFile(1); continue; }
|
||||
|
||||
/* Short commands (note : aggregated short commands are allowed) */
|
||||
if (argument[0]=='-') {
|
||||
@ -406,7 +408,7 @@ int main(int argc, const char** argv)
|
||||
case 'q': if (displayLevel) displayLevel--; break;
|
||||
|
||||
/* keep source file (default anyway, so useless) (for xz/lzma compatibility) */
|
||||
case 'k': break;
|
||||
case 'k': LZ4IO_setRemoveSrcFile(0); break;
|
||||
|
||||
/* Modify Block Properties */
|
||||
case 'B':
|
||||
|
@ -33,14 +33,7 @@
|
||||
/**************************************
|
||||
* Compiler Options
|
||||
**************************************/
|
||||
#ifdef _MSC_VER /* Visual Studio */
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
# define _CRT_SECURE_NO_DEPRECATE /* VS2005 */
|
||||
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
||||
#endif
|
||||
|
||||
#define _LARGE_FILES /* Large file support on 32-bits AIX */
|
||||
#define _FILE_OFFSET_BITS 64 /* Large file support on 32-bits unix */
|
||||
|
||||
#if defined(__MINGW32__) && !defined(_POSIX_SOURCE)
|
||||
# define _POSIX_SOURCE 1 /* disable %llu warnings with MinGW on Windows */
|
||||
@ -49,6 +42,7 @@
|
||||
/*****************************
|
||||
* Includes
|
||||
*****************************/
|
||||
#include "util.h" /* Compiler options, UTIL_getFileStat */
|
||||
#include <stdio.h> /* fprintf, fopen, fread, stdin, stdout, fflush, getchar */
|
||||
#include <stdlib.h> /* malloc, free */
|
||||
#include <string.h> /* strcmp, strlen */
|
||||
@ -84,10 +78,6 @@
|
||||
# define SET_SPARSE_FILE_MODE(file)
|
||||
#endif
|
||||
|
||||
#if !defined(S_ISREG)
|
||||
# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************
|
||||
* Constants
|
||||
@ -242,19 +232,9 @@ int LZ4IO_setContentSize(int enable)
|
||||
return g_contentSizeFlag;
|
||||
}
|
||||
|
||||
static unsigned long long LZ4IO_GetFileSize(const char* infilename)
|
||||
{
|
||||
int r;
|
||||
#if defined(_MSC_VER)
|
||||
struct _stat64 statbuf;
|
||||
r = _stat64(infilename, &statbuf);
|
||||
#else
|
||||
struct stat statbuf;
|
||||
r = stat(infilename, &statbuf);
|
||||
#endif
|
||||
if (r || !S_ISREG(statbuf.st_mode)) return 0; /* failure, or is not a regular file */
|
||||
return (unsigned long long)statbuf.st_size;
|
||||
}
|
||||
static U32 g_removeSrcFile = 0;
|
||||
void LZ4IO_setRemoveSrcFile(unsigned flag) { g_removeSrcFile = (flag>0); }
|
||||
|
||||
|
||||
|
||||
/* ************************************************************************ **
|
||||
@ -465,7 +445,6 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName,
|
||||
LZ4F_compressionContext_t ctx = ress.ctx; /* just a pointer */
|
||||
LZ4F_preferences_t prefs;
|
||||
|
||||
|
||||
/* Init */
|
||||
memset(&prefs, 0, sizeof(prefs));
|
||||
|
||||
@ -479,7 +458,7 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName,
|
||||
prefs.frameInfo.blockSizeID = (LZ4F_blockSizeID_t)g_blockSizeId;
|
||||
prefs.frameInfo.contentChecksumFlag = (LZ4F_contentChecksum_t)g_streamChecksum;
|
||||
if (g_contentSizeFlag) {
|
||||
unsigned long long const fileSize = LZ4IO_GetFileSize(srcFileName);
|
||||
U64 const fileSize = UTIL_getFileSize(srcFileName);
|
||||
prefs.frameInfo.contentSize = fileSize; /* == 0 if input == stdin */
|
||||
if (fileSize==0)
|
||||
DISPLAYLEVEL(3, "Warning : cannot determine input content size \n");
|
||||
@ -547,6 +526,14 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName,
|
||||
fclose (srcFile);
|
||||
fclose (dstFile);
|
||||
|
||||
/* Copy owner, file permissions and modification time */
|
||||
{ stat_t statbuf;
|
||||
if (strcmp (srcFileName, stdinmark) && strcmp (dstFileName, stdoutmark) && UTIL_getFileStat(srcFileName, &statbuf))
|
||||
UTIL_setFileStat(dstFileName, &statbuf);
|
||||
}
|
||||
|
||||
if (g_removeSrcFile) { if (remove(srcFileName)) EXM_THROW(39, "Remove error : %s: %s", srcFileName, strerror(errno)); } /* remove source file : --rm */
|
||||
|
||||
/* Final Status */
|
||||
DISPLAYLEVEL(2, "\r%79s\r", "");
|
||||
DISPLAYLEVEL(2, "Compressed %llu bytes into %llu bytes ==> %.2f%%\n",
|
||||
@ -946,14 +933,22 @@ static int LZ4IO_decompressFile_extRess(dRess_t ress, const char* input_filename
|
||||
filesize += decodedSize;
|
||||
} while (decodedSize != ENDOFSTREAM);
|
||||
|
||||
/* Final Status */
|
||||
DISPLAYLEVEL(2, "\r%79s\r", "");
|
||||
DISPLAYLEVEL(2, "Successfully decoded %llu bytes \n", filesize);
|
||||
|
||||
/* Close */
|
||||
fclose(finput);
|
||||
fclose(foutput);
|
||||
|
||||
/* Copy owner, file permissions and modification time */
|
||||
{ stat_t statbuf;
|
||||
if (strcmp (input_filename, stdinmark) && strcmp (output_filename, stdoutmark) && UTIL_getFileStat(input_filename, &statbuf))
|
||||
UTIL_setFileStat(output_filename, &statbuf);
|
||||
}
|
||||
|
||||
if (g_removeSrcFile) { if (remove(input_filename)) EXM_THROW(45, "Remove error : %s: %s", input_filename, strerror(errno)); } /* remove source file : --rm */
|
||||
|
||||
/* Final Status */
|
||||
DISPLAYLEVEL(2, "\r%79s\r", "");
|
||||
DISPLAYLEVEL(2, "Successfully decoded %llu bytes \n", filesize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -89,3 +89,5 @@ int LZ4IO_setSparseFile(int enable);
|
||||
|
||||
/* Default setting : 0 (disabled) */
|
||||
int LZ4IO_setContentSize(int enable);
|
||||
|
||||
void LZ4IO_setRemoveSrcFile(unsigned flag);
|
||||
|
@ -97,6 +97,9 @@ frametest: $(LZ4DIR)/lz4frame.o $(LZ4DIR)/lz4.o $(LZ4DIR)/lz4hc.o $(LZ4DIR)/xxha
|
||||
frametest32: $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c frametest.c
|
||||
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
|
||||
|
||||
fasttest: $(LZ4DIR)/lz4.o fasttest.c
|
||||
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
||||
|
||||
datagen : $(PRGDIR)/datagen.c datagencli.c
|
||||
$(CC) $(FLAGS) -I$(PRGDIR) $^ -o $@$(EXT)
|
||||
|
||||
@ -119,9 +122,9 @@ versionsTest:
|
||||
#FreeBSD targets
|
||||
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD))
|
||||
|
||||
test: test-lz4 test-lz4c test-frametest test-fullbench test-fuzzer test-mem
|
||||
test: test-lz4 test-lz4c test-fasttest test-frametest test-fullbench test-fuzzer
|
||||
|
||||
test32: test-lz4c32 test-frametest32 test-fullbench32 test-fuzzer32 test-mem32
|
||||
test32: test-lz4c32 test-frametest32 test-fullbench32 test-fuzzer32
|
||||
|
||||
test-all: test test32
|
||||
|
||||
@ -267,6 +270,9 @@ test-frametest: frametest
|
||||
test-frametest32: frametest32
|
||||
./frametest32 $(FUZZER_TIME)
|
||||
|
||||
test-fasttest: fasttest
|
||||
./fasttest
|
||||
|
||||
test-mem: lz4 datagen fuzzer frametest fullbench
|
||||
@echo "\n ---- valgrind tests : memory analyzer ----"
|
||||
valgrind --leak-check=yes --error-exitcode=1 ./datagen -g50M > $(VOID)
|
||||
|
138
tests/fasttest.c
Normal file
138
tests/fasttest.c
Normal file
@ -0,0 +1,138 @@
|
||||
/**************************************
|
||||
* Compiler Options
|
||||
**************************************/
|
||||
#ifdef _MSC_VER /* Visual Studio */
|
||||
# define _CRT_SECURE_NO_WARNINGS // for MSVC
|
||||
# define snprintf sprintf_s
|
||||
#endif
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-braces" /* GCC bug 53119 : doesn't accept { 0 } as initializer (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119) */
|
||||
#endif
|
||||
|
||||
|
||||
/**************************************
|
||||
* Includes
|
||||
**************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "lz4.h"
|
||||
|
||||
|
||||
/* Returns non-zero on failure. */
|
||||
int test_compress(const char *input, int inSize, char *output, int outSize)
|
||||
{
|
||||
LZ4_stream_t lz4Stream_body = { 0 };
|
||||
LZ4_stream_t* lz4Stream = &lz4Stream_body;
|
||||
|
||||
int inOffset = 0;
|
||||
int outOffset = 0;
|
||||
|
||||
if (inSize & 3) return -1;
|
||||
|
||||
while (inOffset < inSize) {
|
||||
const int length = inSize >> 2;
|
||||
if (inSize > 1024) return -2;
|
||||
if (outSize - (outOffset + 8) < LZ4_compressBound(length)) return -3;
|
||||
{
|
||||
const int outBytes = LZ4_compress_continue(
|
||||
lz4Stream, input + inOffset, output + outOffset + 8, length);
|
||||
if(outBytes <= 0) return -4;
|
||||
memcpy(output + outOffset, &length, 4); /* input length */
|
||||
memcpy(output + outOffset + 4, &outBytes, 4); /* output length */
|
||||
inOffset += length;
|
||||
outOffset += outBytes + 8;
|
||||
}
|
||||
}
|
||||
if (outOffset + 8 > outSize) return -5;
|
||||
memset(output + outOffset, 0, 4);
|
||||
memset(output + outOffset + 4, 0, 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void swap(void **a, void **b) {
|
||||
void *tmp = *a;
|
||||
*a = *b;
|
||||
*b = tmp;
|
||||
}
|
||||
|
||||
/* Returns non-zero on failure. Not a safe function. */
|
||||
int test_decompress(const char *uncompressed, const char *compressed)
|
||||
{
|
||||
char outBufferA[1024];
|
||||
char spacing; /* So prefixEnd != dest */
|
||||
char outBufferB[1024];
|
||||
char *output = outBufferA;
|
||||
char *lastOutput = outBufferB;
|
||||
LZ4_streamDecode_t lz4StreamDecode_body = { 0 };
|
||||
LZ4_streamDecode_t* lz4StreamDecode = &lz4StreamDecode_body;
|
||||
int offset = 0;
|
||||
int unOffset = 0;
|
||||
int lastBytes = 0;
|
||||
|
||||
(void)spacing;
|
||||
|
||||
for(;;) {
|
||||
int32_t bytes;
|
||||
int32_t unBytes;
|
||||
/* Read uncompressed size and compressed size */
|
||||
memcpy(&unBytes, compressed + offset, 4);
|
||||
memcpy(&bytes, compressed + offset + 4, 4);
|
||||
offset += 8;
|
||||
/* Check if we reached end of stream or error */
|
||||
if(bytes == 0 && unBytes == 0) return 0;
|
||||
if(bytes <= 0 || unBytes <= 0 || unBytes > 1024) return 1;
|
||||
|
||||
/* Put the last output in the dictionary */
|
||||
LZ4_setStreamDecode(lz4StreamDecode, lastOutput, lastBytes);
|
||||
/* Decompress */
|
||||
bytes = LZ4_decompress_fast_continue(
|
||||
lz4StreamDecode, compressed + offset, output, unBytes);
|
||||
if(bytes <= 0) return 2;
|
||||
/* Check result */
|
||||
{
|
||||
int r = memcmp(uncompressed + unOffset, output, unBytes);
|
||||
if (r) return 3;
|
||||
}
|
||||
swap((void**)&output, (void**)&lastOutput);
|
||||
offset += bytes;
|
||||
unOffset += unBytes;
|
||||
lastBytes = unBytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char input[] =
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello!"
|
||||
"Hello Hello Hello Hello Hello Hello Hello Hello";
|
||||
char output[LZ4_COMPRESSBOUND(4096)];
|
||||
int r;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
if ((r = test_compress(input, sizeof(input), output, sizeof(output)))) {
|
||||
return r;
|
||||
}
|
||||
if ((r = test_decompress(input, output))) {
|
||||
return r;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -121,7 +121,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@ -140,7 +140,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
|
@ -121,7 +121,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@ -140,7 +140,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
|
@ -121,7 +121,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@ -140,7 +140,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
|
@ -121,7 +121,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@ -140,7 +140,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
|
@ -119,7 +119,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@ -137,7 +137,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
@ -28,24 +28,24 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@ -121,7 +121,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@ -140,7 +140,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
@ -157,6 +157,7 @@
|
||||
<ClInclude Include="..\..\..\lib\lz4frame_static.h" />
|
||||
<ClInclude Include="..\..\..\lib\lz4hc.h" />
|
||||
<ClInclude Include="..\..\..\lib\xxhash.h" />
|
||||
<ClInclude Include="..\..\..\programs\datagen.h" />
|
||||
<ClInclude Include="..\..\..\programs\bench.h" />
|
||||
<ClInclude Include="..\..\..\programs\lz4io.h" />
|
||||
</ItemGroup>
|
||||
@ -165,6 +166,7 @@
|
||||
<ClCompile Include="..\..\..\lib\lz4frame.c" />
|
||||
<ClCompile Include="..\..\..\lib\lz4hc.c" />
|
||||
<ClCompile Include="..\..\..\lib\xxhash.c" />
|
||||
<ClCompile Include="..\..\..\programs\datagen.c" />
|
||||
<ClCompile Include="..\..\..\programs\bench.c" />
|
||||
<ClCompile Include="..\..\..\programs\lz4cli.c" />
|
||||
<ClCompile Include="..\..\..\programs\lz4io.c" />
|
||||
|
Loading…
Reference in New Issue
Block a user