feat(compress): move frame parameter updates into Rust
Move ZSTD_CCtx_setFParams's ordered frame-flag updates into the Rust projection. C retains the context-bound ZSTD_CCtx_setParameter callback while Rust preserves content-size, checksum, and dictionary-ID boolean conversions, update order, and first-error propagation. Test Plan: - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml set_fparams -- --test-threads=1 - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings - ulimit -v 41943040; make -B -C programs -j1 zstd - git diff --cached --check
This commit is contained in:
@@ -213,6 +213,19 @@ typedef char ZSTD_rust_set_cparams_state_layout[
|
||||
&& offsetof(ZSTD_rust_setCParamsState, setParameter) == 2 * sizeof(void*)
|
||||
&& sizeof(ZSTD_rust_setCParamsState) == 3 * sizeof(void*))
|
||||
? 1 : -1];
|
||||
typedef size_t (*ZSTD_rust_setFParamsSetParameter_f)(
|
||||
void* context, int param, int value);
|
||||
typedef struct {
|
||||
void* callbackContext;
|
||||
ZSTD_rust_setFParamsSetParameter_f setParameter;
|
||||
} ZSTD_rust_setFParamsState;
|
||||
size_t ZSTD_rust_setFParams(const ZSTD_rust_setFParamsState* state,
|
||||
ZSTD_frameParameters fParams);
|
||||
typedef char ZSTD_rust_set_fparams_state_layout[
|
||||
(offsetof(ZSTD_rust_setFParamsState, callbackContext) == 0
|
||||
&& offsetof(ZSTD_rust_setFParamsState, setParameter) == sizeof(void*)
|
||||
&& sizeof(ZSTD_rust_setFParamsState) == 2 * sizeof(void*))
|
||||
? 1 : -1];
|
||||
ZSTD_frameProgression ZSTD_rust_frameProgression(U64 consumedSrcSize,
|
||||
size_t buffered,
|
||||
U64 producedCSize);
|
||||
@@ -1903,6 +1916,12 @@ static size_t ZSTD_rust_setCParams_setParameter(
|
||||
return ZSTD_CCtx_setParameter((ZSTD_CCtx*)context, (ZSTD_cParameter)param, value);
|
||||
}
|
||||
|
||||
static size_t ZSTD_rust_setFParams_setParameter(
|
||||
void* context, int param, int value)
|
||||
{
|
||||
return ZSTD_CCtx_setParameter((ZSTD_CCtx*)context, (ZSTD_cParameter)param, value);
|
||||
}
|
||||
|
||||
size_t ZSTD_CCtx_setCParams(ZSTD_CCtx* cctx, ZSTD_compressionParameters cparams)
|
||||
{
|
||||
ZSTD_rust_setCParamsState state;
|
||||
@@ -1916,12 +1935,12 @@ size_t ZSTD_CCtx_setCParams(ZSTD_CCtx* cctx, ZSTD_compressionParameters cparams)
|
||||
|
||||
size_t ZSTD_CCtx_setFParams(ZSTD_CCtx* cctx, ZSTD_frameParameters fparams)
|
||||
{
|
||||
ZSTD_rust_setFParamsState state;
|
||||
ZSTD_STATIC_ASSERT(sizeof(fparams) == 3 * 4 /* all params are listed below */);
|
||||
DEBUGLOG(4, "ZSTD_CCtx_setFParams");
|
||||
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(cctx, ZSTD_c_contentSizeFlag, fparams.contentSizeFlag != 0), "");
|
||||
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, fparams.checksumFlag != 0), "");
|
||||
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(cctx, ZSTD_c_dictIDFlag, fparams.noDictIDFlag == 0), "");
|
||||
return 0;
|
||||
state.callbackContext = cctx;
|
||||
state.setParameter = ZSTD_rust_setFParams_setParameter;
|
||||
return ZSTD_rust_setFParams(&state, fparams);
|
||||
}
|
||||
|
||||
size_t ZSTD_CCtx_setParams(ZSTD_CCtx* cctx, ZSTD_parameters params)
|
||||
|
||||
Reference in New Issue
Block a user