lib: Update LZ4 module to v1.9.3+
Update lz4 module using official repository from revision [1].
Keep in mind lz4hc wasn't updated thus it is not used. It may not
compile anymore.
[1]: 4ebe313e00
Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
Change-Id: I51a35b54039c6a67f653ccd9f80ccbec8e3cf759
(cherry picked from commit 6961738d952fd9b5e43852700cec19154c71672a)
Signed-off-by: TogoFire <togofire@mailfence.com>
Signed-off-by: Kanishk <kanishkthederp@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
This commit is contained in:
parent
36d90f7579
commit
6ac6e18ba0
4 changed files with 1749 additions and 1133 deletions
|
|
@ -42,7 +42,7 @@
|
|||
#define __LZ4_H__
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/string.h> /* memset, memcpy */
|
||||
#include <linux/string.h> /* memset, memcpy */
|
||||
|
||||
/*-************************************************************************
|
||||
* CONSTANTS
|
||||
|
|
@ -57,23 +57,24 @@
|
|||
*/
|
||||
#define LZ4_MEMORY_USAGE 14
|
||||
|
||||
#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
|
||||
#define LZ4_COMPRESSBOUND(isize) (\
|
||||
(unsigned int)(isize) > (unsigned int)LZ4_MAX_INPUT_SIZE \
|
||||
? 0 \
|
||||
: (isize) + ((isize)/255) + 16)
|
||||
#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
|
||||
#define LZ4_COMPRESSBOUND(isize) \
|
||||
((unsigned int)(isize) > (unsigned int)LZ4_MAX_INPUT_SIZE ? \
|
||||
0 : \
|
||||
(isize) + ((isize) / 255) + 16)
|
||||
|
||||
#define LZ4_ACCELERATION_DEFAULT 1
|
||||
#define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
|
||||
#define LZ4_ACCELERATION_MAX 65537
|
||||
#define LZ4_HASHLOG (LZ4_MEMORY_USAGE - 2)
|
||||
#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
|
||||
#define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG)
|
||||
|
||||
#define LZ4HC_MIN_CLEVEL 3
|
||||
#define LZ4HC_DEFAULT_CLEVEL 9
|
||||
#define LZ4HC_MAX_CLEVEL 16
|
||||
#define LZ4HC_MIN_CLEVEL 3
|
||||
#define LZ4HC_DEFAULT_CLEVEL 9
|
||||
#define LZ4HC_MAX_CLEVEL 16
|
||||
|
||||
#define LZ4HC_DICTIONARY_LOGSIZE 16
|
||||
#define LZ4HC_MAXD (1<<LZ4HC_DICTIONARY_LOGSIZE)
|
||||
#define LZ4HC_MAXD (1 << LZ4HC_DICTIONARY_LOGSIZE)
|
||||
#define LZ4HC_MAXD_MASK (LZ4HC_MAXD - 1)
|
||||
#define LZ4HC_HASH_LOG (LZ4HC_DICTIONARY_LOGSIZE - 1)
|
||||
#define LZ4HC_HASHTABLESIZE (1 << LZ4HC_HASH_LOG)
|
||||
|
|
@ -82,29 +83,32 @@
|
|||
/*-************************************************************************
|
||||
* STREAMING CONSTANTS AND STRUCTURES
|
||||
**************************************************************************/
|
||||
#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE - 3)) + 4)
|
||||
#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(unsigned long long))
|
||||
#define LZ4_STREAMSIZE \
|
||||
((1UL << LZ4_MEMORY_USAGE) + \
|
||||
32) /* static size, for inter-version compatibility */
|
||||
#define LZ4_STREAMSIZE_VOIDP (LZ4_STREAMSIZE / sizeof(void *))
|
||||
|
||||
#define LZ4_STREAMDECODESIZE_U64 \
|
||||
(4 + ((sizeof(void *) == 16) ? 2 : 0) /*AS-400*/)
|
||||
#define LZ4_STREAMDECODESIZE \
|
||||
(LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
|
||||
|
||||
#define LZ4_STREAMHCSIZE 262192
|
||||
#define LZ4_STREAMHCSIZE_SIZET (262192 / sizeof(size_t))
|
||||
|
||||
#define LZ4_STREAMDECODESIZE_U64 4
|
||||
#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * \
|
||||
sizeof(unsigned long long))
|
||||
|
||||
/*
|
||||
* LZ4_stream_t - information structure to track an LZ4 stream.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct LZ4_stream_t_internal LZ4_stream_t_internal;
|
||||
struct LZ4_stream_t_internal {
|
||||
uint32_t hashTable[LZ4_HASH_SIZE_U32];
|
||||
uint32_t currentOffset;
|
||||
uint32_t initCheck;
|
||||
uint32_t tableType;
|
||||
const uint8_t *dictionary;
|
||||
uint8_t *bufferStart;
|
||||
const LZ4_stream_t_internal *dictCtx;
|
||||
uint32_t dictSize;
|
||||
} LZ4_stream_t_internal;
|
||||
};
|
||||
typedef union {
|
||||
unsigned long long table[LZ4_STREAMSIZE_U64];
|
||||
void *table[LZ4_STREAMSIZE_VOIDP];
|
||||
LZ4_stream_t_internal internal_donotuse;
|
||||
} LZ4_stream_t;
|
||||
|
||||
|
|
@ -112,8 +116,8 @@ typedef union {
|
|||
* LZ4_streamHC_t - information structure to track an LZ4HC stream.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int hashTable[LZ4HC_HASHTABLESIZE];
|
||||
unsigned short chainTable[LZ4HC_MAXD];
|
||||
unsigned int hashTable[LZ4HC_HASHTABLESIZE];
|
||||
unsigned short chainTable[LZ4HC_MAXD];
|
||||
/* next block to continue on current prefix */
|
||||
const unsigned char *end;
|
||||
/* All index relative to this position */
|
||||
|
|
@ -121,12 +125,12 @@ typedef struct {
|
|||
/* alternate base for extDict */
|
||||
const unsigned char *dictBase;
|
||||
/* below that point, need extDict */
|
||||
unsigned int dictLimit;
|
||||
unsigned int dictLimit;
|
||||
/* below that point, no more dict */
|
||||
unsigned int lowLimit;
|
||||
unsigned int lowLimit;
|
||||
/* index from which to continue dict update */
|
||||
unsigned int nextToUpdate;
|
||||
unsigned int compressionLevel;
|
||||
unsigned int nextToUpdate;
|
||||
unsigned int compressionLevel;
|
||||
} LZ4HC_CCtx_internal;
|
||||
typedef union {
|
||||
size_t table[LZ4_STREAMHCSIZE_SIZET];
|
||||
|
|
@ -153,8 +157,8 @@ typedef union {
|
|||
/*-************************************************************************
|
||||
* SIZE OF STATE
|
||||
**************************************************************************/
|
||||
#define LZ4_MEM_COMPRESS LZ4_STREAMSIZE
|
||||
#define LZ4HC_MEM_COMPRESS LZ4_STREAMHCSIZE
|
||||
#define LZ4_MEM_COMPRESS LZ4_STREAMSIZE
|
||||
#define LZ4HC_MEM_COMPRESS LZ4_STREAMHCSIZE
|
||||
|
||||
/*-************************************************************************
|
||||
* Compression Functions
|
||||
|
|
@ -195,7 +199,7 @@ static inline int LZ4_compressBound(size_t isize)
|
|||
* (necessarily <= maxOutputSize) or 0 if compression fails
|
||||
*/
|
||||
int LZ4_compress_default(const char *source, char *dest, int inputSize,
|
||||
int maxOutputSize, void *wrkmem);
|
||||
int maxOutputSize, void *wrkmem);
|
||||
|
||||
/**
|
||||
* LZ4_compress_fast() - As LZ4_compress_default providing an acceleration param
|
||||
|
|
@ -219,7 +223,7 @@ int LZ4_compress_default(const char *source, char *dest, int inputSize,
|
|||
* (necessarily <= maxOutputSize) or 0 if compression fails
|
||||
*/
|
||||
int LZ4_compress_fast(const char *source, char *dest, int inputSize,
|
||||
int maxOutputSize, int acceleration, void *wrkmem);
|
||||
int maxOutputSize, int acceleration, void *wrkmem);
|
||||
|
||||
/**
|
||||
* LZ4_compress_destSize() - Compress as much data as possible
|
||||
|
|
@ -243,33 +247,12 @@ int LZ4_compress_fast(const char *source, char *dest, int inputSize,
|
|||
* or 0 if compression fails
|
||||
*/
|
||||
int LZ4_compress_destSize(const char *source, char *dest, int *sourceSizePtr,
|
||||
int targetDestSize, void *wrkmem);
|
||||
int targetDestSize, void *wrkmem);
|
||||
|
||||
/*-************************************************************************
|
||||
* Decompression Functions
|
||||
**************************************************************************/
|
||||
|
||||
/**
|
||||
* LZ4_decompress_fast() - Decompresses data from 'source' into 'dest'
|
||||
* @source: source address of the compressed data
|
||||
* @dest: output buffer address of the uncompressed data
|
||||
* which must be already allocated with 'originalSize' bytes
|
||||
* @originalSize: is the original and therefore uncompressed size
|
||||
*
|
||||
* Decompresses data from 'source' into 'dest'.
|
||||
* This function fully respect memory boundaries for properly formed
|
||||
* compressed data.
|
||||
* It is a bit faster than LZ4_decompress_safe().
|
||||
* 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).
|
||||
*
|
||||
* Return: number of bytes read from the source buffer
|
||||
* or a negative result if decompression fails.
|
||||
*/
|
||||
int LZ4_decompress_fast(const char *source, char *dest, int originalSize);
|
||||
|
||||
/**
|
||||
* LZ4_decompress_safe() - Decompression protected against buffer overflow
|
||||
* @source: source address of the compressed data
|
||||
|
|
@ -290,7 +273,7 @@ int LZ4_decompress_fast(const char *source, char *dest, int originalSize);
|
|||
* or a negative result in case of error
|
||||
*/
|
||||
int LZ4_decompress_safe(const char *source, char *dest, int compressedSize,
|
||||
int maxDecompressedSize);
|
||||
int maxDecompressedSize);
|
||||
|
||||
/**
|
||||
* LZ4_decompress_safe_partial() - Decompress a block of size 'compressedSize'
|
||||
|
|
@ -318,7 +301,8 @@ int LZ4_decompress_safe(const char *source, char *dest, int compressedSize,
|
|||
*
|
||||
*/
|
||||
int LZ4_decompress_safe_partial(const char *source, char *dest,
|
||||
int compressedSize, int targetOutputSize, int maxDecompressedSize);
|
||||
int compressedSize, int targetOutputSize,
|
||||
int maxDecompressedSize);
|
||||
|
||||
/*-************************************************************************
|
||||
* LZ4 HC Compression
|
||||
|
|
@ -344,7 +328,7 @@ int LZ4_decompress_safe_partial(const char *source, char *dest,
|
|||
* Return : the number of bytes written into 'dst' or 0 if compression fails.
|
||||
*/
|
||||
int LZ4_compress_HC(const char *src, char *dst, int srcSize, int dstCapacity,
|
||||
int compressionLevel, void *wrkmem);
|
||||
int compressionLevel, void *wrkmem);
|
||||
|
||||
/**
|
||||
* LZ4_resetStreamHC() - Init an allocated 'LZ4_streamHC_t' structure
|
||||
|
|
@ -373,8 +357,8 @@ void LZ4_resetStreamHC(LZ4_streamHC_t *streamHCPtr, int compressionLevel);
|
|||
*
|
||||
* Return : dictionary size, in bytes (necessarily <= 64 KB)
|
||||
*/
|
||||
int LZ4_loadDictHC(LZ4_streamHC_t *streamHCPtr, const char *dictionary,
|
||||
int dictSize);
|
||||
int LZ4_loadDictHC(LZ4_streamHC_t *streamHCPtr, const char *dictionary,
|
||||
int dictSize);
|
||||
|
||||
/**
|
||||
* LZ4_compress_HC_continue() - Compress 'src' using data from previously
|
||||
|
|
@ -413,7 +397,7 @@ int LZ4_loadDictHC(LZ4_streamHC_t *streamHCPtr, const char *dictionary,
|
|||
* Return: Number of bytes written into buffer 'dst' or 0 if compression fails
|
||||
*/
|
||||
int LZ4_compress_HC_continue(LZ4_streamHC_t *streamHCPtr, const char *src,
|
||||
char *dst, int srcSize, int maxDstSize);
|
||||
char *dst, int srcSize, int maxDstSize);
|
||||
|
||||
/**
|
||||
* LZ4_saveDictHC() - Save static dictionary from LZ4HC_stream
|
||||
|
|
@ -432,7 +416,7 @@ int LZ4_compress_HC_continue(LZ4_streamHC_t *streamHCPtr, const char *src,
|
|||
* or 0 if error.
|
||||
*/
|
||||
int LZ4_saveDictHC(LZ4_streamHC_t *streamHCPtr, char *safeBuffer,
|
||||
int maxDictSize);
|
||||
int maxDictSize);
|
||||
|
||||
/*-*********************************************
|
||||
* Streaming Compression Functions
|
||||
|
|
@ -462,8 +446,7 @@ void LZ4_resetStream(LZ4_stream_t *LZ4_stream);
|
|||
*
|
||||
* Return : dictionary size, in bytes (necessarily <= 64 KB)
|
||||
*/
|
||||
int LZ4_loadDict(LZ4_stream_t *streamPtr, const char *dictionary,
|
||||
int dictSize);
|
||||
int LZ4_loadDict(LZ4_stream_t *streamPtr, const char *dictionary, int dictSize);
|
||||
|
||||
/**
|
||||
* LZ4_saveDict() - Save static dictionary from LZ4_stream
|
||||
|
|
@ -505,7 +488,8 @@ int LZ4_saveDict(LZ4_stream_t *streamPtr, char *safeBuffer, int dictSize);
|
|||
* Return: Number of bytes written into buffer 'dst' or 0 if compression fails
|
||||
*/
|
||||
int LZ4_compress_fast_continue(LZ4_stream_t *streamPtr, const char *src,
|
||||
char *dst, int srcSize, int maxDstSize, int acceleration);
|
||||
char *dst, int srcSize, int maxDstSize,
|
||||
int acceleration);
|
||||
|
||||
/**
|
||||
* LZ4_setStreamDecode() - Instruct where to find dictionary
|
||||
|
|
@ -519,7 +503,7 @@ int LZ4_compress_fast_continue(LZ4_stream_t *streamPtr, const char *src,
|
|||
* Return: 1 if OK, 0 if error
|
||||
*/
|
||||
int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode,
|
||||
const char *dictionary, int dictSize);
|
||||
const char *dictionary, int dictSize);
|
||||
|
||||
/**
|
||||
* LZ4_decompress_fast_continue() - Decompress blocks in streaming mode
|
||||
|
|
@ -558,8 +542,32 @@ int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode,
|
|||
* or a negative result in case of error
|
||||
*/
|
||||
int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode,
|
||||
const char *source, char *dest, int compressedSize,
|
||||
int maxDecompressedSize);
|
||||
const char *source, char *dest,
|
||||
int compressedSize, int maxDecompressedSize);
|
||||
|
||||
/* \/ Following methods are disabled because they are deprecated \/ */
|
||||
|
||||
/**
|
||||
* LZ4_decompress_fast() - Decompresses data from 'source' into 'dest'
|
||||
* @source: source address of the compressed data
|
||||
* @dest: output buffer address of the uncompressed data
|
||||
* which must be already allocated with 'originalSize' bytes
|
||||
* @originalSize: is the original and therefore uncompressed size
|
||||
*
|
||||
* Decompresses data from 'source' into 'dest'.
|
||||
* This function fully respect memory boundaries for properly formed
|
||||
* compressed data.
|
||||
* It is a bit faster than LZ4_decompress_safe().
|
||||
* 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).
|
||||
*
|
||||
* Return: number of bytes read from the source buffer
|
||||
* or a negative result if decompression fails.
|
||||
*/
|
||||
|
||||
//int LZ4_decompress_fast(const char *source, char *dest, int originalSize);
|
||||
|
||||
/**
|
||||
* LZ4_decompress_fast_continue() - Decompress blocks in streaming mode
|
||||
|
|
@ -596,8 +604,9 @@ int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode,
|
|||
* (necessarily <= maxDecompressedSize)
|
||||
* or a negative result in case of error
|
||||
*/
|
||||
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_decompress_safe_usingDict() - Same as LZ4_setStreamDecode()
|
||||
|
|
@ -619,9 +628,9 @@ int LZ4_decompress_fast_continue(LZ4_streamDecode_t *LZ4_streamDecode,
|
|||
* (necessarily <= maxDecompressedSize)
|
||||
* or a negative result in case of error
|
||||
*/
|
||||
int LZ4_decompress_safe_usingDict(const char *source, char *dest,
|
||||
int compressedSize, int maxDecompressedSize, const char *dictStart,
|
||||
int dictSize);
|
||||
//int LZ4_decompress_safe_usingDict(const char *source, char *dest,
|
||||
// int compressedSize, int maxDecompressedSize, const char *dictStart,
|
||||
// int dictSize);
|
||||
|
||||
/**
|
||||
* LZ4_decompress_fast_usingDict() - Same as LZ4_setStreamDecode()
|
||||
|
|
@ -642,7 +651,7 @@ int LZ4_decompress_safe_usingDict(const char *source, char *dest,
|
|||
* (necessarily <= maxDecompressedSize)
|
||||
* or a negative result in case of error
|
||||
*/
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
|
||||
#include <asm/unaligned.h>
|
||||
#include <linux/string.h> /* memset, memcpy */
|
||||
#include <linux/string.h> /* memset, memcpy */
|
||||
|
||||
#define FORCE_INLINE __always_inline
|
||||
|
||||
|
|
@ -45,10 +45,10 @@
|
|||
**************************************/
|
||||
#include <linux/types.h>
|
||||
|
||||
typedef uint8_t BYTE;
|
||||
typedef uint8_t BYTE;
|
||||
typedef uint16_t U16;
|
||||
typedef uint32_t U32;
|
||||
typedef int32_t S32;
|
||||
typedef int32_t S32;
|
||||
typedef uint64_t U64;
|
||||
typedef uintptr_t uptrval;
|
||||
|
||||
|
|
@ -67,22 +67,28 @@ typedef uintptr_t uptrval;
|
|||
#define LZ4_LITTLE_ENDIAN 0
|
||||
#endif
|
||||
|
||||
#define DEBUGLOG(l, ...) \
|
||||
{ \
|
||||
} /* disabled */
|
||||
|
||||
#ifndef assert
|
||||
#define assert(condition) ((void)0)
|
||||
#endif
|
||||
|
||||
/*-************************************
|
||||
* Constants
|
||||
**************************************/
|
||||
#define LZ4_DISTANCE_ABSOLUTE_MAX 65535
|
||||
#define LZ4_DISTANCE_MAX 65535
|
||||
#define MINMATCH 4
|
||||
|
||||
#define WILDCOPYLENGTH 8
|
||||
#define LASTLITERALS 5
|
||||
#define MFLIMIT (WILDCOPYLENGTH + MINMATCH)
|
||||
/*
|
||||
* ensure it's possible to write 2 x wildcopyLength
|
||||
* without overflowing output buffer
|
||||
*/
|
||||
#define MATCH_SAFEGUARD_DISTANCE ((2 * WILDCOPYLENGTH) - MINMATCH)
|
||||
|
||||
/* Increase this value ==> compression run slower on incompressible data */
|
||||
#define LZ4_SKIPTRIGGER 6
|
||||
#define LASTLITERALS 5 /* see ../doc/lz4_Block_format.md#parsing-restrictions */
|
||||
#define MFLIMIT 12 /* see ../doc/lz4_Block_format.md#parsing-restrictions */
|
||||
#define MATCH_SAFEGUARD_DISTANCE \
|
||||
((2 * WILDCOPYLENGTH) - \
|
||||
MINMATCH) /* ensure it's possible to write 2 x wildcopyLength without overflowing output buffer */
|
||||
#define FASTLOOP_SAFE_DISTANCE 64
|
||||
|
||||
#define HASH_UNIT sizeof(size_t)
|
||||
|
||||
|
|
@ -90,12 +96,16 @@ typedef uintptr_t uptrval;
|
|||
#define MB (1 << 20)
|
||||
#define GB (1U << 30)
|
||||
|
||||
#define MAXD_LOG 16
|
||||
#define MAX_DISTANCE ((1 << MAXD_LOG) - 1)
|
||||
#if defined(__x86_64__)
|
||||
typedef U64 reg_t; /* 64-bits in x32 mode */
|
||||
#else
|
||||
typedef size_t reg_t; /* 32-bits in x32 mode */
|
||||
#endif
|
||||
|
||||
#define STEPSIZE sizeof(size_t)
|
||||
|
||||
#define ML_BITS 4
|
||||
#define ML_MASK ((1U << ML_BITS) - 1)
|
||||
#define ML_BITS 4
|
||||
#define ML_MASK ((1U << ML_BITS) - 1)
|
||||
#define RUN_BITS (8 - ML_BITS)
|
||||
#define RUN_MASK ((1U << RUN_BITS) - 1)
|
||||
|
||||
|
|
@ -146,41 +156,24 @@ static FORCE_INLINE void LZ4_writeLE16(void *memPtr, U16 value)
|
|||
* environments. This is needed when decompressing the Linux Kernel, for example.
|
||||
*/
|
||||
#define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
|
||||
#define LZ4_memmove(dst, src, size) __builtin_memmove(dst, src, size)
|
||||
|
||||
static FORCE_INLINE void LZ4_copy8(void *dst, const void *src)
|
||||
{
|
||||
#if LZ4_ARCH64
|
||||
U64 a = get_unaligned((const U64 *)src);
|
||||
|
||||
put_unaligned(a, (U64 *)dst);
|
||||
#else
|
||||
U32 a = get_unaligned((const U32 *)src);
|
||||
U32 b = get_unaligned((const U32 *)src + 1);
|
||||
|
||||
put_unaligned(a, (U32 *)dst);
|
||||
put_unaligned(b, (U32 *)dst + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* customized variant of memcpy,
|
||||
* which can overwrite up to 7 bytes beyond dstEnd
|
||||
*/
|
||||
static FORCE_INLINE void LZ4_wildCopy(void *dstPtr,
|
||||
const void *srcPtr, void *dstEnd)
|
||||
/* customized variant of memcpy, which can overwrite up to 8 bytes beyond dstEnd */
|
||||
static FORCE_INLINE void LZ4_wildCopy8(void *dstPtr, const void *srcPtr,
|
||||
void *dstEnd)
|
||||
{
|
||||
BYTE *d = (BYTE *)dstPtr;
|
||||
const BYTE *s = (const BYTE *)srcPtr;
|
||||
BYTE *const e = (BYTE *)dstEnd;
|
||||
|
||||
do {
|
||||
LZ4_copy8(d, s);
|
||||
LZ4_memcpy(d, s, 8);
|
||||
d += 8;
|
||||
s += 8;
|
||||
} while (d < e);
|
||||
}
|
||||
|
||||
static FORCE_INLINE unsigned int LZ4_NbCommonBytes(register size_t val)
|
||||
static FORCE_INLINE unsigned int LZ4_NbCommonBytes(reg_t val)
|
||||
{
|
||||
#if LZ4_LITTLE_ENDIAN
|
||||
return __ffs(val) >> 3;
|
||||
|
|
@ -189,56 +182,64 @@ static FORCE_INLINE unsigned int LZ4_NbCommonBytes(register size_t val)
|
|||
#endif
|
||||
}
|
||||
|
||||
static FORCE_INLINE unsigned int LZ4_count(
|
||||
const BYTE *pIn,
|
||||
const BYTE *pMatch,
|
||||
const BYTE *pInLimit)
|
||||
static FORCE_INLINE unsigned int LZ4_count(const BYTE *pIn, const BYTE *pMatch,
|
||||
const BYTE *pInLimit)
|
||||
{
|
||||
const BYTE *const pStart = pIn;
|
||||
|
||||
while (likely(pIn < pInLimit - (STEPSIZE - 1))) {
|
||||
size_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
|
||||
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);
|
||||
if (!diff) {
|
||||
pIn += STEPSIZE;
|
||||
pMatch += STEPSIZE;
|
||||
continue;
|
||||
}
|
||||
|
||||
pIn += LZ4_NbCommonBytes(diff);
|
||||
|
||||
return (unsigned int)(pIn - pStart);
|
||||
return (unsigned)(pIn - pStart);
|
||||
}
|
||||
|
||||
#if LZ4_ARCH64
|
||||
if ((pIn < (pInLimit - 3))
|
||||
&& (LZ4_read32(pMatch) == LZ4_read32(pIn))) {
|
||||
if ((STEPSIZE == 8) && (pIn < (pInLimit - 3)) &&
|
||||
(LZ4_read32(pMatch) == LZ4_read32(pIn))) {
|
||||
pIn += 4;
|
||||
pMatch += 4;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((pIn < (pInLimit - 1))
|
||||
&& (LZ4_read16(pMatch) == LZ4_read16(pIn))) {
|
||||
if ((pIn < (pInLimit - 1)) && (LZ4_read16(pMatch) == LZ4_read16(pIn))) {
|
||||
pIn += 2;
|
||||
pMatch += 2;
|
||||
}
|
||||
|
||||
if ((pIn < pInLimit) && (*pMatch == *pIn))
|
||||
pIn++;
|
||||
|
||||
return (unsigned int)(pIn - pStart);
|
||||
return (unsigned)(pIn - pStart);
|
||||
}
|
||||
|
||||
typedef enum { noLimit = 0, limitedOutput = 1 } limitedOutput_directive;
|
||||
typedef enum { byPtr, byU32, byU16 } tableType_t;
|
||||
typedef enum {
|
||||
notLimited = 0,
|
||||
limitedOutput = 1,
|
||||
fillOutput = 2
|
||||
} limitedOutput_directive;
|
||||
typedef enum { clearedTable = 0, byPtr, byU32, byU16 } tableType_t;
|
||||
|
||||
typedef enum { noDict = 0, withPrefix64k, usingExtDict } dict_directive;
|
||||
typedef enum {
|
||||
noDict = 0,
|
||||
withPrefix64k,
|
||||
usingExtDict,
|
||||
usingDictCtx
|
||||
} dict_directive;
|
||||
typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive;
|
||||
|
||||
typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive;
|
||||
typedef enum { decode_full_block = 0, partial_decode = 1 } earlyEnd_directive;
|
||||
|
||||
#define LZ4_STATIC_ASSERT(c) BUILD_BUG_ON(!(c))
|
||||
#define LZ4_STATIC_ASSERT(c) BUILD_BUG_ON(!(c))
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue