Added compilation flag -Wcast-qual
This commit is contained in:
parent
05b0aa62a7
commit
1c3e633c48
26
lib/lz4.c
26
lib/lz4.c
@ -351,7 +351,7 @@ typedef struct {
|
|||||||
U32 currentOffset;
|
U32 currentOffset;
|
||||||
U32 initCheck;
|
U32 initCheck;
|
||||||
const BYTE* dictionary;
|
const BYTE* dictionary;
|
||||||
const BYTE* bufferStart;
|
BYTE* bufferStart; /* obsolete, used for slideInputBuffer */
|
||||||
U32 dictSize;
|
U32 dictSize;
|
||||||
} LZ4_stream_t_internal;
|
} LZ4_stream_t_internal;
|
||||||
|
|
||||||
@ -1064,11 +1064,11 @@ FORCE_INLINE int LZ4_decompress_generic(
|
|||||||
if (endOnInput)
|
if (endOnInput)
|
||||||
return (int) (((char*)op)-dest); /* Nb of output bytes decoded */
|
return (int) (((char*)op)-dest); /* Nb of output bytes decoded */
|
||||||
else
|
else
|
||||||
return (int) (((char*)ip)-source); /* Nb of input bytes read */
|
return (int) (((const char*)ip)-source); /* Nb of input bytes read */
|
||||||
|
|
||||||
/* Overflow error detected */
|
/* Overflow error detected */
|
||||||
_output_error:
|
_output_error:
|
||||||
return (int) (-(((char*)ip)-source))-1;
|
return (int) (-(((const char*)ip)-source))-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1092,9 +1092,9 @@ int LZ4_decompress_fast(const char* source, char* dest, int originalSize)
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
BYTE* externalDict;
|
const BYTE* externalDict;
|
||||||
size_t extDictSize;
|
size_t extDictSize;
|
||||||
BYTE* prefixEnd;
|
const BYTE* prefixEnd;
|
||||||
size_t prefixSize;
|
size_t prefixSize;
|
||||||
} LZ4_streamDecode_t_internal;
|
} LZ4_streamDecode_t_internal;
|
||||||
|
|
||||||
@ -1126,7 +1126,7 @@ int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dicti
|
|||||||
{
|
{
|
||||||
LZ4_streamDecode_t_internal* lz4sd = (LZ4_streamDecode_t_internal*) LZ4_streamDecode;
|
LZ4_streamDecode_t_internal* lz4sd = (LZ4_streamDecode_t_internal*) LZ4_streamDecode;
|
||||||
lz4sd->prefixSize = (size_t) dictSize;
|
lz4sd->prefixSize = (size_t) dictSize;
|
||||||
lz4sd->prefixEnd = (BYTE*) dictionary + dictSize;
|
lz4sd->prefixEnd = (const BYTE*) dictionary + dictSize;
|
||||||
lz4sd->externalDict = NULL;
|
lz4sd->externalDict = NULL;
|
||||||
lz4sd->extDictSize = 0;
|
lz4sd->extDictSize = 0;
|
||||||
return 1;
|
return 1;
|
||||||
@ -1215,7 +1215,7 @@ FORCE_INLINE int LZ4_decompress_usingDict_generic(const char* source, char* dest
|
|||||||
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, withPrefix64k, (BYTE*)dest-64 KB, NULL, 0);
|
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, withPrefix64k, (BYTE*)dest-64 KB, NULL, 0);
|
||||||
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, noDict, (BYTE*)dest-dictSize, NULL, 0);
|
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, noDict, (BYTE*)dest-dictSize, NULL, 0);
|
||||||
}
|
}
|
||||||
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, usingExtDict, (BYTE*)dest, (BYTE*)dictStart, dictSize);
|
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, usingExtDict, (BYTE*)dest, (const BYTE*)dictStart, dictSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int LZ4_decompress_safe_usingDict(const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize)
|
int LZ4_decompress_safe_usingDict(const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize)
|
||||||
@ -1231,7 +1231,7 @@ int LZ4_decompress_fast_usingDict(const char* source, char* dest, int originalSi
|
|||||||
/* debug function */
|
/* debug function */
|
||||||
int LZ4_decompress_safe_forceExtDict(const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize)
|
int LZ4_decompress_safe_forceExtDict(const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize)
|
||||||
{
|
{
|
||||||
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, usingExtDict, (BYTE*)dest, (BYTE*)dictStart, dictSize);
|
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, usingExtDict, (BYTE*)dest, (const BYTE*)dictStart, dictSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1260,23 +1260,23 @@ int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize,
|
|||||||
|
|
||||||
int LZ4_sizeofStreamState() { return LZ4_STREAMSIZE; }
|
int LZ4_sizeofStreamState() { return LZ4_STREAMSIZE; }
|
||||||
|
|
||||||
static void LZ4_init(LZ4_stream_t_internal* lz4ds, const BYTE* base)
|
static void LZ4_init(LZ4_stream_t_internal* lz4ds, BYTE* base)
|
||||||
{
|
{
|
||||||
MEM_INIT(lz4ds, 0, LZ4_STREAMSIZE);
|
MEM_INIT(lz4ds, 0, LZ4_STREAMSIZE);
|
||||||
lz4ds->bufferStart = base;
|
lz4ds->bufferStart = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LZ4_resetStreamState(void* state, const char* inputBuffer)
|
int LZ4_resetStreamState(void* state, char* inputBuffer)
|
||||||
{
|
{
|
||||||
if ((((size_t)state) & 3) != 0) return 1; /* Error : pointer is not aligned on 4-bytes boundary */
|
if ((((size_t)state) & 3) != 0) return 1; /* Error : pointer is not aligned on 4-bytes boundary */
|
||||||
LZ4_init((LZ4_stream_t_internal*)state, (const BYTE*)inputBuffer);
|
LZ4_init((LZ4_stream_t_internal*)state, (BYTE*)inputBuffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* LZ4_create (const char* inputBuffer)
|
void* LZ4_create (char* inputBuffer)
|
||||||
{
|
{
|
||||||
void* lz4ds = ALLOCATOR(8, LZ4_STREAMSIZE_U64);
|
void* lz4ds = ALLOCATOR(8, LZ4_STREAMSIZE_U64);
|
||||||
LZ4_init ((LZ4_stream_t_internal*)lz4ds, (const BYTE*)inputBuffer);
|
LZ4_init ((LZ4_stream_t_internal*)lz4ds, (BYTE*)inputBuffer);
|
||||||
return lz4ds;
|
return lz4ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,9 +331,9 @@ int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const cha
|
|||||||
/* 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 */
|
||||||
LZ4_DEPRECATED("use LZ4_createStream() instead") void* LZ4_create (const char* inputBuffer);
|
LZ4_DEPRECATED("use LZ4_createStream() instead") void* LZ4_create (char* inputBuffer);
|
||||||
LZ4_DEPRECATED("use LZ4_createStream() instead") int LZ4_sizeofStreamState(void);
|
LZ4_DEPRECATED("use LZ4_createStream() instead") int LZ4_sizeofStreamState(void);
|
||||||
LZ4_DEPRECATED("use LZ4_resetStream() instead") int LZ4_resetStreamState(void* state, const char* inputBuffer);
|
LZ4_DEPRECATED("use LZ4_resetStream() instead") int LZ4_resetStreamState(void* state, char* inputBuffer);
|
||||||
LZ4_DEPRECATED("use LZ4_saveDict() instead") char* LZ4_slideInputBuffer (void* state);
|
LZ4_DEPRECATED("use LZ4_saveDict() instead") char* LZ4_slideInputBuffer (void* state);
|
||||||
|
|
||||||
/* Obsolete streaming decoding functions */
|
/* Obsolete streaming decoding functions */
|
||||||
|
@ -140,7 +140,7 @@ typedef struct LZ4F_dctx_s
|
|||||||
size_t tmpInSize;
|
size_t tmpInSize;
|
||||||
size_t tmpInTarget;
|
size_t tmpInTarget;
|
||||||
BYTE* tmpOutBuffer;
|
BYTE* tmpOutBuffer;
|
||||||
BYTE* dict;
|
const BYTE* dict;
|
||||||
size_t dictSize;
|
size_t dictSize;
|
||||||
BYTE* tmpOut;
|
BYTE* tmpOut;
|
||||||
size_t tmpOutSize;
|
size_t tmpOutSize;
|
||||||
@ -961,7 +961,7 @@ static int LZ4F_decompress_safe (const char* source, char* dest, int compressedS
|
|||||||
static void LZ4F_updateDict(LZ4F_dctx_t* dctxPtr, const BYTE* dstPtr, size_t dstSize, const BYTE* dstPtr0, unsigned withinTmp)
|
static void LZ4F_updateDict(LZ4F_dctx_t* dctxPtr, const BYTE* dstPtr, size_t dstSize, const BYTE* dstPtr0, unsigned withinTmp)
|
||||||
{
|
{
|
||||||
if (dctxPtr->dictSize==0)
|
if (dctxPtr->dictSize==0)
|
||||||
dctxPtr->dict = (BYTE*)dstPtr; /* priority to dictionary continuity */
|
dctxPtr->dict = (const BYTE*)dstPtr; /* priority to dictionary continuity */
|
||||||
|
|
||||||
if (dctxPtr->dict + dctxPtr->dictSize == dstPtr) /* dictionary continuity */
|
if (dctxPtr->dict + dctxPtr->dictSize == dstPtr) /* dictionary continuity */
|
||||||
{
|
{
|
||||||
@ -971,7 +971,7 @@ static void LZ4F_updateDict(LZ4F_dctx_t* dctxPtr, const BYTE* dstPtr, size_t dst
|
|||||||
|
|
||||||
if (dstPtr - dstPtr0 + dstSize >= 64 KB) /* dstBuffer large enough to become dictionary */
|
if (dstPtr - dstPtr0 + dstSize >= 64 KB) /* dstBuffer large enough to become dictionary */
|
||||||
{
|
{
|
||||||
dctxPtr->dict = (BYTE*)dstPtr0;
|
dctxPtr->dict = (const BYTE*)dstPtr0;
|
||||||
dctxPtr->dictSize = dstPtr - dstPtr0 + dstSize;
|
dctxPtr->dictSize = dstPtr - dstPtr0 + dstSize;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -987,7 +987,7 @@ static void LZ4F_updateDict(LZ4F_dctx_t* dctxPtr, const BYTE* dstPtr, size_t dst
|
|||||||
{
|
{
|
||||||
size_t preserveSize = dctxPtr->tmpOut - dctxPtr->tmpOutBuffer;
|
size_t preserveSize = dctxPtr->tmpOut - dctxPtr->tmpOutBuffer;
|
||||||
size_t copySize = 64 KB - dctxPtr->tmpOutSize;
|
size_t copySize = 64 KB - dctxPtr->tmpOutSize;
|
||||||
BYTE* oldDictEnd = dctxPtr->dict + dctxPtr->dictSize - dctxPtr->tmpOutStart;
|
const BYTE* oldDictEnd = dctxPtr->dict + dctxPtr->dictSize - dctxPtr->tmpOutStart;
|
||||||
if (dctxPtr->tmpOutSize > 64 KB) copySize = 0;
|
if (dctxPtr->tmpOutSize > 64 KB) copySize = 0;
|
||||||
if (copySize > preserveSize) copySize = preserveSize;
|
if (copySize > preserveSize) copySize = preserveSize;
|
||||||
|
|
||||||
@ -1003,10 +1003,10 @@ static void LZ4F_updateDict(LZ4F_dctx_t* dctxPtr, const BYTE* dstPtr, size_t dst
|
|||||||
if (dctxPtr->dictSize + dstSize > dctxPtr->maxBufferSize) /* tmp buffer not large enough */
|
if (dctxPtr->dictSize + dstSize > dctxPtr->maxBufferSize) /* tmp buffer not large enough */
|
||||||
{
|
{
|
||||||
size_t preserveSize = 64 KB - dstSize; /* note : dstSize < 64 KB */
|
size_t preserveSize = 64 KB - dstSize; /* note : dstSize < 64 KB */
|
||||||
memcpy(dctxPtr->dict, dctxPtr->dict + dctxPtr->dictSize - preserveSize, preserveSize);
|
memcpy(dctxPtr->tmpOutBuffer, dctxPtr->dict + dctxPtr->dictSize - preserveSize, preserveSize);
|
||||||
dctxPtr->dictSize = preserveSize;
|
dctxPtr->dictSize = preserveSize;
|
||||||
}
|
}
|
||||||
memcpy(dctxPtr->dict + dctxPtr->dictSize, dstPtr, dstSize);
|
memcpy(dctxPtr->tmpOutBuffer + dctxPtr->dictSize, dstPtr, dstSize);
|
||||||
dctxPtr->dictSize += dstSize;
|
dctxPtr->dictSize += dstSize;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1277,10 +1277,10 @@ size_t LZ4F_decompress(LZ4F_decompressionContext_t decompressionContext,
|
|||||||
{
|
{
|
||||||
if (dctxPtr->dictSize > 128 KB)
|
if (dctxPtr->dictSize > 128 KB)
|
||||||
{
|
{
|
||||||
memcpy(dctxPtr->dict, dctxPtr->dict + dctxPtr->dictSize - 64 KB, 64 KB);
|
memcpy(dctxPtr->tmpOutBuffer, dctxPtr->dict + dctxPtr->dictSize - 64 KB, 64 KB);
|
||||||
dctxPtr->dictSize = 64 KB;
|
dctxPtr->dictSize = 64 KB;
|
||||||
}
|
}
|
||||||
dctxPtr->tmpOut = dctxPtr->dict + dctxPtr->dictSize;
|
dctxPtr->tmpOut = dctxPtr->tmpOutBuffer + dctxPtr->dictSize;
|
||||||
}
|
}
|
||||||
else /* dict not within tmp */
|
else /* dict not within tmp */
|
||||||
{
|
{
|
||||||
@ -1444,7 +1444,7 @@ size_t LZ4F_decompress(LZ4F_decompressionContext_t decompressionContext,
|
|||||||
{
|
{
|
||||||
size_t preserveSize = dctxPtr->tmpOut - dctxPtr->tmpOutBuffer;
|
size_t preserveSize = dctxPtr->tmpOut - dctxPtr->tmpOutBuffer;
|
||||||
size_t copySize = 64 KB - dctxPtr->tmpOutSize;
|
size_t copySize = 64 KB - dctxPtr->tmpOutSize;
|
||||||
BYTE* oldDictEnd = dctxPtr->dict + dctxPtr->dictSize - dctxPtr->tmpOutStart;
|
const BYTE* oldDictEnd = dctxPtr->dict + dctxPtr->dictSize - dctxPtr->tmpOutStart;
|
||||||
if (dctxPtr->tmpOutSize > 64 KB) copySize = 0;
|
if (dctxPtr->tmpOutSize > 64 KB) copySize = 0;
|
||||||
if (copySize > preserveSize) copySize = preserveSize;
|
if (copySize > preserveSize) copySize = preserveSize;
|
||||||
|
|
||||||
@ -1456,7 +1456,7 @@ size_t LZ4F_decompress(LZ4F_decompressionContext_t decompressionContext,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t newDictSize = dctxPtr->dictSize;
|
size_t newDictSize = dctxPtr->dictSize;
|
||||||
BYTE* oldDictEnd = dctxPtr->dict + dctxPtr->dictSize;
|
const BYTE* oldDictEnd = dctxPtr->dict + dctxPtr->dictSize;
|
||||||
if ((newDictSize) > 64 KB) newDictSize = 64 KB;
|
if ((newDictSize) > 64 KB) newDictSize = 64 KB;
|
||||||
|
|
||||||
memcpy(dctxPtr->tmpOutBuffer, oldDictEnd - newDictSize, newDictSize);
|
memcpy(dctxPtr->tmpOutBuffer, oldDictEnd - newDictSize, newDictSize);
|
||||||
|
11
lib/lz4hc.c
11
lib/lz4hc.c
@ -91,7 +91,7 @@ typedef struct
|
|||||||
const BYTE* end; /* next block here to continue on current prefix */
|
const BYTE* end; /* next block here to continue on current prefix */
|
||||||
const BYTE* base; /* All index relative to this position */
|
const BYTE* base; /* All index relative to this position */
|
||||||
const BYTE* dictBase; /* alternate base for extDict */
|
const BYTE* dictBase; /* alternate base for extDict */
|
||||||
const BYTE* inputBuffer;/* deprecated */
|
BYTE* inputBuffer; /* deprecated */
|
||||||
U32 dictLimit; /* below that point, need extDict */
|
U32 dictLimit; /* below that point, need extDict */
|
||||||
U32 lowLimit; /* below that point, no more dict */
|
U32 lowLimit; /* below that point, no more dict */
|
||||||
U32 nextToUpdate; /* index from which to continue dictionary update */
|
U32 nextToUpdate; /* index from which to continue dictionary update */
|
||||||
@ -119,7 +119,6 @@ static void LZ4HC_init (LZ4HC_Data_Structure* hc4, const BYTE* start)
|
|||||||
MEM_INIT(hc4->chainTable, 0xFF, sizeof(hc4->chainTable));
|
MEM_INIT(hc4->chainTable, 0xFF, sizeof(hc4->chainTable));
|
||||||
hc4->nextToUpdate = 64 KB;
|
hc4->nextToUpdate = 64 KB;
|
||||||
hc4->base = start - 64 KB;
|
hc4->base = start - 64 KB;
|
||||||
hc4->inputBuffer = start;
|
|
||||||
hc4->end = start;
|
hc4->end = start;
|
||||||
hc4->dictBase = start - 64 KB;
|
hc4->dictBase = start - 64 KB;
|
||||||
hc4->dictLimit = 64 KB;
|
hc4->dictLimit = 64 KB;
|
||||||
@ -628,7 +627,7 @@ static int LZ4_compressHC_continue_generic (LZ4HC_Data_Structure* ctxPtr,
|
|||||||
const BYTE* sourceEnd = (const BYTE*) source + inputSize;
|
const BYTE* sourceEnd = (const BYTE*) source + inputSize;
|
||||||
const BYTE* dictBegin = ctxPtr->dictBase + ctxPtr->lowLimit;
|
const BYTE* dictBegin = ctxPtr->dictBase + ctxPtr->lowLimit;
|
||||||
const BYTE* dictEnd = ctxPtr->dictBase + ctxPtr->dictLimit;
|
const BYTE* dictEnd = ctxPtr->dictBase + ctxPtr->dictLimit;
|
||||||
if ((sourceEnd > dictBegin) && ((BYTE*)source < dictEnd))
|
if ((sourceEnd > dictBegin) && ((const BYTE*)source < dictEnd))
|
||||||
{
|
{
|
||||||
if (sourceEnd > dictEnd) sourceEnd = dictEnd;
|
if (sourceEnd > dictEnd) sourceEnd = dictEnd;
|
||||||
ctxPtr->lowLimit = (U32)(sourceEnd - ctxPtr->dictBase);
|
ctxPtr->lowLimit = (U32)(sourceEnd - ctxPtr->dictBase);
|
||||||
@ -691,17 +690,19 @@ int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* ctx, const char* src,
|
|||||||
/* These functions currently generate deprecation warnings */
|
/* These functions currently generate deprecation warnings */
|
||||||
int LZ4_sizeofStreamStateHC(void) { return LZ4_STREAMHCSIZE; }
|
int LZ4_sizeofStreamStateHC(void) { return LZ4_STREAMHCSIZE; }
|
||||||
|
|
||||||
int LZ4_resetStreamStateHC(void* state, const char* inputBuffer)
|
int LZ4_resetStreamStateHC(void* state, char* inputBuffer)
|
||||||
{
|
{
|
||||||
if ((((size_t)state) & (sizeof(void*)-1)) != 0) return 1; /* Error : pointer is not aligned for pointer (32 or 64 bits) */
|
if ((((size_t)state) & (sizeof(void*)-1)) != 0) return 1; /* Error : pointer is not aligned for pointer (32 or 64 bits) */
|
||||||
LZ4HC_init((LZ4HC_Data_Structure*)state, (const BYTE*)inputBuffer);
|
LZ4HC_init((LZ4HC_Data_Structure*)state, (const BYTE*)inputBuffer);
|
||||||
|
((LZ4HC_Data_Structure*)state)->inputBuffer = (BYTE*)inputBuffer;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* LZ4_createHC (const char* inputBuffer)
|
void* LZ4_createHC (char* inputBuffer)
|
||||||
{
|
{
|
||||||
void* hc4 = ALLOCATOR(1, sizeof(LZ4HC_Data_Structure));
|
void* hc4 = ALLOCATOR(1, sizeof(LZ4HC_Data_Structure));
|
||||||
LZ4HC_init ((LZ4HC_Data_Structure*)hc4, (const BYTE*)inputBuffer);
|
LZ4HC_init ((LZ4HC_Data_Structure*)hc4, (const BYTE*)inputBuffer);
|
||||||
|
((LZ4HC_Data_Structure*)hc4)->inputBuffer = (BYTE*)inputBuffer;
|
||||||
return hc4;
|
return hc4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,13 +175,13 @@ int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, cons
|
|||||||
int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
|
int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||||
|
|
||||||
/* Streaming functions following the older model; should no longer be used */
|
/* Streaming functions following the older model; should no longer be used */
|
||||||
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") void* LZ4_createHC (const char* inputBuffer);
|
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") void* LZ4_createHC (char* inputBuffer);
|
||||||
LZ4_DEPRECATED("use LZ4_saveDictHC() instead") char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
|
LZ4_DEPRECATED("use LZ4_saveDictHC() instead") char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
|
||||||
LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") int LZ4_freeHC (void* LZ4HC_Data);
|
LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") int LZ4_freeHC (void* LZ4HC_Data);
|
||||||
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
|
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
|
||||||
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||||
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") int LZ4_sizeofStreamStateHC(void);
|
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") int LZ4_sizeofStreamStateHC(void);
|
||||||
LZ4_DEPRECATED("use LZ4_resetStreamHC() instead") int LZ4_resetStreamStateHC(void* state, const char* inputBuffer);
|
LZ4_DEPRECATED("use LZ4_resetStreamHC() instead") int LZ4_resetStreamStateHC(void* state, char* inputBuffer);
|
||||||
|
|
||||||
|
|
||||||
#if defined (__cplusplus)
|
#if defined (__cplusplus)
|
||||||
|
144
lib/xxhash.c
144
lib/xxhash.c
@ -29,13 +29,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
You can contact the author at :
|
You can contact the author at :
|
||||||
- xxHash source repository : https://github.com/Cyan4973/xxHash
|
- xxHash source repository : https://github.com/Cyan4973/xxHash
|
||||||
- public discussion board : https://groups.google.com/forum/#!forum/lz4c
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
* Tuning parameters
|
* Tuning parameters
|
||||||
***************************************/
|
**************************************/
|
||||||
/* Unaligned memory access is automatically enabled for "common" CPU, such as x86.
|
/* Unaligned memory access is automatically enabled for "common" CPU, such as x86.
|
||||||
* For others CPU, the compiler will be more cautious, and insert extra code to ensure aligned access is respected.
|
* For others CPU, the compiler will be more cautious, and insert extra code to ensure aligned access is respected.
|
||||||
* If you know your target CPU supports unaligned memory access, you want to force this option manually to improve performance.
|
* If you know your target CPU supports unaligned memory access, you want to force this option manually to improve performance.
|
||||||
@ -93,10 +92,7 @@ static void* XXH_malloc(size_t s) { return malloc(s); }
|
|||||||
static void XXH_free (void* p) { free(p); }
|
static void XXH_free (void* p) { free(p); }
|
||||||
/* for memcpy() */
|
/* for memcpy() */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
static void* XXH_memcpy(void* dest, const void* src, size_t size)
|
static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); }
|
||||||
{
|
|
||||||
return memcpy(dest,src,size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
@ -104,17 +100,17 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size)
|
|||||||
***************************************/
|
***************************************/
|
||||||
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
|
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
typedef uint8_t BYTE;
|
typedef uint8_t BYTE;
|
||||||
typedef uint16_t U16;
|
typedef uint16_t U16;
|
||||||
typedef uint32_t U32;
|
typedef uint32_t U32;
|
||||||
typedef int32_t S32;
|
typedef int32_t S32;
|
||||||
typedef uint64_t U64;
|
typedef uint64_t U64;
|
||||||
#else
|
#else
|
||||||
typedef unsigned char BYTE;
|
typedef unsigned char BYTE;
|
||||||
typedef unsigned short U16;
|
typedef unsigned short U16;
|
||||||
typedef unsigned int U32;
|
typedef unsigned int U32;
|
||||||
typedef signed int S32;
|
typedef signed int S32;
|
||||||
typedef unsigned long long U64;
|
typedef unsigned long long U64;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static U32 XXH_read32(const void* memPtr)
|
static U32 XXH_read32(const void* memPtr)
|
||||||
@ -133,7 +129,7 @@ static U64 XXH_read64(const void* memPtr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************
|
/******************************************
|
||||||
* Compiler-specific Functions and Macros
|
* Compiler-specific Functions and Macros
|
||||||
******************************************/
|
******************************************/
|
||||||
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
||||||
@ -175,7 +171,55 @@ static U64 XXH_swap64 (U64 x)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
/***************************************
|
||||||
|
* Architecture Macros
|
||||||
|
***************************************/
|
||||||
|
typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
|
||||||
|
#ifndef XXH_CPU_LITTLE_ENDIAN /* XXH_CPU_LITTLE_ENDIAN can be defined externally, for example using a compiler switch */
|
||||||
|
static const int one = 1;
|
||||||
|
# define XXH_CPU_LITTLE_ENDIAN (*(const char*)(&one))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************
|
||||||
|
* Memory reads
|
||||||
|
*****************************/
|
||||||
|
typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment;
|
||||||
|
|
||||||
|
FORCE_INLINE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
|
||||||
|
{
|
||||||
|
if (align==XXH_unaligned)
|
||||||
|
return endian==XXH_littleEndian ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr));
|
||||||
|
else
|
||||||
|
return endian==XXH_littleEndian ? *(const U32*)ptr : XXH_swap32(*(const U32*)ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE_INLINE U32 XXH_readLE32(const void* ptr, XXH_endianess endian)
|
||||||
|
{
|
||||||
|
return XXH_readLE32_align(ptr, endian, XXH_unaligned);
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE_INLINE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
|
||||||
|
{
|
||||||
|
if (align==XXH_unaligned)
|
||||||
|
return endian==XXH_littleEndian ? XXH_read64(ptr) : XXH_swap64(XXH_read64(ptr));
|
||||||
|
else
|
||||||
|
return endian==XXH_littleEndian ? *(const U64*)ptr : XXH_swap64(*(const U64*)ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE_INLINE U64 XXH_readLE64(const void* ptr, XXH_endianess endian)
|
||||||
|
{
|
||||||
|
return XXH_readLE64_align(ptr, endian, XXH_unaligned);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* Macros
|
||||||
|
***************************************/
|
||||||
|
#define XXH_STATIC_ASSERT(c) { enum { XXH_static_assert = 1/(!!(c)) }; } /* use only *after* variable declarations */
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************
|
||||||
* Constants
|
* Constants
|
||||||
***************************************/
|
***************************************/
|
||||||
#define PRIME32_1 2654435761U
|
#define PRIME32_1 2654435761U
|
||||||
@ -191,55 +235,7 @@ static U64 XXH_swap64 (U64 x)
|
|||||||
#define PRIME64_5 2870177450012600261ULL
|
#define PRIME64_5 2870177450012600261ULL
|
||||||
|
|
||||||
|
|
||||||
/***************************************
|
/*****************************
|
||||||
* Architecture Macros
|
|
||||||
****************************************/
|
|
||||||
typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
|
|
||||||
#ifndef XXH_CPU_LITTLE_ENDIAN /* XXH_CPU_LITTLE_ENDIAN can be defined externally, for example using a compiler switch */
|
|
||||||
static const int one = 1;
|
|
||||||
# define XXH_CPU_LITTLE_ENDIAN (*(char*)(&one))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
|
||||||
* Macros
|
|
||||||
***************************************/
|
|
||||||
#define XXH_STATIC_ASSERT(c) { enum { XXH_static_assert = 1/(!!(c)) }; } /* use only *after* variable declarations */
|
|
||||||
|
|
||||||
|
|
||||||
/****************************
|
|
||||||
* Memory reads
|
|
||||||
*****************************/
|
|
||||||
typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment;
|
|
||||||
|
|
||||||
FORCE_INLINE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
|
|
||||||
{
|
|
||||||
if (align==XXH_unaligned)
|
|
||||||
return endian==XXH_littleEndian ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr));
|
|
||||||
else
|
|
||||||
return endian==XXH_littleEndian ? *(U32*)ptr : XXH_swap32(*(U32*)ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCE_INLINE U32 XXH_readLE32(const void* ptr, XXH_endianess endian)
|
|
||||||
{
|
|
||||||
return XXH_readLE32_align(ptr, endian, XXH_unaligned);
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCE_INLINE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
|
|
||||||
{
|
|
||||||
if (align==XXH_unaligned)
|
|
||||||
return endian==XXH_littleEndian ? XXH_read64(ptr) : XXH_swap64(XXH_read64(ptr));
|
|
||||||
else
|
|
||||||
return endian==XXH_littleEndian ? *(U64*)ptr : XXH_swap64(*(U64*)ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCE_INLINE U64 XXH_readLE64(const void* ptr, XXH_endianess endian)
|
|
||||||
{
|
|
||||||
return XXH_readLE64_align(ptr, endian, XXH_unaligned);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************************
|
|
||||||
* Simple Hash Functions
|
* Simple Hash Functions
|
||||||
*****************************/
|
*****************************/
|
||||||
FORCE_INLINE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align)
|
FORCE_INLINE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align)
|
||||||
@ -319,7 +315,7 @@ FORCE_INLINE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int XXH32 (const void* input, size_t len, unsigned seed)
|
unsigned XXH32 (const void* input, size_t len, unsigned seed)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
/* Simple version, good for code maintenance, but unfortunately slow for small inputs */
|
/* Simple version, good for code maintenance, but unfortunately slow for small inputs */
|
||||||
@ -331,7 +327,7 @@ unsigned int XXH32 (const void* input, size_t len, unsigned seed)
|
|||||||
XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
|
XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
|
||||||
|
|
||||||
# if !defined(XXH_USE_UNALIGNED_ACCESS)
|
# if !defined(XXH_USE_UNALIGNED_ACCESS)
|
||||||
if ((((size_t)input) & 3) == 0) /* Input is aligned, let's leverage the speed advantage */
|
if ((((size_t)input) & 3) == 0) /* Input is 4-bytes aligned, leverage the speed benefit */
|
||||||
{
|
{
|
||||||
if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
|
if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
|
||||||
return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned);
|
return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned);
|
||||||
@ -488,7 +484,7 @@ unsigned long long XXH64 (const void* input, size_t len, unsigned long long seed
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************
|
/****************************************************
|
||||||
* Advanced Hash Functions
|
* Advanced Hash Functions
|
||||||
****************************************************/
|
****************************************************/
|
||||||
|
|
||||||
/*** Allocation ***/
|
/*** Allocation ***/
|
||||||
@ -672,9 +668,9 @@ XXH_errorcode XXH32_update (XXH32_state_t* state_in, const void* input, size_t l
|
|||||||
|
|
||||||
FORCE_INLINE U32 XXH32_digest_endian (const XXH32_state_t* state_in, XXH_endianess endian)
|
FORCE_INLINE U32 XXH32_digest_endian (const XXH32_state_t* state_in, XXH_endianess endian)
|
||||||
{
|
{
|
||||||
XXH_istate32_t* state = (XXH_istate32_t*) state_in;
|
const XXH_istate32_t* state = (const XXH_istate32_t*) state_in;
|
||||||
const BYTE * p = (const BYTE*)state->mem32;
|
const BYTE * p = (const BYTE*)state->mem32;
|
||||||
BYTE* bEnd = (BYTE*)(state->mem32) + state->memsize;
|
const BYTE* bEnd = (const BYTE*)(state->mem32) + state->memsize;
|
||||||
U32 h32;
|
U32 h32;
|
||||||
|
|
||||||
if (state->total_len >= 16)
|
if (state->total_len >= 16)
|
||||||
@ -826,9 +822,9 @@ XXH_errorcode XXH64_update (XXH64_state_t* state_in, const void* input, size_t l
|
|||||||
|
|
||||||
FORCE_INLINE U64 XXH64_digest_endian (const XXH64_state_t* state_in, XXH_endianess endian)
|
FORCE_INLINE U64 XXH64_digest_endian (const XXH64_state_t* state_in, XXH_endianess endian)
|
||||||
{
|
{
|
||||||
XXH_istate64_t * state = (XXH_istate64_t *) state_in;
|
const XXH_istate64_t * state = (const XXH_istate64_t *) state_in;
|
||||||
const BYTE * p = (const BYTE*)state->mem64;
|
const BYTE * p = (const BYTE*)state->mem64;
|
||||||
BYTE* bEnd = (BYTE*)state->mem64 + state->memsize;
|
const BYTE* bEnd = (const BYTE*)state->mem64 + state->memsize;
|
||||||
U64 h64;
|
U64 h64;
|
||||||
|
|
||||||
if (state->total_len >= 32)
|
if (state->total_len >= 32)
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
You can contact the author at :
|
You can contact the author at :
|
||||||
- xxHash source repository : http://code.google.com/p/xxhash/
|
- xxHash source repository : https://github.com/Cyan4973/xxHash
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Notice extracted from xxHash homepage :
|
/* Notice extracted from xxHash homepage :
|
||||||
@ -57,8 +57,8 @@ Q.Score is a measure of quality of the hash function.
|
|||||||
It depends on successfully passing SMHasher test set.
|
It depends on successfully passing SMHasher test set.
|
||||||
10 is a perfect score.
|
10 is a perfect score.
|
||||||
|
|
||||||
A new 64-bits version, named XXH64, is available since r35.
|
A 64-bits version, named XXH64, is available since r35.
|
||||||
It offers better speed for 64-bits applications.
|
It offers much better speed, but for 64-bits applications only.
|
||||||
Name Speed on 64 bits Speed on 32 bits
|
Name Speed on 64 bits Speed on 32 bits
|
||||||
XXH64 13.8 GB/s 1.9 GB/s
|
XXH64 13.8 GB/s 1.9 GB/s
|
||||||
XXH32 6.8 GB/s 6.0 GB/s
|
XXH32 6.8 GB/s 6.0 GB/s
|
||||||
|
@ -39,7 +39,7 @@ RELEASE?= r129
|
|||||||
DESTDIR?=
|
DESTDIR?=
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
CFLAGS ?= -O3
|
CFLAGS ?= -O3
|
||||||
CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -pedantic -DLZ4_VERSION=\"$(RELEASE)\"
|
CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -pedantic -DLZ4_VERSION=\"$(RELEASE)\"
|
||||||
FLAGS := -I../lib $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
|
FLAGS := -I../lib $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
BINDIR := $(PREFIX)/bin
|
BINDIR := $(PREFIX)/bin
|
||||||
|
@ -568,8 +568,8 @@ _output_error:
|
|||||||
static void locateBuffDiff(const void* buff1, const void* buff2, size_t size, unsigned nonContiguous)
|
static void locateBuffDiff(const void* buff1, const void* buff2, size_t size, unsigned nonContiguous)
|
||||||
{
|
{
|
||||||
int p=0;
|
int p=0;
|
||||||
BYTE* b1=(BYTE*)buff1;
|
const BYTE* b1=(const BYTE*)buff1;
|
||||||
BYTE* b2=(BYTE*)buff2;
|
const BYTE* b2=(const BYTE*)buff2;
|
||||||
if (nonContiguous)
|
if (nonContiguous)
|
||||||
{
|
{
|
||||||
DISPLAY("Non-contiguous output test (%i bytes)\n", (int)size);
|
DISPLAY("Non-contiguous output test (%i bytes)\n", (int)size);
|
||||||
|
@ -470,7 +470,7 @@ int main(int argc, char** argv)
|
|||||||
if (!decode) DISPLAYLEVEL(4, "Blocks size : %i KB\n", blockSize>>10);
|
if (!decode) DISPLAYLEVEL(4, "Blocks size : %i KB\n", blockSize>>10);
|
||||||
|
|
||||||
/* No input filename ==> use stdin */
|
/* No input filename ==> use stdin */
|
||||||
if (multiple_inputs) input_filename = inFileNames[0], output_filename = (char*)(inFileNames[0]);
|
if (multiple_inputs) input_filename = inFileNames[0], output_filename = (const char*)(inFileNames[0]);
|
||||||
if(!input_filename) { input_filename=stdinmark; }
|
if(!input_filename) { input_filename=stdinmark; }
|
||||||
|
|
||||||
/* Check if input or output are defined as console; trigger an error in this case */
|
/* Check if input or output are defined as console; trigger an error in this case */
|
||||||
|
@ -630,10 +630,10 @@ static unsigned LZ4IO_readLE32 (const void* s)
|
|||||||
|
|
||||||
static unsigned LZ4IO_fwriteSparse(FILE* file, const void* buffer, size_t bufferSize, unsigned storedSkips)
|
static unsigned LZ4IO_fwriteSparse(FILE* file, const void* buffer, size_t bufferSize, unsigned storedSkips)
|
||||||
{
|
{
|
||||||
size_t* const bufferT = (size_t*)buffer; /* Buffer is supposed malloc'ed, hence aligned on size_t */
|
const size_t* const bufferT = (const size_t*)buffer; /* Buffer is supposed malloc'ed, hence aligned on size_t */
|
||||||
size_t* ptrT = bufferT;
|
const size_t* ptrT = bufferT;
|
||||||
size_t bufferSizeT = bufferSize / sizeT;
|
size_t bufferSizeT = bufferSize / sizeT;
|
||||||
size_t* const bufferTEnd = bufferT + bufferSizeT;
|
const size_t* const bufferTEnd = bufferT + bufferSizeT;
|
||||||
static const size_t segmentSizeT = (32 KB) / sizeT;
|
static const size_t segmentSizeT = (32 KB) / sizeT;
|
||||||
|
|
||||||
if (!g_sparseFileSupport) /* normal write */
|
if (!g_sparseFileSupport) /* normal write */
|
||||||
@ -679,7 +679,7 @@ static unsigned LZ4IO_fwriteSparse(FILE* file, const void* buffer, size_t buffer
|
|||||||
|
|
||||||
if (bufferSize & maskT) /* size not multiple of sizeT : implies end of block */
|
if (bufferSize & maskT) /* size not multiple of sizeT : implies end of block */
|
||||||
{
|
{
|
||||||
const char* const restStart = (char*)bufferTEnd;
|
const char* const restStart = (const char*)bufferTEnd;
|
||||||
const char* restPtr = restStart;
|
const char* restPtr = restStart;
|
||||||
size_t restSize = bufferSize & maskT;
|
size_t restSize = bufferSize & maskT;
|
||||||
const char* const restEnd = restStart + restSize;
|
const char* const restEnd = restStart + restSize;
|
||||||
|
Loading…
Reference in New Issue
Block a user