mirror of
https://github.com/wolfpld/tracy
synced 2025-05-01 13:13:53 +00:00
Bump lz4 to 1.8.1.
This commit is contained in:
parent
b057c631a6
commit
7d6f5b875d
@ -85,6 +85,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-************************************
|
/*-************************************
|
||||||
* Dependency
|
* Dependency
|
||||||
**************************************/
|
**************************************/
|
||||||
@ -117,6 +118,28 @@
|
|||||||
# endif /* _MSC_VER */
|
# endif /* _MSC_VER */
|
||||||
#endif /* LZ4_FORCE_INLINE */
|
#endif /* LZ4_FORCE_INLINE */
|
||||||
|
|
||||||
|
/* LZ4_FORCE_O2_GCC_PPC64LE and LZ4_FORCE_O2_INLINE_GCC_PPC64LE
|
||||||
|
* Gcc on ppc64le generates an unrolled SIMDized loop for LZ4_wildCopy,
|
||||||
|
* together with a simple 8-byte copy loop as a fall-back path.
|
||||||
|
* However, this optimization hurts the decompression speed by >30%,
|
||||||
|
* because the execution does not go to the optimized loop
|
||||||
|
* for typical compressible data, and all of the preamble checks
|
||||||
|
* before going to the fall-back path become useless overhead.
|
||||||
|
* This optimization happens only with the -O3 flag, and -O2 generates
|
||||||
|
* a simple 8-byte copy loop.
|
||||||
|
* With gcc on ppc64le, all of the LZ4_decompress_* and LZ4_wildCopy
|
||||||
|
* functions are annotated with __attribute__((optimize("O2"))),
|
||||||
|
* and also LZ4_wildCopy is forcibly inlined, so that the O2 attribute
|
||||||
|
* of LZ4_wildCopy does not affect the compression speed.
|
||||||
|
*/
|
||||||
|
#if defined(__PPC64__) && defined(__LITTLE_ENDIAN__) && defined(__GNUC__)
|
||||||
|
# define LZ4_FORCE_O2_GCC_PPC64LE __attribute__((optimize("O2")))
|
||||||
|
# define LZ4_FORCE_O2_INLINE_GCC_PPC64LE __attribute__((optimize("O2"))) LZ4_FORCE_INLINE
|
||||||
|
#else
|
||||||
|
# define LZ4_FORCE_O2_GCC_PPC64LE
|
||||||
|
# define LZ4_FORCE_O2_INLINE_GCC_PPC64LE static
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (defined(__GNUC__) && (__GNUC__ >= 3)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)) || defined(__clang__)
|
#if (defined(__GNUC__) && (__GNUC__ >= 3)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)) || defined(__clang__)
|
||||||
# define expect(expr,value) (__builtin_expect ((expr),(value)) )
|
# define expect(expr,value) (__builtin_expect ((expr),(value)) )
|
||||||
#else
|
#else
|
||||||
@ -255,7 +278,8 @@ static void LZ4_copy8(void* dst, const void* src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* customized variant of memcpy, which can overwrite up to 8 bytes beyond dstEnd */
|
/* customized variant of memcpy, which can overwrite up to 8 bytes beyond dstEnd */
|
||||||
static void LZ4_wildCopy(void* dstPtr, const void* srcPtr, void* dstEnd)
|
LZ4_FORCE_O2_INLINE_GCC_PPC64LE
|
||||||
|
void LZ4_wildCopy(void* dstPtr, const void* srcPtr, void* dstEnd)
|
||||||
{
|
{
|
||||||
BYTE* d = (BYTE*)dstPtr;
|
BYTE* d = (BYTE*)dstPtr;
|
||||||
const BYTE* s = (const BYTE*)srcPtr;
|
const BYTE* s = (const BYTE*)srcPtr;
|
||||||
@ -291,15 +315,24 @@ static const int LZ4_minLength = (MFLIMIT+1);
|
|||||||
/*-************************************
|
/*-************************************
|
||||||
* Error detection
|
* Error detection
|
||||||
**************************************/
|
**************************************/
|
||||||
|
#if defined(LZ4_DEBUG) && (LZ4_DEBUG>=1)
|
||||||
|
# include <assert.h>
|
||||||
|
#else
|
||||||
|
# ifndef assert
|
||||||
|
# define assert(condition) ((void)0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LZ4_STATIC_ASSERT(c) { enum { LZ4_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
|
#define LZ4_STATIC_ASSERT(c) { enum { LZ4_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
|
||||||
|
|
||||||
#if defined(LZ4_DEBUG) && (LZ4_DEBUG>=2)
|
#if defined(LZ4_DEBUG) && (LZ4_DEBUG>=2)
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# define DEBUGLOG(l, ...) { \
|
static int g_debuglog_enable = 1;
|
||||||
if (l<=LZ4_DEBUG) { \
|
# define DEBUGLOG(l, ...) { \
|
||||||
fprintf(stderr, __FILE__ ": "); \
|
if ((g_debuglog_enable) && (l<=LZ4_DEBUG)) { \
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
fprintf(stderr, __FILE__ ": "); \
|
||||||
fprintf(stderr, " \n"); \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
|
fprintf(stderr, " \n"); \
|
||||||
} }
|
} }
|
||||||
#else
|
#else
|
||||||
# define DEBUGLOG(l, ...) {} /* disabled */
|
# define DEBUGLOG(l, ...) {} /* disabled */
|
||||||
@ -309,7 +342,7 @@ static const int LZ4_minLength = (MFLIMIT+1);
|
|||||||
/*-************************************
|
/*-************************************
|
||||||
* Common functions
|
* Common functions
|
||||||
**************************************/
|
**************************************/
|
||||||
static unsigned LZ4_NbCommonBytes (register reg_t val)
|
static unsigned LZ4_NbCommonBytes (reg_t val)
|
||||||
{
|
{
|
||||||
if (LZ4_isLittleEndian()) {
|
if (LZ4_isLittleEndian()) {
|
||||||
if (sizeof(val)==8) {
|
if (sizeof(val)==8) {
|
||||||
@ -320,7 +353,14 @@ static unsigned LZ4_NbCommonBytes (register reg_t val)
|
|||||||
# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
||||||
return (__builtin_ctzll((U64)val) >> 3);
|
return (__builtin_ctzll((U64)val) >> 3);
|
||||||
# else
|
# else
|
||||||
static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 };
|
static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2,
|
||||||
|
0, 3, 1, 3, 1, 4, 2, 7,
|
||||||
|
0, 2, 3, 6, 1, 5, 3, 5,
|
||||||
|
1, 3, 4, 4, 2, 5, 6, 7,
|
||||||
|
7, 0, 1, 2, 3, 3, 4, 6,
|
||||||
|
2, 6, 5, 5, 3, 4, 5, 6,
|
||||||
|
7, 1, 2, 4, 6, 4, 4, 5,
|
||||||
|
7, 2, 6, 5, 7, 6, 7, 7 };
|
||||||
return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
|
return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
|
||||||
# endif
|
# endif
|
||||||
} else /* 32 bits */ {
|
} else /* 32 bits */ {
|
||||||
@ -331,12 +371,15 @@ static unsigned LZ4_NbCommonBytes (register reg_t val)
|
|||||||
# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
||||||
return (__builtin_ctz((U32)val) >> 3);
|
return (__builtin_ctz((U32)val) >> 3);
|
||||||
# else
|
# else
|
||||||
static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
|
static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0,
|
||||||
|
3, 2, 2, 1, 3, 2, 0, 1,
|
||||||
|
3, 3, 1, 2, 2, 2, 2, 0,
|
||||||
|
3, 1, 2, 0, 1, 0, 1, 1 };
|
||||||
return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
|
return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
} else /* Big Endian CPU */ {
|
} else /* Big Endian CPU */ {
|
||||||
if (sizeof(val)==8) {
|
if (sizeof(val)==8) { /* 64-bits */
|
||||||
# if defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
# if defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
||||||
unsigned long r = 0;
|
unsigned long r = 0;
|
||||||
_BitScanReverse64( &r, val );
|
_BitScanReverse64( &r, val );
|
||||||
@ -344,8 +387,11 @@ static unsigned LZ4_NbCommonBytes (register reg_t val)
|
|||||||
# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
||||||
return (__builtin_clzll((U64)val) >> 3);
|
return (__builtin_clzll((U64)val) >> 3);
|
||||||
# else
|
# else
|
||||||
|
static const U32 by32 = sizeof(val)*4; /* 32 on 64 bits (goal), 16 on 32 bits.
|
||||||
|
Just to avoid some static analyzer complaining about shift by 32 on 32-bits target.
|
||||||
|
Note that this code path is never triggered in 32-bits mode. */
|
||||||
unsigned r;
|
unsigned r;
|
||||||
if (!(val>>32)) { r=4; } else { r=0; val>>=32; }
|
if (!(val>>by32)) { r=4; } else { r=0; val>>=by32; }
|
||||||
if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
|
if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
|
||||||
r += (!val);
|
r += (!val);
|
||||||
return r;
|
return r;
|
||||||
@ -368,11 +414,20 @@ static unsigned LZ4_NbCommonBytes (register reg_t val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define STEPSIZE sizeof(reg_t)
|
#define STEPSIZE sizeof(reg_t)
|
||||||
static unsigned LZ4_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLimit)
|
LZ4_FORCE_INLINE
|
||||||
|
unsigned LZ4_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLimit)
|
||||||
{
|
{
|
||||||
const BYTE* const pStart = pIn;
|
const BYTE* const pStart = pIn;
|
||||||
|
|
||||||
while (likely(pIn<pInLimit-(STEPSIZE-1))) {
|
if (likely(pIn < pInLimit-(STEPSIZE-1))) {
|
||||||
|
reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
|
||||||
|
if (!diff) {
|
||||||
|
pIn+=STEPSIZE; pMatch+=STEPSIZE;
|
||||||
|
} else {
|
||||||
|
return LZ4_NbCommonBytes(diff);
|
||||||
|
} }
|
||||||
|
|
||||||
|
while (likely(pIn < pInLimit-(STEPSIZE-1))) {
|
||||||
reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
|
reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
|
||||||
if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
|
if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
|
||||||
pIn += LZ4_NbCommonBytes(diff);
|
pIn += LZ4_NbCommonBytes(diff);
|
||||||
@ -945,6 +1000,7 @@ LZ4_stream_t* LZ4_createStream(void)
|
|||||||
|
|
||||||
void LZ4_resetStream (LZ4_stream_t* LZ4_stream)
|
void LZ4_resetStream (LZ4_stream_t* LZ4_stream)
|
||||||
{
|
{
|
||||||
|
DEBUGLOG(4, "LZ4_resetStream");
|
||||||
MEM_INIT(LZ4_stream, 0, sizeof(LZ4_stream_t));
|
MEM_INIT(LZ4_stream, 0, sizeof(LZ4_stream_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1110,6 +1166,7 @@ int LZ4_saveDict (LZ4_stream_t* LZ4_dict, char* safeBuffer, int dictSize)
|
|||||||
* Note that it is important for performance that this function really get inlined,
|
* Note that it is important for performance that this function really get inlined,
|
||||||
* in order to remove useless branches during compilation optimization.
|
* in order to remove useless branches during compilation optimization.
|
||||||
*/
|
*/
|
||||||
|
LZ4_FORCE_O2_GCC_PPC64LE
|
||||||
LZ4_FORCE_INLINE int LZ4_decompress_generic(
|
LZ4_FORCE_INLINE int LZ4_decompress_generic(
|
||||||
const char* const src,
|
const char* const src,
|
||||||
char* const dst,
|
char* const dst,
|
||||||
@ -1120,7 +1177,7 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
|
|||||||
int partialDecoding, /* full, partial */
|
int partialDecoding, /* full, partial */
|
||||||
int targetOutputSize, /* only used if partialDecoding==partial */
|
int targetOutputSize, /* only used if partialDecoding==partial */
|
||||||
int dict, /* noDict, withPrefix64k, usingExtDict */
|
int dict, /* noDict, withPrefix64k, usingExtDict */
|
||||||
const BYTE* const lowPrefix, /* == dst when no prefix */
|
const BYTE* const lowPrefix, /* always <= dst, == dst when no prefix */
|
||||||
const BYTE* const dictStart, /* only if dict==usingExtDict */
|
const BYTE* const dictStart, /* only if dict==usingExtDict */
|
||||||
const size_t dictSize /* note : = 0 if noDict */
|
const size_t dictSize /* note : = 0 if noDict */
|
||||||
)
|
)
|
||||||
@ -1134,15 +1191,15 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
|
|||||||
BYTE* oexit = op + targetOutputSize;
|
BYTE* oexit = op + targetOutputSize;
|
||||||
|
|
||||||
const BYTE* const dictEnd = (const BYTE*)dictStart + dictSize;
|
const BYTE* const dictEnd = (const BYTE*)dictStart + dictSize;
|
||||||
const unsigned dec32table[] = {0, 1, 2, 1, 4, 4, 4, 4};
|
const unsigned inc32table[8] = {0, 1, 2, 1, 0, 4, 4, 4};
|
||||||
const int dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3};
|
const int dec64table[8] = {0, 0, 0, -1, -4, 1, 2, 3};
|
||||||
|
|
||||||
const int safeDecode = (endOnInput==endOnInputSize);
|
const int safeDecode = (endOnInput==endOnInputSize);
|
||||||
const int checkOffset = ((safeDecode) && (dictSize < (int)(64 KB)));
|
const int checkOffset = ((safeDecode) && (dictSize < (int)(64 KB)));
|
||||||
|
|
||||||
|
|
||||||
/* Special cases */
|
/* Special cases */
|
||||||
if ((partialDecoding) && (oexit > oend-MFLIMIT)) oexit = oend-MFLIMIT; /* targetOutputSize too high => decode everything */
|
if ((partialDecoding) && (oexit > oend-MFLIMIT)) oexit = oend-MFLIMIT; /* targetOutputSize too high => just decode everything */
|
||||||
if ((endOnInput) && (unlikely(outputSize==0))) return ((srcSize==1) && (*ip==0)) ? 0 : -1; /* Empty output buffer */
|
if ((endOnInput) && (unlikely(outputSize==0))) return ((srcSize==1) && (*ip==0)) ? 0 : -1; /* Empty output buffer */
|
||||||
if ((!endOnInput) && (unlikely(outputSize==0))) return (*ip==0?1:-1);
|
if ((!endOnInput) && (unlikely(outputSize==0))) return (*ip==0?1:-1);
|
||||||
|
|
||||||
@ -1152,8 +1209,27 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
|
|||||||
const BYTE* match;
|
const BYTE* match;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
|
||||||
/* get literal length */
|
|
||||||
unsigned const token = *ip++;
|
unsigned const token = *ip++;
|
||||||
|
|
||||||
|
/* shortcut for common case :
|
||||||
|
* in most circumstances, we expect to decode small matches (<= 18 bytes) separated by few literals (<= 14 bytes).
|
||||||
|
* this shortcut was tested on x86 and x64, where it improves decoding speed.
|
||||||
|
* it has not yet been benchmarked on ARM, Power, mips, etc. */
|
||||||
|
if (((ip + 14 /*maxLL*/ + 2 /*offset*/ <= iend)
|
||||||
|
& (op + 14 /*maxLL*/ + 18 /*maxML*/ <= oend))
|
||||||
|
& ((token < (15<<ML_BITS)) & ((token & ML_MASK) != 15)) ) {
|
||||||
|
size_t const ll = token >> ML_BITS;
|
||||||
|
size_t const off = LZ4_readLE16(ip+ll);
|
||||||
|
const BYTE* const matchPtr = op + ll - off; /* pointer underflow risk ? */
|
||||||
|
if ((off >= 18) /* do not deal with overlapping matches */ & (matchPtr >= lowPrefix)) {
|
||||||
|
size_t const ml = (token & ML_MASK) + MINMATCH;
|
||||||
|
memcpy(op, ip, 16); op += ll; ip += ll + 2 /*offset*/;
|
||||||
|
memcpy(op, matchPtr, 18); op += ml;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* decode literal length */
|
||||||
if ((length=(token>>ML_BITS)) == RUN_MASK) {
|
if ((length=(token>>ML_BITS)) == RUN_MASK) {
|
||||||
unsigned s;
|
unsigned s;
|
||||||
do {
|
do {
|
||||||
@ -1231,14 +1307,13 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
|
|||||||
/* copy match within block */
|
/* copy match within block */
|
||||||
cpy = op + length;
|
cpy = op + length;
|
||||||
if (unlikely(offset<8)) {
|
if (unlikely(offset<8)) {
|
||||||
const int dec64 = dec64table[offset];
|
|
||||||
op[0] = match[0];
|
op[0] = match[0];
|
||||||
op[1] = match[1];
|
op[1] = match[1];
|
||||||
op[2] = match[2];
|
op[2] = match[2];
|
||||||
op[3] = match[3];
|
op[3] = match[3];
|
||||||
match += dec32table[offset];
|
match += inc32table[offset];
|
||||||
memcpy(op+4, match, 4);
|
memcpy(op+4, match, 4);
|
||||||
match -= dec64;
|
match -= dec64table[offset];
|
||||||
} else { LZ4_copy8(op, match); match+=8; }
|
} else { LZ4_copy8(op, match); match+=8; }
|
||||||
op += 8;
|
op += 8;
|
||||||
|
|
||||||
@ -1255,7 +1330,7 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
|
|||||||
LZ4_copy8(op, match);
|
LZ4_copy8(op, match);
|
||||||
if (length>16) LZ4_wildCopy(op+8, match+8, cpy);
|
if (length>16) LZ4_wildCopy(op+8, match+8, cpy);
|
||||||
}
|
}
|
||||||
op=cpy; /* correction */
|
op = cpy; /* correction */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end of decoding */
|
/* end of decoding */
|
||||||
@ -1270,16 +1345,19 @@ _output_error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LZ4_FORCE_O2_GCC_PPC64LE
|
||||||
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)
|
||||||
{
|
{
|
||||||
return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize, endOnInputSize, full, 0, noDict, (BYTE*)dest, NULL, 0);
|
return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize, endOnInputSize, full, 0, noDict, (BYTE*)dest, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LZ4_FORCE_O2_GCC_PPC64LE
|
||||||
int LZ4_decompress_safe_partial(const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize)
|
int LZ4_decompress_safe_partial(const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize)
|
||||||
{
|
{
|
||||||
return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize, endOnInputSize, partial, targetOutputSize, noDict, (BYTE*)dest, NULL, 0);
|
return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize, endOnInputSize, partial, targetOutputSize, noDict, (BYTE*)dest, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LZ4_FORCE_O2_GCC_PPC64LE
|
||||||
int LZ4_decompress_fast(const char* source, char* dest, int originalSize)
|
int LZ4_decompress_fast(const char* source, char* dest, int originalSize)
|
||||||
{
|
{
|
||||||
return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withPrefix64k, (BYTE*)(dest - 64 KB), NULL, 64 KB);
|
return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withPrefix64k, (BYTE*)(dest - 64 KB), NULL, 64 KB);
|
||||||
@ -1325,6 +1403,7 @@ int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dicti
|
|||||||
If it's not possible, save the relevant part of decoded data into a safe buffer,
|
If it's not possible, save the relevant part of decoded data into a safe buffer,
|
||||||
and indicate where it stands using LZ4_setStreamDecode()
|
and indicate where it stands using LZ4_setStreamDecode()
|
||||||
*/
|
*/
|
||||||
|
LZ4_FORCE_O2_GCC_PPC64LE
|
||||||
int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxOutputSize)
|
int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxOutputSize)
|
||||||
{
|
{
|
||||||
LZ4_streamDecode_t_internal* lz4sd = &LZ4_streamDecode->internal_donotuse;
|
LZ4_streamDecode_t_internal* lz4sd = &LZ4_streamDecode->internal_donotuse;
|
||||||
@ -1351,6 +1430,7 @@ int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const ch
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LZ4_FORCE_O2_GCC_PPC64LE
|
||||||
int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize)
|
int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize)
|
||||||
{
|
{
|
||||||
LZ4_streamDecode_t_internal* lz4sd = &LZ4_streamDecode->internal_donotuse;
|
LZ4_streamDecode_t_internal* lz4sd = &LZ4_streamDecode->internal_donotuse;
|
||||||
@ -1385,6 +1465,7 @@ Advanced decoding functions :
|
|||||||
the dictionary must be explicitly provided within parameters
|
the dictionary must be explicitly provided within parameters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
LZ4_FORCE_O2_GCC_PPC64LE
|
||||||
LZ4_FORCE_INLINE int LZ4_decompress_usingDict_generic(const char* source, char* dest, int compressedSize, int maxOutputSize, int safe, const char* dictStart, int dictSize)
|
LZ4_FORCE_INLINE int LZ4_decompress_usingDict_generic(const char* source, char* dest, int compressedSize, int maxOutputSize, int safe, const char* dictStart, int dictSize)
|
||||||
{
|
{
|
||||||
if (dictSize==0)
|
if (dictSize==0)
|
||||||
@ -1397,17 +1478,20 @@ LZ4_FORCE_INLINE int LZ4_decompress_usingDict_generic(const char* source, char*
|
|||||||
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, usingExtDict, (BYTE*)dest, (const BYTE*)dictStart, dictSize);
|
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, usingExtDict, (BYTE*)dest, (const BYTE*)dictStart, dictSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LZ4_FORCE_O2_GCC_PPC64LE
|
||||||
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)
|
||||||
{
|
{
|
||||||
return LZ4_decompress_usingDict_generic(source, dest, compressedSize, maxOutputSize, 1, dictStart, dictSize);
|
return LZ4_decompress_usingDict_generic(source, dest, compressedSize, maxOutputSize, 1, dictStart, dictSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LZ4_FORCE_O2_GCC_PPC64LE
|
||||||
int LZ4_decompress_fast_usingDict(const char* source, char* dest, int originalSize, const char* dictStart, int dictSize)
|
int LZ4_decompress_fast_usingDict(const char* source, char* dest, int originalSize, const char* dictStart, int dictSize)
|
||||||
{
|
{
|
||||||
return LZ4_decompress_usingDict_generic(source, dest, 0, originalSize, 0, dictStart, dictSize);
|
return LZ4_decompress_usingDict_generic(source, dest, 0, originalSize, 0, dictStart, dictSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* debug function */
|
/* debug function */
|
||||||
|
LZ4_FORCE_O2_GCC_PPC64LE
|
||||||
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, (const BYTE*)dictStart, dictSize);
|
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, usingExtDict, (BYTE*)dest, (const BYTE*)dictStart, dictSize);
|
||||||
|
@ -73,24 +73,28 @@ namespace tracy
|
|||||||
/*
|
/*
|
||||||
* LZ4_DLL_EXPORT :
|
* LZ4_DLL_EXPORT :
|
||||||
* Enable exporting of functions when building a Windows DLL
|
* Enable exporting of functions when building a Windows DLL
|
||||||
* LZ4LIB_API :
|
* LZ4LIB_VISIBILITY :
|
||||||
* Control library symbols visibility.
|
* Control library symbols visibility.
|
||||||
*/
|
*/
|
||||||
#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
|
#ifndef LZ4LIB_VISIBILITY
|
||||||
# define LZ4LIB_API __declspec(dllexport)
|
# if defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
|
# define LZ4LIB_VISIBILITY __attribute__ ((visibility ("default")))
|
||||||
# define LZ4LIB_API __declspec(dllimport) /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
|
# else
|
||||||
#elif defined(__GNUC__) && (__GNUC__ >= 4)
|
# define LZ4LIB_VISIBILITY
|
||||||
# define LZ4LIB_API __attribute__ ((__visibility__ ("default")))
|
# endif
|
||||||
#else
|
#endif
|
||||||
# define LZ4LIB_API
|
#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
|
||||||
|
# define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY
|
||||||
|
#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
|
||||||
|
# define LZ4LIB_API __declspec(dllimport) LZ4LIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
|
||||||
|
#else
|
||||||
|
# define LZ4LIB_API LZ4LIB_VISIBILITY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*------ Version ------*/
|
/*------ Version ------*/
|
||||||
#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
|
#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
|
||||||
#define LZ4_VERSION_MINOR 8 /* for new (non-breaking) interface capabilities */
|
#define LZ4_VERSION_MINOR 8 /* for new (non-breaking) interface capabilities */
|
||||||
#define LZ4_VERSION_RELEASE 0 /* for tweaks, bug-fixes, or development */
|
#define LZ4_VERSION_RELEASE 1 /* for tweaks, bug-fixes, or development */
|
||||||
|
|
||||||
#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
|
#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
|
||||||
|
|
||||||
@ -121,30 +125,30 @@ LZ4LIB_API const char* LZ4_versionString (void); /**< library version string;
|
|||||||
* Simple Functions
|
* Simple Functions
|
||||||
**************************************/
|
**************************************/
|
||||||
/*! LZ4_compress_default() :
|
/*! LZ4_compress_default() :
|
||||||
Compresses 'sourceSize' bytes from buffer 'source'
|
Compresses 'srcSize' bytes from buffer 'src'
|
||||||
into already allocated 'dest' buffer of size 'maxDestSize'.
|
into already allocated 'dst' buffer of size 'dstCapacity'.
|
||||||
Compression is guaranteed to succeed if 'maxDestSize' >= LZ4_compressBound(sourceSize).
|
Compression is guaranteed to succeed if 'dstCapacity' >= LZ4_compressBound(srcSize).
|
||||||
It also runs faster, so it's a recommended setting.
|
It also runs faster, so it's a recommended setting.
|
||||||
If the function cannot compress 'source' into a more limited 'dest' budget,
|
If the function cannot compress 'src' into a limited 'dst' budget,
|
||||||
compression stops *immediately*, and the function result is zero.
|
compression stops *immediately*, and the function result is zero.
|
||||||
As a consequence, 'dest' content is not valid.
|
As a consequence, 'dst' content is not valid.
|
||||||
This function never writes outside 'dest' buffer, nor read outside 'source' buffer.
|
This function never writes outside 'dst' buffer, nor read outside 'source' buffer.
|
||||||
sourceSize : Max supported value is LZ4_MAX_INPUT_VALUE
|
srcSize : supported max value is LZ4_MAX_INPUT_VALUE
|
||||||
maxDestSize : full or partial size of buffer 'dest' (which must be already allocated)
|
dstCapacity : full or partial size of buffer 'dst' (which must be already allocated)
|
||||||
return : the number of bytes written into buffer 'dest' (necessarily <= maxOutputSize)
|
return : the number of bytes written into buffer 'dst' (necessarily <= dstCapacity)
|
||||||
or 0 if compression fails */
|
or 0 if compression fails */
|
||||||
LZ4LIB_API int LZ4_compress_default(const char* source, char* dest, int sourceSize, int maxDestSize);
|
LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity);
|
||||||
|
|
||||||
/*! LZ4_decompress_safe() :
|
/*! LZ4_decompress_safe() :
|
||||||
compressedSize : is the precise full size of the compressed block.
|
compressedSize : is the exact complete size of the compressed block.
|
||||||
maxDecompressedSize : is the size of destination buffer, which must be already allocated.
|
dstCapacity : is the size of destination buffer, which must be already allocated.
|
||||||
return : the number of bytes decompressed into destination buffer (necessarily <= maxDecompressedSize)
|
return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
|
||||||
If destination buffer is not large enough, decoding will stop and output an error code (<0).
|
If destination buffer is not large enough, decoding will stop and output an error code (negative value).
|
||||||
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||||
This function is protected against buffer overflow exploits, including malicious data packets.
|
This function is protected against buffer overflow exploits, including malicious data packets.
|
||||||
It never writes outside output buffer, nor reads outside input buffer.
|
It never writes outside output buffer, nor reads outside input buffer.
|
||||||
*/
|
*/
|
||||||
LZ4LIB_API int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize);
|
LZ4LIB_API int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity);
|
||||||
|
|
||||||
|
|
||||||
/*-************************************
|
/*-************************************
|
||||||
@ -173,7 +177,7 @@ LZ4_compress_fast() :
|
|||||||
An acceleration value of "1" is the same as regular LZ4_compress_default()
|
An acceleration value of "1" is the same as regular LZ4_compress_default()
|
||||||
Values <= 0 will be replaced by ACCELERATION_DEFAULT (see lz4.c), which is 1.
|
Values <= 0 will be replaced by ACCELERATION_DEFAULT (see lz4.c), which is 1.
|
||||||
*/
|
*/
|
||||||
LZ4LIB_API int LZ4_compress_fast (const char* source, char* dest, int sourceSize, int maxDestSize, int acceleration);
|
LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -184,49 +188,49 @@ LZ4_compress_fast_extState() :
|
|||||||
Then, provide it as 'void* state' to compression function.
|
Then, provide it as 'void* state' to compression function.
|
||||||
*/
|
*/
|
||||||
LZ4LIB_API int LZ4_sizeofState(void);
|
LZ4LIB_API int LZ4_sizeofState(void);
|
||||||
LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* source, char* dest, int inputSize, int maxDestSize, int acceleration);
|
LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
LZ4_compress_destSize() :
|
LZ4_compress_destSize() :
|
||||||
Reverse the logic, by compressing as much data as possible from 'source' buffer
|
Reverse the logic : compresses as much data as possible from 'src' buffer
|
||||||
into already allocated buffer 'dest' of size 'targetDestSize'.
|
into already allocated buffer 'dst' of size 'targetDestSize'.
|
||||||
This function either compresses the entire 'source' content into 'dest' if it's large enough,
|
This function either compresses the entire 'src' content into 'dst' if it's large enough,
|
||||||
or fill 'dest' buffer completely with as much data as possible from 'source'.
|
or fill 'dst' buffer completely with as much data as possible from 'src'.
|
||||||
*sourceSizePtr : will be modified to indicate how many bytes where read from 'source' to fill 'dest'.
|
*srcSizePtr : will be modified to indicate how many bytes where read from 'src' to fill 'dst'.
|
||||||
New value is necessarily <= old value.
|
New value is necessarily <= old value.
|
||||||
return : Nb bytes written into 'dest' (necessarily <= targetDestSize)
|
return : Nb bytes written into 'dst' (necessarily <= targetDestSize)
|
||||||
or 0 if compression fails
|
or 0 if compression fails
|
||||||
*/
|
*/
|
||||||
LZ4LIB_API int LZ4_compress_destSize (const char* source, char* dest, int* sourceSizePtr, int targetDestSize);
|
LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize);
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
LZ4_decompress_fast() :
|
LZ4_decompress_fast() : (unsafe!!)
|
||||||
originalSize : is the original and therefore uncompressed size
|
originalSize : is the original uncompressed size
|
||||||
return : the number of bytes read from the source buffer (in other words, the compressed size)
|
return : the number of bytes read from the source buffer (in other words, the compressed size)
|
||||||
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||||
Destination buffer must be already allocated. Its size must be a minimum of 'originalSize' bytes.
|
Destination buffer must be already allocated. Its size must be >= 'originalSize' bytes.
|
||||||
note : This function fully respect memory boundaries for properly formed compressed data.
|
note : This function respects memory boundaries for *properly formed* compressed data.
|
||||||
It is a bit faster than LZ4_decompress_safe().
|
It is a bit faster than LZ4_decompress_safe().
|
||||||
However, it does not provide any protection against intentionally modified data stream (malicious input).
|
However, it does not provide any protection against intentionally modified data stream (malicious input).
|
||||||
Use this function in trusted environment only (data to decode comes from a trusted source).
|
Use this function in trusted environment only (data to decode comes from a trusted source).
|
||||||
*/
|
*/
|
||||||
LZ4LIB_API int LZ4_decompress_fast (const char* source, char* dest, int originalSize);
|
LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
LZ4_decompress_safe_partial() :
|
LZ4_decompress_safe_partial() :
|
||||||
This function decompress a compressed block of size 'compressedSize' at position 'source'
|
This function decompress a compressed block of size 'srcSize' at position 'src'
|
||||||
into destination buffer 'dest' of size 'maxDecompressedSize'.
|
into destination buffer 'dst' of size 'dstCapacity'.
|
||||||
The function tries to stop decompressing operation as soon as 'targetOutputSize' has been reached,
|
The function will decompress a minimum of 'targetOutputSize' bytes, and stop after that.
|
||||||
reducing decompression time.
|
However, it's not accurate, and may write more than 'targetOutputSize' (but <= dstCapacity).
|
||||||
return : the number of bytes decoded in the destination buffer (necessarily <= maxDecompressedSize)
|
@return : the number of bytes decoded in the destination buffer (necessarily <= dstCapacity)
|
||||||
Note : this number can be < 'targetOutputSize' should the compressed block to decode be smaller.
|
Note : this number can be < 'targetOutputSize' should the compressed block contain less data.
|
||||||
Always control how many bytes were decoded.
|
Always control how many bytes were decoded.
|
||||||
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||||
This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets
|
This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets.
|
||||||
*/
|
*/
|
||||||
LZ4LIB_API int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize);
|
LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity);
|
||||||
|
|
||||||
|
|
||||||
/*-*********************************************
|
/*-*********************************************
|
||||||
@ -318,8 +322,8 @@ LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const
|
|||||||
* Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer,
|
* Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer,
|
||||||
* and indicate where it is saved using LZ4_setStreamDecode() before decompressing next block.
|
* and indicate where it is saved using LZ4_setStreamDecode() before decompressing next block.
|
||||||
*/
|
*/
|
||||||
LZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxDecompressedSize);
|
LZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int srcSize, int dstCapacity);
|
||||||
LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize);
|
LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize);
|
||||||
|
|
||||||
|
|
||||||
/*! LZ4_decompress_*_usingDict() :
|
/*! LZ4_decompress_*_usingDict() :
|
||||||
@ -327,8 +331,8 @@ LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecod
|
|||||||
* a combination of LZ4_setStreamDecode() followed by LZ4_decompress_*_continue()
|
* a combination of LZ4_setStreamDecode() followed by LZ4_decompress_*_continue()
|
||||||
* They are stand-alone, and don't need an LZ4_streamDecode_t structure.
|
* They are stand-alone, and don't need an LZ4_streamDecode_t structure.
|
||||||
*/
|
*/
|
||||||
LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxDecompressedSize, const char* dictStart, int dictSize);
|
LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* src, char* dst, int srcSize, int dstCapcity, const char* dictStart, int dictSize);
|
||||||
LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize);
|
LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize);
|
||||||
|
|
||||||
|
|
||||||
/*^**********************************************
|
/*^**********************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user