Merge branch 'mingw' into adapt

This commit is contained in:
Yann Collet 2018-09-21 16:00:46 -07:00
commit c484345a82
4 changed files with 46 additions and 34 deletions

View File

@ -141,16 +141,16 @@ size_t ZSTD_compressBlock_doubleFast_generic(
goto _match_stored; goto _match_stored;
} }
/* check prefix long match */ if (matchIndexL > prefixLowestIndex) {
if ( (matchIndexL > prefixLowestIndex) && (MEM_read64(matchLong) == MEM_read64(ip)) ) { /* check prefix long match */
mLength = ZSTD_count(ip+8, matchLong+8, iend) + 8; if (MEM_read64(matchLong) == MEM_read64(ip)) {
offset = (U32)(ip-matchLong); mLength = ZSTD_count(ip+8, matchLong+8, iend) + 8;
while (((ip>anchor) & (matchLong>prefixLowest)) && (ip[-1] == matchLong[-1])) { ip--; matchLong--; mLength++; } /* catch up */ offset = (U32)(ip-matchLong);
goto _match_found; while (((ip>anchor) & (matchLong>prefixLowest)) && (ip[-1] == matchLong[-1])) { ip--; matchLong--; mLength++; } /* catch up */
} goto _match_found;
}
/* check dictMatchState long match */ } else if (dictMode == ZSTD_dictMatchState) {
if (dictMode == ZSTD_dictMatchState) { /* check dictMatchState long match */
U32 const dictMatchIndexL = dictHashLong[h2]; U32 const dictMatchIndexL = dictHashLong[h2];
const BYTE* dictMatchL = dictBase + dictMatchIndexL; const BYTE* dictMatchL = dictBase + dictMatchIndexL;
assert(dictMatchL < dictEnd); assert(dictMatchL < dictEnd);
@ -163,13 +163,13 @@ size_t ZSTD_compressBlock_doubleFast_generic(
} }
} }
/* check prefix short match */ if (matchIndexS > prefixLowestIndex) {
if ( (matchIndexS > prefixLowestIndex) && (MEM_read32(match) == MEM_read32(ip)) ) { /* check prefix short match */
goto _search_next_long; if (MEM_read32(match) == MEM_read32(ip)) {
} goto _search_next_long;
}
/* check dictMatchState short match */ } else if (dictMode == ZSTD_dictMatchState) {
if (dictMode == ZSTD_dictMatchState) { /* check dictMatchState short match */
U32 const dictMatchIndexS = dictHashSmall[h]; U32 const dictMatchIndexS = dictHashSmall[h];
match = dictBase + dictMatchIndexS; match = dictBase + dictMatchIndexS;
matchIndexS = dictMatchIndexS + dictIndexDelta; matchIndexS = dictMatchIndexS + dictIndexDelta;
@ -191,16 +191,16 @@ _search_next_long:
hashLong[hl3] = current + 1; hashLong[hl3] = current + 1;
/* check prefix long +1 match */ /* check prefix long +1 match */
if ( (matchIndexL3 > prefixLowestIndex) && (MEM_read64(matchL3) == MEM_read64(ip+1)) ) { if (matchIndexL3 > prefixLowestIndex) {
mLength = ZSTD_count(ip+9, matchL3+8, iend) + 8; if (MEM_read64(matchL3) == MEM_read64(ip+1)) {
ip++; mLength = ZSTD_count(ip+9, matchL3+8, iend) + 8;
offset = (U32)(ip-matchL3); ip++;
while (((ip>anchor) & (matchL3>prefixLowest)) && (ip[-1] == matchL3[-1])) { ip--; matchL3--; mLength++; } /* catch up */ offset = (U32)(ip-matchL3);
goto _match_found; while (((ip>anchor) & (matchL3>prefixLowest)) && (ip[-1] == matchL3[-1])) { ip--; matchL3--; mLength++; } /* catch up */
} goto _match_found;
}
/* check dict long +1 match */ } else if (dictMode == ZSTD_dictMatchState) {
if (dictMode == ZSTD_dictMatchState) { /* check dict long +1 match */
U32 const dictMatchIndexL3 = dictHashLong[hl3]; U32 const dictMatchIndexL3 = dictHashLong[hl3];
const BYTE* dictMatchL3 = dictBase + dictMatchIndexL3; const BYTE* dictMatchL3 = dictBase + dictMatchIndexL3;
assert(dictMatchL3 < dictEnd); assert(dictMatchL3 < dictEnd);

View File

@ -124,8 +124,7 @@ size_t ZSTD_compressBlock_fast_generic(
mLength = ZSTD_count(ip+1+4, ip+1+4-offset_1, iend) + 4; mLength = ZSTD_count(ip+1+4, ip+1+4-offset_1, iend) + 4;
ip++; ip++;
ZSTD_storeSeq(seqStore, ip-anchor, anchor, 0, mLength-MINMATCH); ZSTD_storeSeq(seqStore, ip-anchor, anchor, 0, mLength-MINMATCH);
} else if ( (matchIndex <= prefixStartIndex) } else if ( (matchIndex <= prefixStartIndex) ) {
|| (MEM_read32(match) != MEM_read32(ip)) ) {
if (dictMode == ZSTD_dictMatchState) { if (dictMode == ZSTD_dictMatchState) {
U32 const dictMatchIndex = dictHashTable[h]; U32 const dictMatchIndex = dictHashTable[h];
const BYTE* dictMatch = dictBase + dictMatchIndex; const BYTE* dictMatch = dictBase + dictMatchIndex;
@ -151,6 +150,11 @@ size_t ZSTD_compressBlock_fast_generic(
ip += ((ip-anchor) >> kSearchStrength) + stepSize; ip += ((ip-anchor) >> kSearchStrength) + stepSize;
continue; continue;
} }
} else if (MEM_read32(match) != MEM_read32(ip)) {
/* it's not a match, and we're not going to check the dictionary */
assert(stepSize >= 1);
ip += ((ip-anchor) >> kSearchStrength) + stepSize;
continue;
} else { } else {
/* found a regular match */ /* found a regular match */
U32 const offset = (U32)(ip-match); U32 const offset = (U32)(ip-match);

View File

@ -20,6 +20,9 @@
# define _POSIX_SOURCE 1 /* disable %llu warnings with MinGW on Windows */ # define _POSIX_SOURCE 1 /* disable %llu warnings with MinGW on Windows */
#endif #endif
#if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
# define BACKTRACES_ENABLE 1
#endif
/*-************************************* /*-*************************************
* Includes * Includes
@ -31,8 +34,8 @@
#include <string.h> /* strcmp, strlen */ #include <string.h> /* strcmp, strlen */
#include <errno.h> /* errno */ #include <errno.h> /* errno */
#include <signal.h> #include <signal.h>
#ifndef _WIN32 #ifdef BACKTRACES_ENABLE
#include <execinfo.h> /* backtrace, backtrace_symbols */ # include <execinfo.h> /* backtrace, backtrace_symbols */
#endif #endif
#if defined (_MSC_VER) #if defined (_MSC_VER)
@ -163,9 +166,10 @@ static void clearHandler(void)
/*-********************************************************* /*-*********************************************************
* Termination signal trapping (Print debug stack trace) * Termination signal trapping (Print debug stack trace)
***********************************************************/ ***********************************************************/
#ifdef BACKTRACES_ENABLE
#define MAX_STACK_FRAMES 50 #define MAX_STACK_FRAMES 50
#ifndef _WIN32
static void ABRThandler(int sig) { static void ABRThandler(int sig) {
const char* name; const char* name;
void* addrlist[MAX_STACK_FRAMES]; void* addrlist[MAX_STACK_FRAMES];
@ -203,7 +207,7 @@ static void ABRThandler(int sig) {
void FIO_addAbortHandler() void FIO_addAbortHandler()
{ {
#ifndef _WIN32 #ifdef BACKTRACES_ENABLE
signal(SIGABRT, ABRThandler); signal(SIGABRT, ABRThandler);
signal(SIGFPE, ABRThandler); signal(SIGFPE, ABRThandler);
signal(SIGILL, ABRThandler); signal(SIGILL, ABRThandler);

View File

@ -170,7 +170,11 @@ static int g_utilDisplayLevel;
return ((clockEnd - clockStart) * (U64)rate.numer) / ((U64)rate.denom); return ((clockEnd - clockStart) * (U64)rate.numer) / ((U64)rate.denom);
} }
#elif (PLATFORM_POSIX_VERSION >= 200112L) && (defined __UCLIBC__ || ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) || __GLIBC__ > 2)) #elif (PLATFORM_POSIX_VERSION >= 200112L) \
&& (defined(__UCLIBC__) \
|| (defined(__GLIBC__) \
&& ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) \
|| (__GLIBC__ > 2))))
#define UTIL_TIME_INITIALIZER { 0, 0 } #define UTIL_TIME_INITIALIZER { 0, 0 }
typedef struct timespec UTIL_freq_t; typedef struct timespec UTIL_freq_t;