mirror of
https://github.com/facebook/zstd.git
synced 2025-08-07 06:23:00 +03:00
Add a method for checking if ZSTD was compiled with flags that impact determinism
This commit is contained in:
committed by
Nick Terrell
parent
99cf130cfc
commit
0de4991942
@@ -168,4 +168,23 @@
|
|||||||
# define ZSTD_CET_ENDBRANCH
|
# define ZSTD_CET_ENDBRANCH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ZSTD_IS_DETERMINISTIC_BUILD must be set to 0 if any compilation macro is
|
||||||
|
* active that impacts the compressed output.
|
||||||
|
*
|
||||||
|
* NOTE: ZSTD_MULTITHREAD is allowed to be set or unset.
|
||||||
|
*/
|
||||||
|
#if defined(ZSTD_CLEVEL_DEFAULT) \
|
||||||
|
|| defined(ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR) \
|
||||||
|
|| defined(ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR) \
|
||||||
|
|| defined(ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR) \
|
||||||
|
|| defined(ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR) \
|
||||||
|
|| defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR) \
|
||||||
|
|| defined(ZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR) \
|
||||||
|
|| defined(ZSTD_EXCLUDE_BTULTRA_BLOCK_COMPRESSOR)
|
||||||
|
# define ZSTD_IS_DETERMINISTIC_BUILD 0
|
||||||
|
#else
|
||||||
|
# define ZSTD_IS_DETERMINISTIC_BUILD 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* ZSTD_PORTABILITY_MACROS_H */
|
#endif /* ZSTD_PORTABILITY_MACROS_H */
|
||||||
|
@@ -46,3 +46,12 @@ ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
|
|||||||
/*! ZSTD_getErrorString() :
|
/*! ZSTD_getErrorString() :
|
||||||
* provides error code string from enum */
|
* provides error code string from enum */
|
||||||
const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
|
const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
|
||||||
|
|
||||||
|
int ZSTD_isDeterministicBuild(void)
|
||||||
|
{
|
||||||
|
#if ZSTD_IS_DETERMINISTIC_BUILD
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
12
lib/zstd.h
12
lib/zstd.h
@@ -3138,6 +3138,18 @@ ZSTDLIB_STATIC_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*! ZSTD_isDeterministicBuild() :
|
||||||
|
* Returns 1 if the library is built using standard compilation flags,
|
||||||
|
* and participates in determinism guarantees with other builds of the
|
||||||
|
* same version.
|
||||||
|
* If this function returns 0, it means the library was compiled with
|
||||||
|
* non-standard compilation flags that change the output of the
|
||||||
|
* compressor.
|
||||||
|
* This is mainly used for Zstd's determinism test suite, which is only
|
||||||
|
* run when this function returns 1.
|
||||||
|
*/
|
||||||
|
ZSTDLIB_API int ZSTD_isDeterministicBuild(void);
|
||||||
|
|
||||||
|
|
||||||
/* ========================================= */
|
/* ========================================= */
|
||||||
/** Block level API (DEPRECATED) */
|
/** Block level API (DEPRECATED) */
|
||||||
|
@@ -695,7 +695,10 @@ static void printVersion(void)
|
|||||||
#ifdef PLATFORM_POSIX_VERSION
|
#ifdef PLATFORM_POSIX_VERSION
|
||||||
DISPLAYOUT("PLATFORM_POSIX_VERSION defined: %ldL\n", (long) PLATFORM_POSIX_VERSION);
|
DISPLAYOUT("PLATFORM_POSIX_VERSION defined: %ldL\n", (long) PLATFORM_POSIX_VERSION);
|
||||||
#endif
|
#endif
|
||||||
} }
|
|
||||||
|
if (!ZSTD_isDeterministicBuild()) {
|
||||||
|
DISPLAYOUT("non-deterministic build\n");
|
||||||
|
} } }
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ZSTD_NB_STRATEGIES 9
|
#define ZSTD_NB_STRATEGIES 9
|
||||||
|
Reference in New Issue
Block a user