Merge branch 'master' of github.com:steveicarus/iverilog

This commit is contained in:
Stephen Williams 2014-10-02 14:10:10 -07:00
commit b4119de9b1
3 changed files with 36 additions and 42 deletions

View File

@ -232,13 +232,13 @@ unusedFunction:fastlz.c:150
// lz4.c from GTKWave
// These functions are not used by Icarus
// LZ4_compress_continue()
unusedFunction:lz4.c:817
unusedFunction:lz4.c:818
// LZ4_compress_forceExtDict()
unusedFunction:lz4.c:829
unusedFunction:lz4.c:830
// LZ4_compress_limitedOutput()
unusedFunction:lz4.c:664
unusedFunction:lz4.c:665
// LZ4_compress_limitedOutput_continue()
unusedFunction:lz4.c:822
unusedFunction:lz4.c:823
// LZ4_compress_limitedOutput_withState()
unusedFunction:lz4.c:1228
// LZ4_compress_withState()
@ -246,7 +246,7 @@ unusedFunction:lz4.c:1217
// LZ4_create()
unusedFunction:lz4.c:1197
// LZ4_createStream()
unusedFunction:lz4.c:699
unusedFunction:lz4.c:700
// LZ4_createStreamDecode()
unusedFunction:lz4.c:1073
// LZ4_decompress_fast_continue()
@ -262,11 +262,11 @@ unusedFunction:lz4.c:1156
// LZ4_decompress_safe_withPrefix64k()
unusedFunction:lz4.c:1241
// LZ4_freeStream()
unusedFunction:lz4.c:706
unusedFunction:lz4.c:707
// LZ4_freeStreamDecode()
unusedFunction:lz4.c:1080
// LZ4_loadDict()
unusedFunction:lz4.c:713
unusedFunction:lz4.c:714
// LZ4_resetStreamState()
unusedFunction:lz4.c:1190
// LZ4_setStreamDecode()
@ -282,7 +282,7 @@ unusedFunction:lz4.c:1176
// LZ4_uncompress_unknownOutputSize()
unusedFunction:lz4.c:1177
// LZ4_versionNumber()
unusedFunction:lz4.c:370
unusedFunction:lz4.c:371
// The routines in sys_random.c are exact copies from IEEE1364-2005 and
// they have scope warnings that we need to ignore.

View File

@ -47,6 +47,7 @@
**************************************/
/* 32 or 64 bits ? */
#if (defined(__x86_64__) || defined(_M_X64) || defined(_WIN64) \
|| defined(__64BIT__) || defined(__mips64) \
|| defined(__powerpc64__) || defined(__powerpc64le__) \
|| defined(__ppc64__) || defined(__ppc64le__) \
|| defined(__PPC64__) || defined(__PPC64LE__) \
@ -899,8 +900,8 @@ FORCE_INLINE int LZ4_decompress_generic(
const BYTE* const lowLimit = (const BYTE*)dest - dictSize;
const BYTE* const dictEnd = (const BYTE*)dictStart + dictSize;
const size_t dec32table[] = {4-0, 4-3, 4-2, 4-3, 4-0, 4-0, 4-0, 4-0}; /* note : static reduces speed for LZ4_decompress_safe() on GCC64 */
static const size_t dec64table[] = {0, 0, 0, (size_t)-1, 0, 1, 2, 3};
const size_t dec32table[] = {4, 1, 2, 1, 4, 4, 4, 4};
const size_t dec64table[] = {0, 0, 0, (size_t)-1, 0, 1, 2, 3};
const int safeDecode = (endOnInput==endOnInputSize);
const int checkOffset = ((safeDecode) && (dictSize < (int)(64 KB)));
@ -971,24 +972,25 @@ FORCE_INLINE int LZ4_decompress_generic(
} while (s==255);
if ((safeDecode) && LZ4_32BITS && unlikely((size_t)(op+length)<(size_t)op)) goto _output_error; /* overflow detection */
}
length += MINMATCH;
/* check external dictionary */
if ((dict==usingExtDict) && (ref < (BYTE* const)dest))
{
if (unlikely(op+length+MINMATCH > oend-LASTLITERALS)) goto _output_error;
if (unlikely(op+length > oend-LASTLITERALS)) goto _output_error;
if (length+MINMATCH <= (size_t)(dest-(char*)ref))
if (length <= (size_t)(dest-(char*)ref))
{
ref = dictEnd - (dest-(char*)ref);
memcpy(op, ref, length+MINMATCH);
op += length+MINMATCH;
memcpy(op, ref, length);
op += length;
}
else
{
size_t copySize = (size_t)(dest-(char*)ref);
memcpy(op, dictEnd - copySize, copySize);
op += copySize;
copySize = length+MINMATCH - copySize;
copySize = length - copySize;
if (copySize > (size_t)((char*)op-dest)) /* overlap */
{
BYTE* const endOfMatch = op + copySize;
@ -1005,28 +1007,26 @@ FORCE_INLINE int LZ4_decompress_generic(
}
/* copy repeated sequence */
cpy = op + length;
if (unlikely((op-ref)<(int)STEPSIZE))
{
const size_t dec64 = dec64table[LZ4_32BITS ? 0 : op-ref];
const size_t dec64 = dec64table[op-ref];
op[0] = ref[0];
op[1] = ref[1];
op[2] = ref[2];
op[3] = ref[3];
ref += dec32table[op-ref];
A32(op+4) = A32(ref);
op += STEPSIZE; ref -= dec64;
} else { LZ4_COPYSTEP(op,ref); }
cpy = op + length - (STEPSIZE-4);
op += 8; ref -= dec64;
} else { LZ4_COPY8(op,ref); }
if (unlikely(cpy>oend-COPYLENGTH-(STEPSIZE-4)))
if (unlikely(cpy>oend-12))
{
if (cpy > oend-LASTLITERALS) goto _output_error; /* Error : last 5 bytes must be literals */
if (op<oend-COPYLENGTH) LZ4_WILDCOPY(op, ref, (oend-COPYLENGTH));
while(op<cpy) *op++=*ref++;
op=cpy;
continue;
}
LZ4_WILDCOPY(op, ref, cpy);
else LZ4_WILDCOPY(op, ref, cpy);
op=cpy; /* correction */
}

View File

@ -64,12 +64,12 @@ int LZ4_versionNumber (void);
Simple Functions
**************************************/
int LZ4_compress (const char* source, char* dest, int inputSize);
int LZ4_compress (const char* source, char* dest, int sourceSize);
int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize);
/*
LZ4_compress() :
Compresses 'inputSize' bytes from 'source' into 'dest'.
Compresses 'sourceSize' bytes from 'source' into 'dest'.
Destination buffer must be already allocated,
and must be sized to handle worst cases situations (input data not compressible)
Worst case size evaluation is provided by function LZ4_compressBound()
@ -83,16 +83,9 @@ LZ4_decompress_safe() :
return : the number of bytes decompressed into the destination buffer (necessarily <= maxDecompressedSize)
If the destination buffer is not large enough, decoding will stop and output an error code (<0).
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 :
it never writes outside of output buffer, and never reads outside of input buffer.
Therefore, it is protected against malicious data packets.
*/
/*
Note :
Should you prefer to explicitly allocate compression-table memory using your own allocation method,
use the streaming functions provided below, simply reset the memory area between each call to LZ4_compress_continue()
This function is protected against buffer overflow exploits,
and never writes outside of output buffer, nor reads outside of input buffer.
It is also protected against malicious data packets.
*/
@ -104,9 +97,9 @@ Note :
/*
LZ4_compressBound() :
Provides the maximum size that LZ4 may output in a "worst case" scenario (input data not compressible)
primarily useful for memory allocation of output buffer.
macro is also provided when result needs to be evaluated at compilation (such as stack memory allocation).
Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
This function is primarily useful for memory allocation purposes (output buffer size).
Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example).
isize : is the input size. Max supported value is LZ4_MAX_INPUT_SIZE
return : maximum output size in a "worst case" scenario
@ -117,16 +110,17 @@ int LZ4_compressBound(int isize);
/*
LZ4_compress_limitedOutput() :
Compress 'inputSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.
Compress 'sourceSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.
If it cannot achieve it, compression will stop, and result of the function will be zero.
This saves time and memory on detecting non-compressible (or barely compressible) data.
This function never writes outside of provided output buffer.
inputSize : Max supported value is LZ4_MAX_INPUT_VALUE
sourceSize : Max supported value is LZ4_MAX_INPUT_VALUE
maxOutputSize : is the size of the destination buffer (which must be already allocated)
return : the number of bytes written in buffer 'dest'
or 0 if the compression fails
or 0 if compression fails
*/
int LZ4_compress_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize);
/*