mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
benchfn : added macro macro CONTROL()
like assert() but cannot be disabled. proper separation of user contract errors (CONTROL()) and invariant verification (assert()).
This commit is contained in:
@ -563,6 +563,9 @@ MEM_STATIC U64 ZSTD_rollingHash_rotate(U64 hash, BYTE toRemove, BYTE toAdd, U64
|
|||||||
/*-*************************************
|
/*-*************************************
|
||||||
* Round buffer management
|
* Round buffer management
|
||||||
***************************************/
|
***************************************/
|
||||||
|
#if (ZSTD_WINDOWLOG_MAX_64 > 31)
|
||||||
|
# error "ZSTD_WINDOWLOG_MAX is too large : would overflow ZSTD_CURRENT_MAX"
|
||||||
|
#endif
|
||||||
/* Max current allowed */
|
/* Max current allowed */
|
||||||
#define ZSTD_CURRENT_MAX ((3U << 29) + (1U << ZSTD_WINDOWLOG_MAX))
|
#define ZSTD_CURRENT_MAX ((3U << 29) + (1U << ZSTD_WINDOWLOG_MAX))
|
||||||
/* Maximum chunk size before overflow correction needs to be called again */
|
/* Maximum chunk size before overflow correction needs to be called again */
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
***************************************/
|
***************************************/
|
||||||
#include <stdlib.h> /* malloc, free */
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <string.h> /* memset */
|
#include <string.h> /* memset */
|
||||||
#undef NDEBUG /* assert must not be disabled */
|
|
||||||
#include <assert.h> /* assert */
|
#include <assert.h> /* assert */
|
||||||
|
|
||||||
#include "timefn.h" /* UTIL_time_t, UTIL_getTime */
|
#include "timefn.h" /* UTIL_time_t, UTIL_getTime */
|
||||||
@ -54,6 +53,9 @@
|
|||||||
return retValue; \
|
return retValue; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Abort execution if a condition is not met */
|
||||||
|
#define CONTROL(c) { if (!(c)) { DEBUGOUTPUT("error: %s \n", #c); abort(); } }
|
||||||
|
|
||||||
|
|
||||||
/* *************************************
|
/* *************************************
|
||||||
* Benchmarking an arbitrary function
|
* Benchmarking an arbitrary function
|
||||||
@ -68,13 +70,13 @@ int BMK_isSuccessful_runOutcome(BMK_runOutcome_t outcome)
|
|||||||
* check outcome validity first, using BMK_isValid_runResult() */
|
* check outcome validity first, using BMK_isValid_runResult() */
|
||||||
BMK_runTime_t BMK_extract_runTime(BMK_runOutcome_t outcome)
|
BMK_runTime_t BMK_extract_runTime(BMK_runOutcome_t outcome)
|
||||||
{
|
{
|
||||||
assert(outcome.error_tag_never_ever_use_directly == 0);
|
CONTROL(outcome.error_tag_never_ever_use_directly == 0);
|
||||||
return outcome.internal_never_ever_use_directly;
|
return outcome.internal_never_ever_use_directly;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BMK_extract_errorResult(BMK_runOutcome_t outcome)
|
size_t BMK_extract_errorResult(BMK_runOutcome_t outcome)
|
||||||
{
|
{
|
||||||
assert(outcome.error_tag_never_ever_use_directly != 0);
|
CONTROL(outcome.error_tag_never_ever_use_directly != 0);
|
||||||
return outcome.error_result_never_ever_use_directly;
|
return outcome.error_result_never_ever_use_directly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user