Update lz4 files to the latest from GTKWave

This commit is contained in:
Cary R 2014-10-13 09:42:53 -07:00
parent 712f394224
commit da4200c5bd
3 changed files with 82 additions and 59 deletions

View File

@ -232,57 +232,59 @@ unusedFunction:fastlz.c:150
// lz4.c from GTKWave
// These functions are not used by Icarus
// LZ4_compress_continue()
unusedFunction:lz4.c:818
unusedFunction:lz4.c:819
// LZ4_compress_forceExtDict()
unusedFunction:lz4.c:830
unusedFunction:lz4.c:831
// LZ4_compress_limitedOutput()
unusedFunction:lz4.c:665
unusedFunction:lz4.c:666
// LZ4_compress_limitedOutput_continue()
unusedFunction:lz4.c:823
unusedFunction:lz4.c:824
// LZ4_compress_limitedOutput_withState()
unusedFunction:lz4.c:1228
// LZ4_compress_withState()
unusedFunction:lz4.c:1217
// LZ4_create()
unusedFunction:lz4.c:1197
// LZ4_createStream()
unusedFunction:lz4.c:700
// LZ4_createStreamDecode()
unusedFunction:lz4.c:1073
// LZ4_decompress_fast_continue()
unusedFunction:lz4.c:1128
// LZ4_decompress_fast_usingDict()
unusedFunction:lz4.c:1161
// LZ4_decompress_fast_withPrefix64k()
unusedFunction:lz4.c:1246
// LZ4_decompress_safe_continue()
unusedFunction:lz4.c:1108
// LZ4_decompress_safe_usingDict()
unusedFunction:lz4.c:1156
// LZ4_decompress_safe_withPrefix64k()
unusedFunction:lz4.c:1241
// LZ4_freeStream()
unusedFunction:lz4.c:707
// LZ4_freeStreamDecode()
unusedFunction:lz4.c:1080
// LZ4_loadDict()
unusedFunction:lz4.c:714
// LZ4_resetStreamState()
unusedFunction:lz4.c:1190
// LZ4_setStreamDecode()
unusedFunction:lz4.c:1093
// LZ4_sizeofState()
// LZ4_compress_withState()
unusedFunction:lz4.c:1235
// LZ4_create()
unusedFunction:lz4.c:1215
// LZ4_createStream()
unusedFunction:lz4.c:701
// LZ4_createStreamDecode()
unusedFunction:lz4.c:1074
// LZ4_decompress_fast_continue()
unusedFunction:lz4.c:1129
// LZ4_decompress_fast_usingDict()
unusedFunction:lz4.c:1172
// LZ4_decompress_fast_withPrefix64k()
unusedFunction:lz4.c:1264
// LZ4_decompress_safe_continue()
unusedFunction:lz4.c:1109
// LZ4_decompress_safe_forceExtDict()
unusedFunction:lz4.c:1179
// LZ4_decompress_safe_usingDict()
unusedFunction:lz4.c:1166
// LZ4_decompress_safe_withPrefix64k()
unusedFunction:lz4.c:1259
// LZ4_freeStream()
unusedFunction:lz4.c:708
// LZ4_freeStreamDecode()
unusedFunction:lz4.c:1081
// LZ4_loadDict()
unusedFunction:lz4.c:715
// LZ4_resetStreamState()
unusedFunction:lz4.c:1208
// LZ4_setStreamDecode()
unusedFunction:lz4.c:1094
// LZ4_sizeofState()
unusedFunction:lz4.c:1233
// LZ4_sizeofStreamState()
unusedFunction:lz4.c:1182
unusedFunction:lz4.c:1200
// LZ4_slideInputBuffer()
unusedFunction:lz4.c:1204
unusedFunction:lz4.c:1222
// LZ4_uncompress()
unusedFunction:lz4.c:1176
unusedFunction:lz4.c:1194
// LZ4_uncompress_unknownOutputSize()
unusedFunction:lz4.c:1177
unusedFunction:lz4.c:1195
// LZ4_versionNumber()
unusedFunction:lz4.c:371
unusedFunction:lz4.c:372
// The routines in sys_random.c are exact copies from IEEE1364-2005 and
// they have scope warnings that we need to ignore.

View File

@ -51,7 +51,8 @@
|| defined(__powerpc64__) || defined(__powerpc64le__) \
|| defined(__ppc64__) || defined(__ppc64le__) \
|| defined(__PPC64__) || defined(__PPC64LE__) \
|| defined(__ia64) || defined(__itanium__) || defined(_M_IA64) ) /* Detects 64 bits mode */
|| defined(__ia64) || defined(__itanium__) || defined(_M_IA64) \
|| defined(__s390x__) ) /* Detects 64 bits mode */
# define LZ4_ARCH64 1
#else
# define LZ4_ARCH64 0
@ -855,12 +856,12 @@ int LZ4_saveDict (LZ4_stream_t* LZ4_dict, char* safeBuffer, int dictSize)
if ((U32)dictSize > 64 KB) dictSize = 64 KB; /* useless to define a dictionary > 64 KB */
if ((U32)dictSize > dict->dictSize) dictSize = dict->dictSize;
memcpy(safeBuffer, previousDictEnd - dictSize, dictSize);
memmove(safeBuffer, previousDictEnd - dictSize, dictSize);
dict->dictionary = (const BYTE*)safeBuffer;
dict->dictSize = (U32)dictSize;
return 1;
return dictSize;
}
@ -870,9 +871,9 @@ int LZ4_saveDict (LZ4_stream_t* LZ4_dict, char* safeBuffer, int dictSize)
****************************/
/*
* This generic decompression function cover all use cases.
* It shall be instanciated several times, using different sets of directives
* It shall be instantiated several times, using different sets of directives
* Note that it is essential this generic function is really inlined,
* in order to remove useless branches during compilation optimisation.
* in order to remove useless branches during compilation optimization.
*/
FORCE_INLINE int LZ4_decompress_generic(
const char* source,
@ -1153,14 +1154,31 @@ Advanced decoding functions :
the dictionary must be explicitly provided within parameters
*/
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)
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, noDict, NULL, 64 KB);
if ((dictStart+dictSize == dest) && (dictSize >= (int)(64 KB - 1)))
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, withPrefix64k, NULL, 64 KB);
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, usingExtDict, dictStart, dictSize);
}
int LZ4_decompress_safe_usingDict(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, dictStart, dictSize);
//return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, usingExtDict, dictStart, dictSize);
return LZ4_decompress_usingDict_generic(source, dest, compressedSize, maxOutputSize, 1, dictStart, dictSize);
}
int LZ4_decompress_fast_usingDict(const char* source, char* dest, int originalSize, const char* dictStart, int dictSize)
{
return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, usingExtDict, dictStart, dictSize);
//return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, usingExtDict, dictStart, dictSize);
return LZ4_decompress_usingDict_generic(source, dest, 0, originalSize, 0, dictStart, dictSize);
}
/* debug function */
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, dictStart, dictSize);
}

View File

@ -37,13 +37,18 @@
extern "C" {
#endif
/*
* lz4.h provides raw compression format functions, for optimal performance and integration into programs.
* If you need to generate data using an inter-operable format (respecting the framing specification),
* please use lz4frame.h instead.
*/
/**************************************
Version
**************************************/
#define LZ4_VERSION_MAJOR 1 /* for major interface/format changes */
#define LZ4_VERSION_MINOR 3 /* for minor interface/format changes */
#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)
int LZ4_versionNumber (void);
@ -142,7 +147,7 @@ LZ4_decompress_fast() :
Destination buffer must be already allocated. Its size must be a minimum of 'originalSize' bytes.
note : 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 intentionnally 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).
*/
int LZ4_decompress_fast (const char* source, char* dest, int originalSize);
@ -178,10 +183,9 @@ typedef struct { unsigned int table[LZ4_STREAMSIZE_U32]; } LZ4_stream_t;
/*
* LZ4_resetStream
* Use this function to init a newly allocated LZ4_stream_t structure
* You can also reset an existing LZ4_stream_t structure
* Use this function to init an allocated LZ4_stream_t structure
*/
void LZ4_resetStream (LZ4_stream_t* LZ4_stream);
void LZ4_resetStream (LZ4_stream_t* LZ4_streamPtr);
/*
* If you prefer dynamic allocation methods,
@ -217,10 +221,10 @@ int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_stream, const char* s
/*
* LZ4_saveDict
* If previously compressed data block is not guaranteed to remain available at its memory location
* save it into a safe place (char* safeBuffer)
* save it into a safer place (char* safeBuffer)
* Note : you don't need to call LZ4_loadDict() afterwards,
* dictionary is immediately usable, you can therefore call again LZ4_compress_continue()
* Return : 1 if OK, 0 if error
* Return : dictionary size in bytes, or 0 if error
* Note : any dictSize > 64 KB will be interpreted as 64KB.
*/
int LZ4_saveDict (LZ4_stream_t* LZ4_stream, char* safeBuffer, int dictSize);
@ -262,9 +266,9 @@ int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
These decoding functions allow decompression of multiple blocks in "streaming" mode.
Previously decoded blocks must still be available at the memory position where they were decoded.
If it's not possible, save the relevant part of decoded data into a safe buffer,
and indicate where its new address using LZ4_setDictDecode()
and indicate where its new address using LZ4_setStreamDecode()
*/
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 maxDecompressedSize);
int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize);
@ -273,10 +277,9 @@ Advanced decoding functions :
*_usingDict() :
These decoding functions work the same as
a combination of LZ4_setDictDecode() followed by LZ4_decompress_x_continue()
all together into a single function call.
It doesn't use nor update an LZ4_streamDecode_t structure.
They don't use nor update an LZ4_streamDecode_t structure.
*/
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 maxDecompressedSize, const char* dictStart, int dictSize);
int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize);