Implemented obsolete warning message

This commit is contained in:
Yann Collet 2015-04-11 18:59:22 +01:00
parent be9d248851
commit 973e385fa3
5 changed files with 125 additions and 116 deletions

3
NEWS
View File

@ -2,7 +2,8 @@ r129:
Added : LZ4_compress_fast() Added : LZ4_compress_fast()
Changed: New compression functions LZ4_compress_safe() - Suggested by Evan Nemerson & Takayuki Matsuoka Changed: New compression functions LZ4_compress_safe() - Suggested by Evan Nemerson & Takayuki Matsuoka
Added : AppVeyor CI environment, for Visual tests - Suggested by Takayuki Matsuoka Added : AppVeyor CI environment, for Visual tests - Suggested by Takayuki Matsuoka
Fixed : GCC 4.9+ optimization bug - Reported by Markus Trippelsdorf, Evan Nemerson and Greg Slazinski Fixed : GCC 4.9+ optimization bug - Reported by Markus Trippelsdorf, Greg Slazinski, Evan Nemerson & Takayuki Matsuoka
Modified:Obsolete functions generate warnings - Suggested by Evan Nemerson & Takayuki Matsuoka
Updated: Documentation converted to MarkDown Updated: Documentation converted to MarkDown
r128: r128:

View File

@ -62,6 +62,12 @@
#endif #endif
/**************************************
* Includes
**************************************/
#include "lz4.h"
/************************************** /**************************************
* Compiler Options * Compiler Options
**************************************/ **************************************/
@ -88,8 +94,6 @@
# endif /* __STDC_VERSION__ */ # endif /* __STDC_VERSION__ */
#endif /* _MSC_VER */ #endif /* _MSC_VER */
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
#if (GCC_VERSION >= 302) || (__INTEL_COMPILER >= 800) || defined(__clang__) #if (GCC_VERSION >= 302) || (__INTEL_COMPILER >= 800) || defined(__clang__)
# define expect(expr,value) (__builtin_expect ((expr),(value)) ) # define expect(expr,value) (__builtin_expect ((expr),(value)) )
#else #else
@ -110,12 +114,6 @@
#define MEM_INIT memset #define MEM_INIT memset
/**************************************
* Includes
**************************************/
#include "lz4.h"
/************************************** /**************************************
* Basic Types * Basic Types
**************************************/ **************************************/

View File

@ -39,9 +39,9 @@ extern "C" {
#endif #endif
/* /*
* lz4.h provides block compression functions, for optimal performance. * lz4.h provides block compression functions, and gives full buffer control to programmer.
* If you need to generate inter-operable compressed data (respecting LZ4 frame specification), * If you need to generate inter-operable compressed data (respecting LZ4 frame specification),
* please use lz4frame.h instead. * and can let the library handle its own memory, please use lz4frame.h instead.
*/ */
/************************************** /**************************************
@ -70,7 +70,7 @@ int LZ4_versionNumber (void);
* Simple Functions * Simple Functions
**************************************/ **************************************/
int LZ4_compress_safe (const char* source, char* dest, int sourceSize, int maxOutputSize); int LZ4_compress_safe (const char* source, char* dest, int sourceSize, int maxDestSize);
int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize); int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize);
/* /*
@ -85,7 +85,7 @@ LZ4_compress_limitedOutput() :
It greatly accelerates behavior on non-compressible input, but as a consequence, 'dest' content is not valid either. It greatly accelerates behavior on non-compressible input, but as a consequence, 'dest' content is not valid either.
This function never writes outside 'dest' buffer, nor read outside 'source' buffer. This function never writes outside 'dest' buffer, nor read outside 'source' buffer.
sourceSize : Max supported value is LZ4_MAX_INPUT_VALUE sourceSize : Max supported value is LZ4_MAX_INPUT_VALUE
maxOutputSize : full or partial size of buffer 'dest' (which must be already allocated) maxDestSize : full or partial size of buffer 'dest' (which must be already allocated)
return : the number of bytes written into buffer 'dest' (necessarily <= maxOutputSize) return : the number of bytes written into buffer 'dest' (necessarily <= maxOutputSize)
or 0 if compression fails or 0 if compression fails
@ -124,11 +124,12 @@ LZ4_compress_fast() :
The larger the value, the faster the algorithm, but also the lesser the compression. The larger the value, the faster the algorithm, but also the lesser the compression.
So it's a trade-off, which can be fine tuned, selecting whichever value you want. So it's a trade-off, which can be fine tuned, selecting whichever value you want.
An acceleration value of "0" means "use Default value", which is typically about 15 (see lz4.c source code). An acceleration value of "0" means "use Default value", which is typically about 15 (see lz4.c source code).
Note : this function is "safe", even if its name does not say it. It's just faster and compress less.
*/ */
int LZ4_compress_fast (const char* source, char* dest, int sourceSize, int maxOutputSize, unsigned acceleration); int LZ4_compress_fast (const char* source, char* dest, int sourceSize, int maxOutputSize, unsigned acceleration);
/* /*
LZ4_compress_safe_withState() : LZ4_compress_safe_extState() :
Same compression function, just using an externally allocated memory space to store compression state. Same compression function, just using an externally allocated memory space to store compression state.
Use LZ4_sizeofState() to know how much memory must be allocated, Use LZ4_sizeofState() to know how much memory must be allocated,
and then, provide it as 'void* state' to compression functions. and then, provide it as 'void* state' to compression functions.
@ -169,7 +170,6 @@ int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedS
/*********************************************** /***********************************************
* Streaming Compression Functions * Streaming Compression Functions
***********************************************/ ***********************************************/
#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4) #define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4)
#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(long long)) #define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(long long))
/* /*
@ -280,35 +280,50 @@ int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalS
/************************************** /**************************************
* Obsolete Functions * Obsolete Functions
**************************************/ **************************************/
/* Warning statements */
#ifndef _WARNING_STATEMENT_BLOCK
# define _WARNING_STATEMENT_BLOCK
# define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
# if (GCC_VERSION >= 405) || defined(__clang__)
# define DEPRECATED(message) __attribute__((deprecated(message)))
# elif (GCC_VERSION >= 301)
# define DEPRECATED(message) __attribute__((deprecated))
# elif defined(_MSC_VER)
# define DEPRECATED(message) __declspec(deprecated(message))
# else
# pragma message("WARNING: You need to implement DEPRECATED for this compiler")
# define DEPRECATED
# endif
#endif // _WARNING_STATEMENT_BLOCK
/* Obsolete compression functions */ /* Obsolete compression functions */
int LZ4_compress (const char* source, char* dest, int sourceSize); /* These functions are planned to generate warnings by r131 approximately */
int LZ4_compress (const char* source, char* dest, int sourceSize);
int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize); int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize);
int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize); int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize); int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize); int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
/* /* Obsolete decompression functions */
Obsolete decompression functions /* These function names are completely deprecated and must no longer be used.
These function names are deprecated and should no longer be used. They are only provided here for compatibility with older programs.
They are only provided here for compatibility with older user programs. - LZ4_uncompress is the same as LZ4_decompress_fast
- LZ4_uncompress is the same as LZ4_decompress_fast - LZ4_uncompress_unknownOutputSize is the same as LZ4_decompress_safe
- LZ4_uncompress_unknownOutputSize is the same as LZ4_decompress_safe These function prototypes are now disabled; uncomment them only if you really need them.
These function prototypes are now disabled; uncomment them if you really need them. It is highly recommended to stop using these prototypes and migrate to maintained ones */
It is highly recommended to stop using these functions and migrate to newer ones */
/* int LZ4_uncompress (const char* source, char* dest, int outputSize); */ /* int LZ4_uncompress (const char* source, char* dest, int outputSize); */
/* int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); */ /* int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); */
/* Obsolete streaming functions; use new streaming interface whenever possible */ /* Obsolete streaming functions; use new streaming interface whenever possible */
void* LZ4_create (const char* inputBuffer); DEPRECATED("use LZ4_createStream() instead") void* LZ4_create (const char* inputBuffer);
int LZ4_sizeofStreamState(void); DEPRECATED("use LZ4_createStream() instead") int LZ4_sizeofStreamState(void);
int LZ4_resetStreamState(void* state, const char* inputBuffer); DEPRECATED("use LZ4_resetStream() instead") int LZ4_resetStreamState(void* state, const char* inputBuffer);
char* LZ4_slideInputBuffer (void* state); DEPRECATED("use LZ4_saveDict() instead") char* LZ4_slideInputBuffer (void* state);
/* Obsolete streaming decoding functions */ /* Obsolete streaming decoding functions */
int LZ4_decompress_safe_withPrefix64k (const char* source, char* dest, int compressedSize, int maxOutputSize); DEPRECATED("use LZ4_decompress_safe_usingDict() instead") int LZ4_decompress_safe_withPrefix64k (const char* source, char* dest, int compressedSize, int maxOutputSize);
int LZ4_decompress_fast_withPrefix64k (const char* source, char* dest, int originalSize); DEPRECATED("use LZ4_decompress_fast_usingDict() instead") int LZ4_decompress_fast_withPrefix64k (const char* source, char* dest, int originalSize);
#if defined (__cplusplus) #if defined (__cplusplus)

View File

@ -381,6 +381,23 @@ start:
#endif // __SSSE3__ #endif // __SSSE3__
static LZ4_stream_t LZ4_stream;
static void local_LZ4_resetDictT(void)
{
LZ4_resetStream(&LZ4_stream);
}
static void local_LZ4_createStream(void)
{
LZ4_resetStream(&LZ4_stream);
}
static int local_LZ4_saveDict(const char* in, char* out, int inSize)
{
(void)in;
return LZ4_saveDict(&LZ4_stream, out, inSize);
}
static int local_LZ4_compress_limitedOutput(const char* in, char* out, int inSize) static int local_LZ4_compress_limitedOutput(const char* in, char* out, int inSize)
{ {
return LZ4_compress_limitedOutput(in, out, inSize, LZ4_compressBound(inSize)-1); return LZ4_compress_limitedOutput(in, out, inSize, LZ4_compressBound(inSize)-1);
@ -391,53 +408,56 @@ static int local_LZ4_compress_fast(const char* in, char* out, int inSize)
return LZ4_compress_fast(in, out, inSize, LZ4_compressBound(inSize), 0); return LZ4_compress_fast(in, out, inSize, LZ4_compressBound(inSize), 0);
} }
static LZ4_stream_t* stateLZ4;
static int local_LZ4_compress_withState(const char* in, char* out, int inSize) static int local_LZ4_compress_withState(const char* in, char* out, int inSize)
{ {
return LZ4_compress_withState(stateLZ4, in, out, inSize); return LZ4_compress_withState(&LZ4_stream, in, out, inSize);
} }
static int local_LZ4_compress_limitedOutput_withState(const char* in, char* out, int inSize) static int local_LZ4_compress_limitedOutput_withState(const char* in, char* out, int inSize)
{ {
return LZ4_compress_limitedOutput_withState(stateLZ4, in, out, inSize, LZ4_compressBound(inSize)-1); return LZ4_compress_limitedOutput_withState(&LZ4_stream, in, out, inSize, LZ4_compressBound(inSize)-1);
} }
static LZ4_stream_t* ctx;
static int local_LZ4_compress_continue(const char* in, char* out, int inSize) static int local_LZ4_compress_continue(const char* in, char* out, int inSize)
{ {
return LZ4_compress_continue(ctx, in, out, inSize); return LZ4_compress_continue(&LZ4_stream, in, out, inSize);
} }
static int local_LZ4_compress_limitedOutput_continue(const char* in, char* out, int inSize) static int local_LZ4_compress_limitedOutput_continue(const char* in, char* out, int inSize)
{ {
return LZ4_compress_limitedOutput_continue(ctx, in, out, inSize, LZ4_compressBound(inSize)-1); return LZ4_compress_limitedOutput_continue(&LZ4_stream, in, out, inSize, LZ4_compressBound(inSize)-1);
} }
/* declare hidden function */
int LZ4_compress_forceExtDict (LZ4_stream_t* LZ4_stream, const char* source, char* dest, int inputSize);
LZ4_stream_t LZ4_dict;
static void* local_LZ4_resetDictT(const char* fake)
{
(void)fake;
memset(&LZ4_dict, 0, sizeof(LZ4_stream_t));
return NULL;
}
int LZ4_compress_forceExtDict (LZ4_stream_t* LZ4_dict, const char* source, char* dest, int inputSize);
static int local_LZ4_compress_forceDict(const char* in, char* out, int inSize) static int local_LZ4_compress_forceDict(const char* in, char* out, int inSize)
{ {
return LZ4_compress_forceExtDict(&LZ4_dict, in, out, inSize); return LZ4_compress_forceExtDict(&LZ4_stream, in, out, inSize);
} }
static LZ4_streamHC_t* stateLZ4HC; /* HC compression functions */
LZ4_streamHC_t LZ4_streamHC;
static void local_LZ4_resetStreamHC(void)
{
LZ4_resetStreamHC(&LZ4_streamHC, 0);
}
static int local_LZ4_saveDictHC(const char* in, char* out, int inSize)
{
(void)in;
return LZ4_saveDictHC(&LZ4_streamHC, out, inSize);
}
static int local_LZ4_compressHC_withStateHC(const char* in, char* out, int inSize) static int local_LZ4_compressHC_withStateHC(const char* in, char* out, int inSize)
{ {
return LZ4_compressHC_withStateHC(stateLZ4HC, in, out, inSize); return LZ4_compressHC_withStateHC(&LZ4_streamHC, in, out, inSize);
} }
static int local_LZ4_compressHC_limitedOutput_withStateHC(const char* in, char* out, int inSize) static int local_LZ4_compressHC_limitedOutput_withStateHC(const char* in, char* out, int inSize)
{ {
return LZ4_compressHC_limitedOutput_withStateHC(stateLZ4HC, in, out, inSize, LZ4_compressBound(inSize)-1); return LZ4_compressHC_limitedOutput_withStateHC(&LZ4_streamHC, in, out, inSize, LZ4_compressBound(inSize)-1);
} }
static int local_LZ4_compressHC_limitedOutput(const char* in, char* out, int inSize) static int local_LZ4_compressHC_limitedOutput(const char* in, char* out, int inSize)
@ -447,33 +467,16 @@ static int local_LZ4_compressHC_limitedOutput(const char* in, char* out, int inS
static int local_LZ4_compressHC_continue(const char* in, char* out, int inSize) static int local_LZ4_compressHC_continue(const char* in, char* out, int inSize)
{ {
return LZ4_compressHC_continue((LZ4_streamHC_t*)ctx, in, out, inSize); return LZ4_compressHC_continue(&LZ4_streamHC, in, out, inSize);
} }
static int local_LZ4_compressHC_limitedOutput_continue(const char* in, char* out, int inSize) static int local_LZ4_compressHC_limitedOutput_continue(const char* in, char* out, int inSize)
{ {
return LZ4_compressHC_limitedOutput_continue((LZ4_streamHC_t*)ctx, in, out, inSize, LZ4_compressBound(inSize)-1); return LZ4_compressHC_limitedOutput_continue(&LZ4_streamHC, in, out, inSize, LZ4_compressBound(inSize)-1);
}
static int local_LZ4F_compressFrame(const char* in, char* out, int inSize)
{
return (int)LZ4F_compressFrame(out, 2*inSize + 16, in, inSize, NULL);
}
static int local_LZ4_saveDict(const char* in, char* out, int inSize)
{
(void)in;
return LZ4_saveDict(&LZ4_dict, out, inSize);
}
LZ4_streamHC_t LZ4_dictHC;
static int local_LZ4_saveDictHC(const char* in, char* out, int inSize)
{
(void)in;
return LZ4_saveDictHC(&LZ4_dictHC, out, inSize);
} }
/* decompression functions */
static int local_LZ4_decompress_fast(const char* in, char* out, int inSize, int outSize) static int local_LZ4_decompress_fast(const char* in, char* out, int inSize, int outSize)
{ {
(void)inSize; (void)inSize;
@ -481,13 +484,6 @@ static int local_LZ4_decompress_fast(const char* in, char* out, int inSize, int
return outSize; return outSize;
} }
static int local_LZ4_decompress_fast_withPrefix64k(const char* in, char* out, int inSize, int outSize)
{
(void)inSize;
LZ4_decompress_fast_withPrefix64k(in, out, outSize);
return outSize;
}
static int local_LZ4_decompress_fast_usingDict(const char* in, char* out, int inSize, int outSize) static int local_LZ4_decompress_fast_usingDict(const char* in, char* out, int inSize, int outSize)
{ {
(void)inSize; (void)inSize;
@ -516,6 +512,13 @@ static int local_LZ4_decompress_safe_partial(const char* in, char* out, int inSi
return LZ4_decompress_safe_partial(in, out, inSize, outSize - 5, outSize); return LZ4_decompress_safe_partial(in, out, inSize, outSize - 5, outSize);
} }
/* frame functions */
static int local_LZ4F_compressFrame(const char* in, char* out, int inSize)
{
return (int)LZ4F_compressFrame(out, 2*inSize + 16, in, inSize, NULL);
}
static LZ4F_decompressionContext_t g_dCtx; static LZ4F_decompressionContext_t g_dCtx;
static int local_LZ4F_decompress(const char* in, char* out, int inSize, int outSize) static int local_LZ4F_decompress(const char* in, char* out, int inSize, int outSize)
@ -534,11 +537,8 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
{ {
int fileIdx=0; int fileIdx=0;
char* orig_buff; char* orig_buff;
# define NB_COMPRESSION_ALGORITHMS 17 # define NB_COMPRESSION_ALGORITHMS 100
double totalCTime[NB_COMPRESSION_ALGORITHMS+1] = {0}; # define NB_DECOMPRESSION_ALGORITHMS 100
double totalCSize[NB_COMPRESSION_ALGORITHMS+1] = {0};
# define NB_DECOMPRESSION_ALGORITHMS 9
double totalDTime[NB_DECOMPRESSION_ALGORITHMS+1] = {0};
size_t errorCode; size_t errorCode;
@ -576,8 +576,6 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
DISPLAY("Not enough memory for '%s' full size; testing %i MB only...\n", inFileName, (int)(benchedSize>>20)); DISPLAY("Not enough memory for '%s' full size; testing %i MB only...\n", inFileName, (int)(benchedSize>>20));
/* Allocation */ /* Allocation */
stateLZ4 = LZ4_createStream();
stateLZ4HC = LZ4_createStreamHC();
errorCode = LZ4F_createDecompressionContext(&g_dCtx, LZ4F_VERSION); errorCode = LZ4F_createDecompressionContext(&g_dCtx, LZ4F_VERSION);
if (LZ4F_isError(errorCode)) if (LZ4F_isError(errorCode))
{ {
@ -634,9 +632,12 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
{ {
const char* compressorName; const char* compressorName;
int (*compressionFunction)(const char*, char*, int); int (*compressionFunction)(const char*, char*, int);
void* (*initFunction)(const char*) = NULL; void (*initFunction)(void) = NULL;
double bestTime = 100000000.; double bestTime = 100000000.;
/* filter compressionAlgo only */
if ((compressionAlgo != ALL_COMPRESSORS) && (compressionAlgo != cAlgNb)) continue;
/* Init data chunks */ /* Init data chunks */
{ {
int i; int i;
@ -654,34 +655,34 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
} }
} }
if ((compressionAlgo != ALL_COMPRESSORS) && (compressionAlgo != cAlgNb)) continue;
switch(cAlgNb) switch(cAlgNb)
{ {
case 1 : compressionFunction = LZ4_compress; compressorName = "LZ4_compress"; break; case 1 : compressionFunction = LZ4_compress; compressorName = "LZ4_compress"; break;
case 2 : compressionFunction = local_LZ4_compress_limitedOutput; compressorName = "LZ4_compress_limitedOutput"; break; case 2 : compressionFunction = local_LZ4_compress_limitedOutput; compressorName = "LZ4_compress_limitedOutput"; break;
case 3 : compressionFunction = local_LZ4_compress_withState; compressorName = "LZ4_compress_withState"; break; case 3 : compressionFunction = local_LZ4_compress_withState; compressorName = "LZ4_compress_withState"; break;
case 4 : compressionFunction = local_LZ4_compress_limitedOutput_withState; compressorName = "LZ4_compress_limitedOutput_withState"; break; case 4 : compressionFunction = local_LZ4_compress_limitedOutput_withState; compressorName = "LZ4_compress_limitedOutput_withState"; break;
case 5 : compressionFunction = local_LZ4_compress_continue; initFunction = LZ4_create; compressorName = "LZ4_compress_continue"; break; case 5 : compressionFunction = local_LZ4_compress_continue; initFunction = local_LZ4_createStream; compressorName = "LZ4_compress_continue"; break;
case 6 : compressionFunction = local_LZ4_compress_limitedOutput_continue; initFunction = LZ4_create; compressorName = "LZ4_compress_limitedOutput_continue"; break; case 6 : compressionFunction = local_LZ4_compress_limitedOutput_continue; initFunction = local_LZ4_createStream; compressorName = "LZ4_compress_limitedOutput_continue"; break;
case 7 : compressionFunction = local_LZ4_compress_fast; compressorName = "LZ4_compress_fast"; break; case 7 : compressionFunction = local_LZ4_compress_fast; compressorName = "LZ4_compress_fast"; break;
case 8 : compressionFunction = LZ4_compressHC; compressorName = "LZ4_compressHC"; break; case 8 : compressionFunction = LZ4_compressHC; compressorName = "LZ4_compressHC"; break;
case 9 : compressionFunction = local_LZ4_compressHC_limitedOutput; compressorName = "LZ4_compressHC_limitedOutput"; break; case 9 : compressionFunction = local_LZ4_compressHC_limitedOutput; compressorName = "LZ4_compressHC_limitedOutput"; break;
case 10 : compressionFunction = local_LZ4_compressHC_withStateHC; compressorName = "LZ4_compressHC_withStateHC"; break; case 10 : compressionFunction = local_LZ4_compressHC_withStateHC; compressorName = "LZ4_compressHC_withStateHC"; break;
case 11: compressionFunction = local_LZ4_compressHC_limitedOutput_withStateHC; compressorName = "LZ4_compressHC_limitedOutput_withStateHC"; break; case 11: compressionFunction = local_LZ4_compressHC_limitedOutput_withStateHC; compressorName = "LZ4_compressHC_limitedOutput_withStateHC"; break;
case 12: compressionFunction = local_LZ4_compressHC_continue; initFunction = LZ4_createHC; compressorName = "LZ4_compressHC_continue"; break; case 12: compressionFunction = local_LZ4_compressHC_continue; initFunction = local_LZ4_resetStreamHC; compressorName = "LZ4_compressHC_continue"; break;
case 13: compressionFunction = local_LZ4_compressHC_limitedOutput_continue; initFunction = LZ4_createHC; compressorName = "LZ4_compressHC_limitedOutput_continue"; break; case 13: compressionFunction = local_LZ4_compressHC_limitedOutput_continue; initFunction = local_LZ4_resetStreamHC; compressorName = "LZ4_compressHC_limitedOutput_continue"; break;
case 14: compressionFunction = local_LZ4_compress_forceDict; initFunction = local_LZ4_resetDictT; compressorName = "LZ4_compress_forceDict"; break; case 14: compressionFunction = local_LZ4_compress_forceDict; initFunction = local_LZ4_resetDictT; compressorName = "LZ4_compress_forceDict"; break;
case 15: compressionFunction = local_LZ4F_compressFrame; compressorName = "LZ4F_compressFrame"; case 15: compressionFunction = local_LZ4F_compressFrame; compressorName = "LZ4F_compressFrame";
chunkP[0].origSize = (int)benchedSize; nbChunks=1; chunkP[0].origSize = (int)benchedSize; nbChunks=1;
break; break;
case 16: compressionFunction = local_LZ4_saveDict; compressorName = "LZ4_saveDict"; case 16: compressionFunction = local_LZ4_saveDict; compressorName = "LZ4_saveDict";
LZ4_loadDict(&LZ4_dict, chunkP[0].origBuffer, chunkP[0].origSize); LZ4_loadDict(&LZ4_stream, chunkP[0].origBuffer, chunkP[0].origSize);
break; break;
case 17: compressionFunction = local_LZ4_saveDictHC; compressorName = "LZ4_saveDictHC"; case 17: compressionFunction = local_LZ4_saveDictHC; compressorName = "LZ4_saveDictHC";
LZ4_loadDictHC(&LZ4_dictHC, chunkP[0].origBuffer, chunkP[0].origSize); LZ4_loadDictHC(&LZ4_streamHC, chunkP[0].origBuffer, chunkP[0].origSize);
break; break;
default : DISPLAY("ERROR ! Bad algorithm Id !! \n"); free(chunkP); return 1; default :
continue; /* unknown ID : just skip */
DISPLAY("ERROR ! Bad algorithm Id !! \n"); free(chunkP); return 1;
} }
for (loopNb = 1; loopNb <= nbIterations; loopNb++) for (loopNb = 1; loopNb <= nbIterations; loopNb++)
@ -698,13 +699,12 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
milliTime = BMK_GetMilliStart(); milliTime = BMK_GetMilliStart();
while(BMK_GetMilliSpan(milliTime) < TIMELOOP) while(BMK_GetMilliSpan(milliTime) < TIMELOOP)
{ {
if (initFunction!=NULL) ctx = (LZ4_stream_t*)initFunction(chunkP[0].origBuffer); if (initFunction!=NULL) initFunction();
for (chunkNb=0; chunkNb<nbChunks; chunkNb++) for (chunkNb=0; chunkNb<nbChunks; chunkNb++)
{ {
chunkP[chunkNb].compressedSize = compressionFunction(chunkP[chunkNb].origBuffer, chunkP[chunkNb].compressedBuffer, chunkP[chunkNb].origSize); chunkP[chunkNb].compressedSize = compressionFunction(chunkP[chunkNb].origBuffer, chunkP[chunkNb].compressedBuffer, chunkP[chunkNb].origSize);
if (chunkP[chunkNb].compressedSize==0) DISPLAY("ERROR ! %s() = 0 !! \n", compressorName), exit(1); if (chunkP[chunkNb].compressedSize==0) DISPLAY("ERROR ! %s() = 0 !! \n", compressorName), exit(1);
} }
if (initFunction!=NULL) free(ctx);
nb_loops++; nb_loops++;
} }
milliTime = BMK_GetMilliSpan(milliTime); milliTime = BMK_GetMilliSpan(milliTime);
@ -720,9 +720,6 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
DISPLAY("%2i-%-28.28s :%9i ->%9i (%5.2f%%),%7.1f MB/s\n", cAlgNb, compressorName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 1000.); DISPLAY("%2i-%-28.28s :%9i ->%9i (%5.2f%%),%7.1f MB/s\n", cAlgNb, compressorName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 1000.);
else else
DISPLAY("%2i-%-28.28s :%9i ->%9i (%5.1f%%),%7.1f MB/s\n", cAlgNb, compressorName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 1000.); DISPLAY("%2i-%-28.28s :%9i ->%9i (%5.1f%%),%7.1f MB/s\n", cAlgNb, compressorName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 1000.);
totalCTime[cAlgNb] += bestTime;
totalCSize[cAlgNb] += cSize;
} }
/* Prepare layout for decompression */ /* Prepare layout for decompression */
@ -732,7 +729,8 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
size_t remaining = benchedSize; size_t remaining = benchedSize;
char* in = orig_buff; char* in = orig_buff;
char* out = compressed_buff; char* out = compressed_buff;
nbChunks = (int) (((int)benchedSize + (chunkSize-1))/ chunkSize);
nbChunks = (int) (((int)benchedSize + (chunkSize-1))/ chunkSize);
for (i=0; i<nbChunks; i++) for (i=0; i<nbChunks; i++)
{ {
chunkP[i].id = i; chunkP[i].id = i;
@ -760,10 +758,8 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
switch(dAlgNb) switch(dAlgNb)
{ {
case 1: decompressionFunction = local_LZ4_decompress_fast; dName = "LZ4_decompress_fast"; break; case 1: decompressionFunction = local_LZ4_decompress_fast; dName = "LZ4_decompress_fast"; break;
case 2: decompressionFunction = local_LZ4_decompress_fast_withPrefix64k; dName = "LZ4_decompress_fast_withPrefix64k"; break;
case 3: decompressionFunction = local_LZ4_decompress_fast_usingDict; dName = "LZ4_decompress_fast_usingDict"; break; case 3: decompressionFunction = local_LZ4_decompress_fast_usingDict; dName = "LZ4_decompress_fast_usingDict"; break;
case 4: decompressionFunction = LZ4_decompress_safe; dName = "LZ4_decompress_safe"; break; case 4: decompressionFunction = LZ4_decompress_safe; dName = "LZ4_decompress_safe"; break;
case 5: decompressionFunction = LZ4_decompress_safe_withPrefix64k; dName = "LZ4_decompress_safe_withPrefix64k"; break;
case 6: decompressionFunction = local_LZ4_decompress_safe_usingDict; dName = "LZ4_decompress_safe_usingDict"; break; case 6: decompressionFunction = local_LZ4_decompress_safe_usingDict; dName = "LZ4_decompress_safe_usingDict"; break;
case 7: decompressionFunction = local_LZ4_decompress_safe_partial; dName = "LZ4_decompress_safe_partial"; break; case 7: decompressionFunction = local_LZ4_decompress_safe_partial; dName = "LZ4_decompress_safe_partial"; break;
case 8: decompressionFunction = local_LZ4_decompress_safe_forceExtDict; dName = "LZ4_decompress_safe_forceExtDict"; break; case 8: decompressionFunction = local_LZ4_decompress_safe_forceExtDict; dName = "LZ4_decompress_safe_forceExtDict"; break;
@ -774,7 +770,9 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
chunkP[0].compressedSize = (int)errorCode; chunkP[0].compressedSize = (int)errorCode;
nbChunks = 1; nbChunks = 1;
break; break;
default : DISPLAY("ERROR ! Bad decompression algorithm Id !! \n"); free(chunkP); return 1; default :
continue; /* skip if unknown ID */
DISPLAY("ERROR ! Bad decompression algorithm Id !! \n"); free(chunkP); return 1;
} }
{ size_t i; for (i=0; i<benchedSize; i++) orig_buff[i]=0; } /* zeroing source area, for CRC checking */ { size_t i; for (i=0; i<benchedSize; i++) orig_buff[i]=0; } /* zeroing source area, for CRC checking */
@ -813,8 +811,6 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
} }
DISPLAY("%2i-%-29.29s :%10i -> %7.1f MB/s\n", dAlgNb, dName, (int)benchedSize, (double)benchedSize / bestTime / 1000.); DISPLAY("%2i-%-29.29s :%10i -> %7.1f MB/s\n", dAlgNb, dName, (int)benchedSize, (double)benchedSize / bestTime / 1000.);
totalDTime[dAlgNb] += bestTime;
} }
} }
@ -822,8 +818,6 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
free(orig_buff); free(orig_buff);
free(compressed_buff); free(compressed_buff);
free(chunkP); free(chunkP);
LZ4_freeStream(stateLZ4);
LZ4_freeStreamHC(stateLZ4HC);
LZ4F_freeDecompressionContext(g_dCtx); LZ4F_freeDecompressionContext(g_dCtx);
} }

View File

@ -316,7 +316,6 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
# define FUZ_DISPLAYTEST { testNb++; g_displayLevel<3 ? 0 : printf("%2u\b\b", testNb); if (g_displayLevel==4) fflush(stdout); } # define FUZ_DISPLAYTEST { testNb++; g_displayLevel<3 ? 0 : printf("%2u\b\b", testNb); if (g_displayLevel==4) fflush(stdout); }
void* stateLZ4 = malloc(LZ4_sizeofState()); void* stateLZ4 = malloc(LZ4_sizeofState());
void* stateLZ4HC = malloc(LZ4_sizeofStateHC()); void* stateLZ4HC = malloc(LZ4_sizeofStateHC());
void* LZ4continue;
LZ4_stream_t LZ4dict; LZ4_stream_t LZ4dict;
LZ4_streamHC_t LZ4dictHC; LZ4_streamHC_t LZ4dictHC;
U32 crcOrig, crcCheck; U32 crcOrig, crcCheck;
@ -546,16 +545,18 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
/* Compress using dictionary */ /* Compress using dictionary */
FUZ_DISPLAYTEST; FUZ_DISPLAYTEST;
LZ4continue = LZ4_create (dict); {
LZ4_compress_continue ((LZ4_stream_t*)LZ4continue, dict, compressedBuffer, dictSize); // Just to fill hash tables LZ4_stream_t LZ4_stream;
blockContinueCompressedSize = LZ4_compress_continue ((LZ4_stream_t*)LZ4continue, block, compressedBuffer, blockSize); LZ4_resetStream(&LZ4_stream);
FUZ_CHECKTEST(blockContinueCompressedSize==0, "LZ4_compress_continue failed"); LZ4_compress_continue (&LZ4_stream, dict, compressedBuffer, dictSize); /* Just to fill hash tables */
free (LZ4continue); blockContinueCompressedSize = LZ4_compress_continue (&LZ4_stream, block, compressedBuffer, blockSize);
FUZ_CHECKTEST(blockContinueCompressedSize==0, "LZ4_compress_continue failed");
}
/* Decompress with dictionary as prefix */ /* Decompress with dictionary as prefix */
FUZ_DISPLAYTEST; FUZ_DISPLAYTEST;
memcpy(decodedBuffer, dict, dictSize); memcpy(decodedBuffer, dict, dictSize);
ret = LZ4_decompress_fast_withPrefix64k(compressedBuffer, decodedBuffer+dictSize, blockSize); ret = LZ4_decompress_fast_usingDict(compressedBuffer, decodedBuffer+dictSize, blockSize, decodedBuffer, dictSize);
FUZ_CHECKTEST(ret!=blockContinueCompressedSize, "LZ4_decompress_fast_withPrefix64k did not read all compressed block input"); FUZ_CHECKTEST(ret!=blockContinueCompressedSize, "LZ4_decompress_fast_withPrefix64k did not read all compressed block input");
crcCheck = XXH32(decodedBuffer+dictSize, blockSize, 0); crcCheck = XXH32(decodedBuffer+dictSize, blockSize, 0);
if (crcCheck!=crcOrig) if (crcCheck!=crcOrig)
@ -568,7 +569,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
FUZ_CHECKTEST(crcCheck!=crcOrig, "LZ4_decompress_fast_withPrefix64k corrupted decoded data (dict %i)", dictSize); FUZ_CHECKTEST(crcCheck!=crcOrig, "LZ4_decompress_fast_withPrefix64k corrupted decoded data (dict %i)", dictSize);
FUZ_DISPLAYTEST; FUZ_DISPLAYTEST;
ret = LZ4_decompress_safe_withPrefix64k(compressedBuffer, decodedBuffer+dictSize, blockContinueCompressedSize, blockSize); ret = LZ4_decompress_safe_usingDict(compressedBuffer, decodedBuffer+dictSize, blockContinueCompressedSize, blockSize, decodedBuffer, dictSize);
FUZ_CHECKTEST(ret!=blockSize, "LZ4_decompress_safe_withPrefix64k did not regenerate original data"); FUZ_CHECKTEST(ret!=blockSize, "LZ4_decompress_safe_withPrefix64k did not regenerate original data");
crcCheck = XXH32(decodedBuffer+dictSize, blockSize, 0); crcCheck = XXH32(decodedBuffer+dictSize, blockSize, 0);
FUZ_CHECKTEST(crcCheck!=crcOrig, "LZ4_decompress_safe_withPrefix64k corrupted decoded data"); FUZ_CHECKTEST(crcCheck!=crcOrig, "LZ4_decompress_safe_withPrefix64k corrupted decoded data");