Modernize macros to use do { } while (0)
This PR introduces no functional changes. It attempts to change all
macros currently using `{ }` or some variant of that to to
`do { } while (0)`, and introduces trailing `;` where necessary.
There were no bugs found during this migration.
The bug in Visual Studios warning on this has been fixed since VS2015.
Additionally, we have several instances of `do { } while (0)` which have
been present for several releases, so we don't have to worry about
breaking peoples builds.
Fixes Issue #3830.
This commit is contained in:
committed by
Nick Terrell
parent
6b3d12fe54
commit
8193250615
+17
-16
@@ -132,8 +132,8 @@
|
|||||||
/* prefetch
|
/* prefetch
|
||||||
* can be disabled, by declaring NO_PREFETCH build macro */
|
* can be disabled, by declaring NO_PREFETCH build macro */
|
||||||
#if defined(NO_PREFETCH)
|
#if defined(NO_PREFETCH)
|
||||||
# define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
|
# define PREFETCH_L1(ptr) do { (void)(ptr); } while (0) /* disabled */
|
||||||
# define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
|
# define PREFETCH_L2(ptr) do { (void)(ptr); } while (0) /* disabled */
|
||||||
#else
|
#else
|
||||||
# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) && !defined(_M_ARM64EC) /* _mm_prefetch() is not defined outside of x86/x64 */
|
# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) && !defined(_M_ARM64EC) /* _mm_prefetch() is not defined outside of x86/x64 */
|
||||||
# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
|
# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
|
||||||
@@ -143,24 +143,25 @@
|
|||||||
# define PREFETCH_L1(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */)
|
# define PREFETCH_L1(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */)
|
||||||
# define PREFETCH_L2(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */)
|
# define PREFETCH_L2(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */)
|
||||||
# elif defined(__aarch64__)
|
# elif defined(__aarch64__)
|
||||||
# define PREFETCH_L1(ptr) __asm__ __volatile__("prfm pldl1keep, %0" ::"Q"(*(ptr)))
|
# define PREFETCH_L1(ptr) do { __asm__ __volatile__("prfm pldl1keep, %0" ::"Q"(*(ptr))); } while (0)
|
||||||
# define PREFETCH_L2(ptr) __asm__ __volatile__("prfm pldl2keep, %0" ::"Q"(*(ptr)))
|
# define PREFETCH_L2(ptr) do { __asm__ __volatile__("prfm pldl2keep, %0" ::"Q"(*(ptr))); } while (0)
|
||||||
# else
|
# else
|
||||||
# define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
|
# define PREFETCH_L1(ptr) do { (void)(ptr); } while (0) /* disabled */
|
||||||
# define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
|
# define PREFETCH_L2(ptr) do { (void)(ptr); } while (0) /* disabled */
|
||||||
# endif
|
# endif
|
||||||
#endif /* NO_PREFETCH */
|
#endif /* NO_PREFETCH */
|
||||||
|
|
||||||
#define CACHELINE_SIZE 64
|
#define CACHELINE_SIZE 64
|
||||||
|
|
||||||
#define PREFETCH_AREA(p, s) { \
|
#define PREFETCH_AREA(p, s) \
|
||||||
const char* const _ptr = (const char*)(p); \
|
do { \
|
||||||
size_t const _size = (size_t)(s); \
|
const char* const _ptr = (const char*)(p); \
|
||||||
size_t _pos; \
|
size_t const _size = (size_t)(s); \
|
||||||
for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \
|
size_t _pos; \
|
||||||
PREFETCH_L2(_ptr + _pos); \
|
for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \
|
||||||
} \
|
PREFETCH_L2(_ptr + _pos); \
|
||||||
}
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* vectorization
|
/* vectorization
|
||||||
* older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax,
|
* older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax,
|
||||||
@@ -189,9 +190,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __has_builtin(__builtin_unreachable) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)))
|
#if __has_builtin(__builtin_unreachable) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)))
|
||||||
# define ZSTD_UNREACHABLE { assert(0), __builtin_unreachable(); }
|
# define ZSTD_UNREACHABLE do { assert(0), __builtin_unreachable(); } while (0)
|
||||||
#else
|
#else
|
||||||
# define ZSTD_UNREACHABLE { assert(0); }
|
# define ZSTD_UNREACHABLE do { assert(0); } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* disable warnings */
|
/* disable warnings */
|
||||||
|
|||||||
+16
-11
@@ -85,18 +85,23 @@ extern int g_debuglevel; /* the variable is only declared,
|
|||||||
It's useful when enabling very verbose levels
|
It's useful when enabling very verbose levels
|
||||||
on selective conditions (such as position in src) */
|
on selective conditions (such as position in src) */
|
||||||
|
|
||||||
# define RAWLOG(l, ...) { \
|
# define RAWLOG(l, ...) \
|
||||||
if (l<=g_debuglevel) { \
|
do { \
|
||||||
ZSTD_DEBUG_PRINT(__VA_ARGS__); \
|
if (l<=g_debuglevel) { \
|
||||||
} }
|
ZSTD_DEBUG_PRINT(__VA_ARGS__); \
|
||||||
# define DEBUGLOG(l, ...) { \
|
} \
|
||||||
if (l<=g_debuglevel) { \
|
} while (0)
|
||||||
ZSTD_DEBUG_PRINT(__FILE__ ": " __VA_ARGS__); \
|
|
||||||
ZSTD_DEBUG_PRINT(" \n"); \
|
# define DEBUGLOG(l, ...) \
|
||||||
} }
|
do { \
|
||||||
|
if (l<=g_debuglevel) { \
|
||||||
|
ZSTD_DEBUG_PRINT(__FILE__ ": " __VA_ARGS__); \
|
||||||
|
ZSTD_DEBUG_PRINT(" \n"); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
#else
|
#else
|
||||||
# define RAWLOG(l, ...) {} /* disabled */
|
# define RAWLOG(l, ...) do { } while (0) /* disabled */
|
||||||
# define DEBUGLOG(l, ...) {} /* disabled */
|
# define DEBUGLOG(l, ...) do { } while (0) /* disabled */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+45
-36
@@ -60,8 +60,13 @@ ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
|
|||||||
ERR_STATIC ERR_enum ERR_getErrorCode(size_t code) { if (!ERR_isError(code)) return (ERR_enum)0; return (ERR_enum) (0-code); }
|
ERR_STATIC ERR_enum ERR_getErrorCode(size_t code) { if (!ERR_isError(code)) return (ERR_enum)0; return (ERR_enum) (0-code); }
|
||||||
|
|
||||||
/* check and forward error code */
|
/* check and forward error code */
|
||||||
#define CHECK_V_F(e, f) size_t const e = f; if (ERR_isError(e)) return e
|
#define CHECK_V_F(e, f) \
|
||||||
#define CHECK_F(f) { CHECK_V_F(_var_err__, f); }
|
size_t const e = f; \
|
||||||
|
do { \
|
||||||
|
if (ERR_isError(e)) \
|
||||||
|
return e; \
|
||||||
|
} while (0)
|
||||||
|
#define CHECK_F(f) do { CHECK_V_F(_var_err__, f); } while (0)
|
||||||
|
|
||||||
|
|
||||||
/*-****************************************
|
/*-****************************************
|
||||||
@@ -95,10 +100,12 @@ void _force_has_format_string(const char *format, ...) {
|
|||||||
* We want to force this function invocation to be syntactically correct, but
|
* We want to force this function invocation to be syntactically correct, but
|
||||||
* we don't want to force runtime evaluation of its arguments.
|
* we don't want to force runtime evaluation of its arguments.
|
||||||
*/
|
*/
|
||||||
#define _FORCE_HAS_FORMAT_STRING(...) \
|
#define _FORCE_HAS_FORMAT_STRING(...) \
|
||||||
if (0) { \
|
do { \
|
||||||
_force_has_format_string(__VA_ARGS__); \
|
if (0) { \
|
||||||
}
|
_force_has_format_string(__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define ERR_QUOTE(str) #str
|
#define ERR_QUOTE(str) #str
|
||||||
|
|
||||||
@@ -109,48 +116,50 @@ void _force_has_format_string(const char *format, ...) {
|
|||||||
* In order to do that (particularly, printing the conditional that failed),
|
* In order to do that (particularly, printing the conditional that failed),
|
||||||
* this can't just wrap RETURN_ERROR().
|
* this can't just wrap RETURN_ERROR().
|
||||||
*/
|
*/
|
||||||
#define RETURN_ERROR_IF(cond, err, ...) \
|
#define RETURN_ERROR_IF(cond, err, ...) \
|
||||||
if (cond) { \
|
do { \
|
||||||
RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s", \
|
if (cond) { \
|
||||||
__FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
|
RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s", \
|
||||||
_FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
|
__FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
|
||||||
RAWLOG(3, ": " __VA_ARGS__); \
|
_FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
|
||||||
RAWLOG(3, "\n"); \
|
RAWLOG(3, ": " __VA_ARGS__); \
|
||||||
return ERROR(err); \
|
RAWLOG(3, "\n"); \
|
||||||
}
|
return ERROR(err); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unconditionally return the specified error.
|
* Unconditionally return the specified error.
|
||||||
*
|
*
|
||||||
* In debug modes, prints additional information.
|
* In debug modes, prints additional information.
|
||||||
*/
|
*/
|
||||||
#define RETURN_ERROR(err, ...) \
|
#define RETURN_ERROR(err, ...) \
|
||||||
do { \
|
do { \
|
||||||
RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", \
|
RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", \
|
||||||
__FILE__, __LINE__, ERR_QUOTE(ERROR(err))); \
|
__FILE__, __LINE__, ERR_QUOTE(ERROR(err))); \
|
||||||
_FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
|
_FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
|
||||||
RAWLOG(3, ": " __VA_ARGS__); \
|
RAWLOG(3, ": " __VA_ARGS__); \
|
||||||
RAWLOG(3, "\n"); \
|
RAWLOG(3, "\n"); \
|
||||||
return ERROR(err); \
|
return ERROR(err); \
|
||||||
} while(0);
|
} while(0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the provided expression evaluates to an error code, returns that error code.
|
* If the provided expression evaluates to an error code, returns that error code.
|
||||||
*
|
*
|
||||||
* In debug modes, prints additional information.
|
* In debug modes, prints additional information.
|
||||||
*/
|
*/
|
||||||
#define FORWARD_IF_ERROR(err, ...) \
|
#define FORWARD_IF_ERROR(err, ...) \
|
||||||
do { \
|
do { \
|
||||||
size_t const err_code = (err); \
|
size_t const err_code = (err); \
|
||||||
if (ERR_isError(err_code)) { \
|
if (ERR_isError(err_code)) { \
|
||||||
RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s", \
|
RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s", \
|
||||||
__FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
|
__FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
|
||||||
_FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
|
_FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
|
||||||
RAWLOG(3, ": " __VA_ARGS__); \
|
RAWLOG(3, ": " __VA_ARGS__); \
|
||||||
RAWLOG(3, "\n"); \
|
RAWLOG(3, "\n"); \
|
||||||
return err_code; \
|
return err_code; \
|
||||||
} \
|
} \
|
||||||
} while(0);
|
} while(0)
|
||||||
|
|
||||||
#if defined (__cplusplus)
|
#if defined (__cplusplus)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ static void ZSTD_copy8(void* dst, const void* src) {
|
|||||||
ZSTD_memcpy(dst, src, 8);
|
ZSTD_memcpy(dst, src, 8);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#define COPY8(d,s) { ZSTD_copy8(d,s); d+=8; s+=8; }
|
#define COPY8(d,s) do { ZSTD_copy8(d,s); d+=8; s+=8; } while (0)
|
||||||
|
|
||||||
/* Need to use memmove here since the literal buffer can now be located within
|
/* Need to use memmove here since the literal buffer can now be located within
|
||||||
the dst buffer. In circumstances where the op "catches up" to where the
|
the dst buffer. In circumstances where the op "catches up" to where the
|
||||||
@@ -198,7 +198,7 @@ static void ZSTD_copy16(void* dst, const void* src) {
|
|||||||
ZSTD_memcpy(dst, copy16_buf, 16);
|
ZSTD_memcpy(dst, copy16_buf, 16);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#define COPY16(d,s) { ZSTD_copy16(d,s); d+=16; s+=16; }
|
#define COPY16(d,s) do { ZSTD_copy16(d,s); d+=16; s+=16; } while (0)
|
||||||
|
|
||||||
#define WILDCOPY_OVERLENGTH 32
|
#define WILDCOPY_OVERLENGTH 32
|
||||||
#define WILDCOPY_VECLEN 16
|
#define WILDCOPY_VECLEN 16
|
||||||
@@ -227,7 +227,7 @@ void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e
|
|||||||
if (ovtype == ZSTD_overlap_src_before_dst && diff < WILDCOPY_VECLEN) {
|
if (ovtype == ZSTD_overlap_src_before_dst && diff < WILDCOPY_VECLEN) {
|
||||||
/* Handle short offset copies. */
|
/* Handle short offset copies. */
|
||||||
do {
|
do {
|
||||||
COPY8(op, ip)
|
COPY8(op, ip);
|
||||||
} while (op < oend);
|
} while (op < oend);
|
||||||
} else {
|
} else {
|
||||||
assert(diff >= WILDCOPY_VECLEN || diff <= -WILDCOPY_VECLEN);
|
assert(diff >= WILDCOPY_VECLEN || diff <= -WILDCOPY_VECLEN);
|
||||||
|
|||||||
@@ -650,10 +650,11 @@ static size_t ZSTD_cParam_clampBounds(ZSTD_cParameter cParam, int* value)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BOUNDCHECK(cParam, val) { \
|
#define BOUNDCHECK(cParam, val) \
|
||||||
RETURN_ERROR_IF(!ZSTD_cParam_withinBounds(cParam,val), \
|
do { \
|
||||||
parameter_outOfBound, "Param out of bounds"); \
|
RETURN_ERROR_IF(!ZSTD_cParam_withinBounds(cParam,val), \
|
||||||
}
|
parameter_outOfBound, "Param out of bounds"); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
static int ZSTD_isUpdateAuthorized(ZSTD_cParameter param)
|
static int ZSTD_isUpdateAuthorized(ZSTD_cParameter param)
|
||||||
@@ -1392,11 +1393,12 @@ size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
|
|||||||
static ZSTD_compressionParameters
|
static ZSTD_compressionParameters
|
||||||
ZSTD_clampCParams(ZSTD_compressionParameters cParams)
|
ZSTD_clampCParams(ZSTD_compressionParameters cParams)
|
||||||
{
|
{
|
||||||
# define CLAMP_TYPE(cParam, val, type) { \
|
# define CLAMP_TYPE(cParam, val, type) \
|
||||||
ZSTD_bounds const bounds = ZSTD_cParam_getBounds(cParam); \
|
do { \
|
||||||
if ((int)val<bounds.lowerBound) val=(type)bounds.lowerBound; \
|
ZSTD_bounds const bounds = ZSTD_cParam_getBounds(cParam); \
|
||||||
else if ((int)val>bounds.upperBound) val=(type)bounds.upperBound; \
|
if ((int)val<bounds.lowerBound) val=(type)bounds.lowerBound; \
|
||||||
}
|
else if ((int)val>bounds.upperBound) val=(type)bounds.upperBound; \
|
||||||
|
} while (0)
|
||||||
# define CLAMP(cParam, val) CLAMP_TYPE(cParam, val, unsigned)
|
# define CLAMP(cParam, val) CLAMP_TYPE(cParam, val, unsigned)
|
||||||
CLAMP(ZSTD_c_windowLog, cParams.windowLog);
|
CLAMP(ZSTD_c_windowLog, cParams.windowLog);
|
||||||
CLAMP(ZSTD_c_chainLog, cParams.chainLog);
|
CLAMP(ZSTD_c_chainLog, cParams.chainLog);
|
||||||
|
|||||||
@@ -356,8 +356,8 @@ size_t ZSTD_compressBlock_doubleFast_dictMatchState_generic(
|
|||||||
if (ms->prefetchCDictTables) {
|
if (ms->prefetchCDictTables) {
|
||||||
size_t const hashTableBytes = (((size_t)1) << dictCParams->hashLog) * sizeof(U32);
|
size_t const hashTableBytes = (((size_t)1) << dictCParams->hashLog) * sizeof(U32);
|
||||||
size_t const chainTableBytes = (((size_t)1) << dictCParams->chainLog) * sizeof(U32);
|
size_t const chainTableBytes = (((size_t)1) << dictCParams->chainLog) * sizeof(U32);
|
||||||
PREFETCH_AREA(dictHashLong, hashTableBytes)
|
PREFETCH_AREA(dictHashLong, hashTableBytes);
|
||||||
PREFETCH_AREA(dictHashSmall, chainTableBytes)
|
PREFETCH_AREA(dictHashSmall, chainTableBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
|
|||||||
@@ -508,7 +508,7 @@ size_t ZSTD_compressBlock_fast_dictMatchState_generic(
|
|||||||
|
|
||||||
if (ms->prefetchCDictTables) {
|
if (ms->prefetchCDictTables) {
|
||||||
size_t const hashTableBytes = (((size_t)1) << dictCParams->hashLog) * sizeof(U32);
|
size_t const hashTableBytes = (((size_t)1) << dictCParams->hashLog) * sizeof(U32);
|
||||||
PREFETCH_AREA(dictHashTable, hashTableBytes)
|
PREFETCH_AREA(dictHashTable, hashTableBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
|
|||||||
@@ -1182,7 +1182,7 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms,
|
|||||||
for (cur = 1; cur <= last_pos; cur++) {
|
for (cur = 1; cur <= last_pos; cur++) {
|
||||||
const BYTE* const inr = ip + cur;
|
const BYTE* const inr = ip + cur;
|
||||||
assert(cur < ZSTD_OPT_NUM);
|
assert(cur < ZSTD_OPT_NUM);
|
||||||
DEBUGLOG(7, "cPos:%zi==rPos:%u", inr-istart, cur)
|
DEBUGLOG(7, "cPos:%zi==rPos:%u", inr-istart, cur);
|
||||||
|
|
||||||
/* Fix current position with one literal if cheaper */
|
/* Fix current position with one literal if cheaper */
|
||||||
{ U32 const litlen = (opt[cur-1].mlen == 0) ? opt[cur-1].litlen + 1 : 1;
|
{ U32 const litlen = (opt[cur-1].mlen == 0) ? opt[cur-1].litlen + 1 : 1;
|
||||||
@@ -1331,7 +1331,7 @@ _shortestPath: /* cur, last_pos, best_mlen, best_off have to be set */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* save sequences */
|
/* save sequences */
|
||||||
DEBUGLOG(6, "sending selected sequences into seqStore")
|
DEBUGLOG(6, "sending selected sequences into seqStore");
|
||||||
{ U32 storePos;
|
{ U32 storePos;
|
||||||
for (storePos=storeStart; storePos <= storeEnd; storePos++) {
|
for (storePos=storeStart; storePos <= storeEnd; storePos++) {
|
||||||
U32 const llen = opt[storePos].litlen;
|
U32 const llen = opt[storePos].litlen;
|
||||||
|
|||||||
@@ -40,12 +40,13 @@
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <sys/times.h>
|
# include <sys/times.h>
|
||||||
|
|
||||||
# define DEBUG_PRINTHEX(l,p,n) { \
|
# define DEBUG_PRINTHEX(l,p,n) \
|
||||||
unsigned debug_u; \
|
do { \
|
||||||
for (debug_u=0; debug_u<(n); debug_u++) \
|
unsigned debug_u; \
|
||||||
RAWLOG(l, "%02X ", ((const unsigned char*)(p))[debug_u]); \
|
for (debug_u=0; debug_u<(n); debug_u++) \
|
||||||
RAWLOG(l, " \n"); \
|
RAWLOG(l, "%02X ", ((const unsigned char*)(p))[debug_u]); \
|
||||||
}
|
RAWLOG(l, " \n"); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
static unsigned long long GetCurrentClockTimeMicroseconds(void)
|
static unsigned long long GetCurrentClockTimeMicroseconds(void)
|
||||||
{
|
{
|
||||||
@@ -57,25 +58,28 @@ static unsigned long long GetCurrentClockTimeMicroseconds(void)
|
|||||||
} }
|
} }
|
||||||
|
|
||||||
#define MUTEX_WAIT_TIME_DLEVEL 6
|
#define MUTEX_WAIT_TIME_DLEVEL 6
|
||||||
#define ZSTD_PTHREAD_MUTEX_LOCK(mutex) { \
|
#define ZSTD_PTHREAD_MUTEX_LOCK(mutex) \
|
||||||
if (DEBUGLEVEL >= MUTEX_WAIT_TIME_DLEVEL) { \
|
do { \
|
||||||
unsigned long long const beforeTime = GetCurrentClockTimeMicroseconds(); \
|
if (DEBUGLEVEL >= MUTEX_WAIT_TIME_DLEVEL) { \
|
||||||
ZSTD_pthread_mutex_lock(mutex); \
|
unsigned long long const beforeTime = GetCurrentClockTimeMicroseconds(); \
|
||||||
{ unsigned long long const afterTime = GetCurrentClockTimeMicroseconds(); \
|
ZSTD_pthread_mutex_lock(mutex); \
|
||||||
unsigned long long const elapsedTime = (afterTime-beforeTime); \
|
{ unsigned long long const afterTime = GetCurrentClockTimeMicroseconds(); \
|
||||||
if (elapsedTime > 1000) { /* or whatever threshold you like; I'm using 1 millisecond here */ \
|
unsigned long long const elapsedTime = (afterTime-beforeTime); \
|
||||||
DEBUGLOG(MUTEX_WAIT_TIME_DLEVEL, "Thread took %llu microseconds to acquire mutex %s \n", \
|
if (elapsedTime > 1000) { \
|
||||||
elapsedTime, #mutex); \
|
/* or whatever threshold you like; I'm using 1 millisecond here */ \
|
||||||
} } \
|
DEBUGLOG(MUTEX_WAIT_TIME_DLEVEL, \
|
||||||
} else { \
|
"Thread took %llu microseconds to acquire mutex %s \n", \
|
||||||
ZSTD_pthread_mutex_lock(mutex); \
|
elapsedTime, #mutex); \
|
||||||
} \
|
} } \
|
||||||
}
|
} else { \
|
||||||
|
ZSTD_pthread_mutex_lock(mutex); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
# define ZSTD_PTHREAD_MUTEX_LOCK(m) ZSTD_pthread_mutex_lock(m)
|
# define ZSTD_PTHREAD_MUTEX_LOCK(m) ZSTD_pthread_mutex_lock(m)
|
||||||
# define DEBUG_PRINTHEX(l,p,n) {}
|
# define DEBUG_PRINTHEX(l,p,n) do { } while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -667,12 +671,13 @@ typedef struct {
|
|||||||
unsigned frameChecksumNeeded; /* used only by mtctx */
|
unsigned frameChecksumNeeded; /* used only by mtctx */
|
||||||
} ZSTDMT_jobDescription;
|
} ZSTDMT_jobDescription;
|
||||||
|
|
||||||
#define JOB_ERROR(e) { \
|
#define JOB_ERROR(e) \
|
||||||
ZSTD_PTHREAD_MUTEX_LOCK(&job->job_mutex); \
|
do { \
|
||||||
job->cSize = e; \
|
ZSTD_PTHREAD_MUTEX_LOCK(&job->job_mutex); \
|
||||||
ZSTD_pthread_mutex_unlock(&job->job_mutex); \
|
job->cSize = e; \
|
||||||
goto _endJob; \
|
ZSTD_pthread_mutex_unlock(&job->job_mutex); \
|
||||||
}
|
goto _endJob; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* ZSTDMT_compressionJob() is a POOL_function type */
|
/* ZSTDMT_compressionJob() is a POOL_function type */
|
||||||
static void ZSTDMT_compressionJob(void* jobDescription)
|
static void ZSTDMT_compressionJob(void* jobDescription)
|
||||||
@@ -1101,7 +1106,7 @@ ZSTD_frameProgression ZSTDMT_getFrameProgression(ZSTDMT_CCtx* mtctx)
|
|||||||
{ unsigned jobNb;
|
{ unsigned jobNb;
|
||||||
unsigned lastJobNb = mtctx->nextJobID + mtctx->jobReady; assert(mtctx->jobReady <= 1);
|
unsigned lastJobNb = mtctx->nextJobID + mtctx->jobReady; assert(mtctx->jobReady <= 1);
|
||||||
DEBUGLOG(6, "ZSTDMT_getFrameProgression: jobs: from %u to <%u (jobReady:%u)",
|
DEBUGLOG(6, "ZSTDMT_getFrameProgression: jobs: from %u to <%u (jobReady:%u)",
|
||||||
mtctx->doneJobID, lastJobNb, mtctx->jobReady)
|
mtctx->doneJobID, lastJobNb, mtctx->jobReady);
|
||||||
for (jobNb = mtctx->doneJobID ; jobNb < lastJobNb ; jobNb++) {
|
for (jobNb = mtctx->doneJobID ; jobNb < lastJobNb ; jobNb++) {
|
||||||
unsigned const wJobID = jobNb & mtctx->jobIDMask;
|
unsigned const wJobID = jobNb & mtctx->jobIDMask;
|
||||||
ZSTDMT_jobDescription* jobPtr = &mtctx->jobs[wJobID];
|
ZSTDMT_jobDescription* jobPtr = &mtctx->jobs[wJobID];
|
||||||
|
|||||||
@@ -304,21 +304,21 @@ static size_t HUF_initRemainingDStream(BIT_DStream_t* bit, HUF_DecompressFastArg
|
|||||||
|
|
||||||
/* Calls X(N) for each stream 0, 1, 2, 3. */
|
/* Calls X(N) for each stream 0, 1, 2, 3. */
|
||||||
#define HUF_4X_FOR_EACH_STREAM(X) \
|
#define HUF_4X_FOR_EACH_STREAM(X) \
|
||||||
{ \
|
do { \
|
||||||
X(0) \
|
X(0); \
|
||||||
X(1) \
|
X(1); \
|
||||||
X(2) \
|
X(2); \
|
||||||
X(3) \
|
X(3); \
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
/* Calls X(N, var) for each stream 0, 1, 2, 3. */
|
/* Calls X(N, var) for each stream 0, 1, 2, 3. */
|
||||||
#define HUF_4X_FOR_EACH_STREAM_WITH_VAR(X, var) \
|
#define HUF_4X_FOR_EACH_STREAM_WITH_VAR(X, var) \
|
||||||
{ \
|
do { \
|
||||||
X(0, (var)) \
|
X(0, (var)); \
|
||||||
X(1, (var)) \
|
X(1, (var)); \
|
||||||
X(2, (var)) \
|
X(2, (var)); \
|
||||||
X(3, (var)) \
|
X(3, (var)); \
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
#ifndef HUF_FORCE_DECOMPRESS_X2
|
#ifndef HUF_FORCE_DECOMPRESS_X2
|
||||||
@@ -528,15 +528,19 @@ HUF_decodeSymbolX1(BIT_DStream_t* Dstream, const HUF_DEltX1* dt, const U32 dtLog
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr) \
|
#define HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr) \
|
||||||
*ptr++ = HUF_decodeSymbolX1(DStreamPtr, dt, dtLog)
|
do { *ptr++ = HUF_decodeSymbolX1(DStreamPtr, dt, dtLog); } while (0)
|
||||||
|
|
||||||
#define HUF_DECODE_SYMBOLX1_1(ptr, DStreamPtr) \
|
#define HUF_DECODE_SYMBOLX1_1(ptr, DStreamPtr) \
|
||||||
if (MEM_64bits() || (HUF_TABLELOG_MAX<=12)) \
|
do { \
|
||||||
HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr)
|
if (MEM_64bits() || (HUF_TABLELOG_MAX<=12)) \
|
||||||
|
HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define HUF_DECODE_SYMBOLX1_2(ptr, DStreamPtr) \
|
#define HUF_DECODE_SYMBOLX1_2(ptr, DStreamPtr) \
|
||||||
if (MEM_64bits()) \
|
do { \
|
||||||
HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr)
|
if (MEM_64bits()) \
|
||||||
|
HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
HINT_INLINE size_t
|
HINT_INLINE size_t
|
||||||
HUF_decodeStreamX1(BYTE* p, BIT_DStream_t* const bitDPtr, BYTE* const pEnd, const HUF_DEltX1* const dt, const U32 dtLog)
|
HUF_decodeStreamX1(BYTE* p, BIT_DStream_t* const bitDPtr, BYTE* const pEnd, const HUF_DEltX1* const dt, const U32 dtLog)
|
||||||
@@ -781,15 +785,15 @@ void HUF_decompress4X1_usingDTable_internal_fast_c_loop(HUF_DecompressFastArgs*
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HUF_4X1_DECODE_SYMBOL(_stream, _symbol) \
|
#define HUF_4X1_DECODE_SYMBOL(_stream, _symbol) \
|
||||||
{ \
|
do { \
|
||||||
int const index = (int)(bits[(_stream)] >> 53); \
|
int const index = (int)(bits[(_stream)] >> 53); \
|
||||||
int const entry = (int)dtable[index]; \
|
int const entry = (int)dtable[index]; \
|
||||||
bits[(_stream)] <<= (entry & 0x3F); \
|
bits[(_stream)] <<= (entry & 0x3F); \
|
||||||
op[(_stream)][(_symbol)] = (BYTE)((entry >> 8) & 0xFF); \
|
op[(_stream)][(_symbol)] = (BYTE)((entry >> 8) & 0xFF); \
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
#define HUF_4X1_RELOAD_STREAM(_stream) \
|
#define HUF_4X1_RELOAD_STREAM(_stream) \
|
||||||
{ \
|
do { \
|
||||||
int const ctz = ZSTD_countTrailingZeros64(bits[(_stream)]); \
|
int const ctz = ZSTD_countTrailingZeros64(bits[(_stream)]); \
|
||||||
int const nbBits = ctz & 7; \
|
int const nbBits = ctz & 7; \
|
||||||
int const nbBytes = ctz >> 3; \
|
int const nbBytes = ctz >> 3; \
|
||||||
@@ -797,21 +801,21 @@ void HUF_decompress4X1_usingDTable_internal_fast_c_loop(HUF_DecompressFastArgs*
|
|||||||
ip[(_stream)] -= nbBytes; \
|
ip[(_stream)] -= nbBytes; \
|
||||||
bits[(_stream)] = MEM_read64(ip[(_stream)]) | 1; \
|
bits[(_stream)] = MEM_read64(ip[(_stream)]) | 1; \
|
||||||
bits[(_stream)] <<= nbBits; \
|
bits[(_stream)] <<= nbBits; \
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
/* Manually unroll the loop because compilers don't consistently
|
/* Manually unroll the loop because compilers don't consistently
|
||||||
* unroll the inner loops, which destroys performance.
|
* unroll the inner loops, which destroys performance.
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
/* Decode 5 symbols in each of the 4 streams */
|
/* Decode 5 symbols in each of the 4 streams */
|
||||||
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X1_DECODE_SYMBOL, 0)
|
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X1_DECODE_SYMBOL, 0);
|
||||||
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X1_DECODE_SYMBOL, 1)
|
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X1_DECODE_SYMBOL, 1);
|
||||||
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X1_DECODE_SYMBOL, 2)
|
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X1_DECODE_SYMBOL, 2);
|
||||||
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X1_DECODE_SYMBOL, 3)
|
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X1_DECODE_SYMBOL, 3);
|
||||||
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X1_DECODE_SYMBOL, 4)
|
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X1_DECODE_SYMBOL, 4);
|
||||||
|
|
||||||
/* Reload each of the 4 the bitstreams */
|
/* Reload each of the 4 the bitstreams */
|
||||||
HUF_4X_FOR_EACH_STREAM(HUF_4X1_RELOAD_STREAM)
|
HUF_4X_FOR_EACH_STREAM(HUF_4X1_RELOAD_STREAM);
|
||||||
} while (op[3] < olimit);
|
} while (op[3] < olimit);
|
||||||
|
|
||||||
#undef HUF_4X1_DECODE_SYMBOL
|
#undef HUF_4X1_DECODE_SYMBOL
|
||||||
@@ -1286,15 +1290,19 @@ HUF_decodeLastSymbolX2(void* op, BIT_DStream_t* DStream, const HUF_DEltX2* dt, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define HUF_DECODE_SYMBOLX2_0(ptr, DStreamPtr) \
|
#define HUF_DECODE_SYMBOLX2_0(ptr, DStreamPtr) \
|
||||||
ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog)
|
do { ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog); } while (0)
|
||||||
|
|
||||||
#define HUF_DECODE_SYMBOLX2_1(ptr, DStreamPtr) \
|
#define HUF_DECODE_SYMBOLX2_1(ptr, DStreamPtr) \
|
||||||
if (MEM_64bits() || (HUF_TABLELOG_MAX<=12)) \
|
do { \
|
||||||
ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog)
|
if (MEM_64bits() || (HUF_TABLELOG_MAX<=12)) \
|
||||||
|
ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define HUF_DECODE_SYMBOLX2_2(ptr, DStreamPtr) \
|
#define HUF_DECODE_SYMBOLX2_2(ptr, DStreamPtr) \
|
||||||
if (MEM_64bits()) \
|
do { \
|
||||||
ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog)
|
if (MEM_64bits()) \
|
||||||
|
ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
HINT_INLINE size_t
|
HINT_INLINE size_t
|
||||||
HUF_decodeStreamX2(BYTE* p, BIT_DStream_t* bitDPtr, BYTE* const pEnd,
|
HUF_decodeStreamX2(BYTE* p, BIT_DStream_t* bitDPtr, BYTE* const pEnd,
|
||||||
@@ -1594,18 +1602,20 @@ void HUF_decompress4X2_usingDTable_internal_fast_c_loop(HUF_DecompressFastArgs*
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HUF_4X2_DECODE_SYMBOL(_stream, _decode3) \
|
#define HUF_4X2_DECODE_SYMBOL(_stream, _decode3) \
|
||||||
if ((_decode3) || (_stream) != 3) { \
|
do { \
|
||||||
int const index = (int)(bits[(_stream)] >> 53); \
|
if ((_decode3) || (_stream) != 3) { \
|
||||||
HUF_DEltX2 const entry = dtable[index]; \
|
int const index = (int)(bits[(_stream)] >> 53); \
|
||||||
MEM_write16(op[(_stream)], entry.sequence); \
|
HUF_DEltX2 const entry = dtable[index]; \
|
||||||
bits[(_stream)] <<= (entry.nbBits) & 0x3F; \
|
MEM_write16(op[(_stream)], entry.sequence); \
|
||||||
op[(_stream)] += (entry.length); \
|
bits[(_stream)] <<= (entry.nbBits) & 0x3F; \
|
||||||
}
|
op[(_stream)] += (entry.length); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define HUF_4X2_RELOAD_STREAM(_stream) \
|
#define HUF_4X2_RELOAD_STREAM(_stream) \
|
||||||
{ \
|
do { \
|
||||||
HUF_4X2_DECODE_SYMBOL(3, 1) \
|
HUF_4X2_DECODE_SYMBOL(3, 1); \
|
||||||
{ \
|
{ \
|
||||||
int const ctz = ZSTD_countTrailingZeros64(bits[(_stream)]); \
|
int const ctz = ZSTD_countTrailingZeros64(bits[(_stream)]); \
|
||||||
int const nbBits = ctz & 7; \
|
int const nbBits = ctz & 7; \
|
||||||
@@ -1614,7 +1624,7 @@ void HUF_decompress4X2_usingDTable_internal_fast_c_loop(HUF_DecompressFastArgs*
|
|||||||
bits[(_stream)] = MEM_read64(ip[(_stream)]) | 1; \
|
bits[(_stream)] = MEM_read64(ip[(_stream)]) | 1; \
|
||||||
bits[(_stream)] <<= nbBits; \
|
bits[(_stream)] <<= nbBits; \
|
||||||
} \
|
} \
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
/* Manually unroll the loop because compilers don't consistently
|
/* Manually unroll the loop because compilers don't consistently
|
||||||
* unroll the inner loops, which destroys performance.
|
* unroll the inner loops, which destroys performance.
|
||||||
@@ -1624,20 +1634,20 @@ void HUF_decompress4X2_usingDTable_internal_fast_c_loop(HUF_DecompressFastArgs*
|
|||||||
* The final stream will be decoded during the reload phase
|
* The final stream will be decoded during the reload phase
|
||||||
* to reduce register pressure.
|
* to reduce register pressure.
|
||||||
*/
|
*/
|
||||||
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X2_DECODE_SYMBOL, 0)
|
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X2_DECODE_SYMBOL, 0);
|
||||||
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X2_DECODE_SYMBOL, 0)
|
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X2_DECODE_SYMBOL, 0);
|
||||||
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X2_DECODE_SYMBOL, 0)
|
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X2_DECODE_SYMBOL, 0);
|
||||||
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X2_DECODE_SYMBOL, 0)
|
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X2_DECODE_SYMBOL, 0);
|
||||||
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X2_DECODE_SYMBOL, 0)
|
HUF_4X_FOR_EACH_STREAM_WITH_VAR(HUF_4X2_DECODE_SYMBOL, 0);
|
||||||
|
|
||||||
/* Decode one symbol from the final stream */
|
/* Decode one symbol from the final stream */
|
||||||
HUF_4X2_DECODE_SYMBOL(3, 1)
|
HUF_4X2_DECODE_SYMBOL(3, 1);
|
||||||
|
|
||||||
/* Decode 4 symbols from the final stream & reload bitstreams.
|
/* Decode 4 symbols from the final stream & reload bitstreams.
|
||||||
* The final stream is reloaded last, meaning that all 5 symbols
|
* The final stream is reloaded last, meaning that all 5 symbols
|
||||||
* are decoded from the final stream before it is reloaded.
|
* are decoded from the final stream before it is reloaded.
|
||||||
*/
|
*/
|
||||||
HUF_4X_FOR_EACH_STREAM(HUF_4X2_RELOAD_STREAM)
|
HUF_4X_FOR_EACH_STREAM(HUF_4X2_RELOAD_STREAM);
|
||||||
} while (op[3] < olimit);
|
} while (op[3] < olimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2173,7 +2173,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB
|
|||||||
/* shortcut : using single-pass mode */
|
/* shortcut : using single-pass mode */
|
||||||
size_t const decompressedSize = ZSTD_decompress_usingDDict(zds, op, (size_t)(oend-op), istart, cSize, ZSTD_getDDict(zds));
|
size_t const decompressedSize = ZSTD_decompress_usingDDict(zds, op, (size_t)(oend-op), istart, cSize, ZSTD_getDDict(zds));
|
||||||
if (ZSTD_isError(decompressedSize)) return decompressedSize;
|
if (ZSTD_isError(decompressedSize)) return decompressedSize;
|
||||||
DEBUGLOG(4, "shortcut to single-pass ZSTD_decompress_usingDDict()")
|
DEBUGLOG(4, "shortcut to single-pass ZSTD_decompress_usingDDict()");
|
||||||
assert(istart != NULL);
|
assert(istart != NULL);
|
||||||
ip = istart + cSize;
|
ip = istart + cSize;
|
||||||
op = op ? op + decompressedSize : op; /* can occur if frameContentSize = 0 (empty frame) */
|
op = op ? op + decompressedSize : op; /* can occur if frameContentSize = 0 (empty frame) */
|
||||||
|
|||||||
+12
-6
@@ -74,9 +74,9 @@ static const U32 g_selectivity_default = 9;
|
|||||||
* Console display
|
* Console display
|
||||||
***************************************/
|
***************************************/
|
||||||
#undef DISPLAY
|
#undef DISPLAY
|
||||||
#define DISPLAY(...) { fprintf(stderr, __VA_ARGS__); fflush( stderr ); }
|
#define DISPLAY(...) do { fprintf(stderr, __VA_ARGS__); fflush( stderr ); } while (0)
|
||||||
#undef DISPLAYLEVEL
|
#undef DISPLAYLEVEL
|
||||||
#define DISPLAYLEVEL(l, ...) if (notificationLevel>=l) { DISPLAY(__VA_ARGS__); } /* 0 : no display; 1: errors; 2: default; 3: details; 4: debug */
|
#define DISPLAYLEVEL(l, ...) do { if (notificationLevel>=l) { DISPLAY(__VA_ARGS__); } } while (0) /* 0 : no display; 1: errors; 2: default; 3: details; 4: debug */
|
||||||
|
|
||||||
static clock_t ZDICT_clockSpan(clock_t nPrevious) { return clock() - nPrevious; }
|
static clock_t ZDICT_clockSpan(clock_t nPrevious) { return clock() - nPrevious; }
|
||||||
|
|
||||||
@@ -477,10 +477,16 @@ static size_t ZDICT_trainBuffer_legacy(dictItem* dictList, U32 dictListSize,
|
|||||||
clock_t const refreshRate = CLOCKS_PER_SEC * 3 / 10;
|
clock_t const refreshRate = CLOCKS_PER_SEC * 3 / 10;
|
||||||
|
|
||||||
# undef DISPLAYUPDATE
|
# undef DISPLAYUPDATE
|
||||||
# define DISPLAYUPDATE(l, ...) if (notificationLevel>=l) { \
|
# define DISPLAYUPDATE(l, ...) \
|
||||||
if (ZDICT_clockSpan(displayClock) > refreshRate) \
|
do { \
|
||||||
{ displayClock = clock(); DISPLAY(__VA_ARGS__); \
|
if (notificationLevel>=l) { \
|
||||||
if (notificationLevel>=4) fflush(stderr); } }
|
if (ZDICT_clockSpan(displayClock) > refreshRate) { \
|
||||||
|
displayClock = clock(); \
|
||||||
|
DISPLAY(__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
if (notificationLevel>=4) fflush(stderr); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
DISPLAYLEVEL(2, "\r%70s\r", ""); /* clean display line */
|
DISPLAYLEVEL(2, "\r%70s\r", ""); /* clean display line */
|
||||||
|
|||||||
Reference in New Issue
Block a user