feat(compress): move stored parameter policy into Rust
Move ZSTD_CCtx_setParametersUsingCCtxParams stage, dictionary, and copy policy into a Rust-owned ABI bridge while retaining C-owned parameter object storage. Preserve stage-before-dictionary validation, error codes, and no-mutation behavior on rejected calls. Test Plan: - cargo test --manifest-path rust/Cargo.toml --lib - cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings - make -B -C programs -j1 zstd - make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s - focused set_parameters_using_cctx_params unit tests
This commit is contained in:
@@ -247,6 +247,25 @@ typedef char ZSTD_rust_set_params_state_layout[
|
||||
&& offsetof(ZSTD_rust_setParamsState, setCParams) == 3 * sizeof(void*)
|
||||
&& sizeof(ZSTD_rust_setParamsState) == 4 * sizeof(void*))
|
||||
? 1 : -1];
|
||||
typedef struct {
|
||||
ZSTD_CCtx_params* requestedParams;
|
||||
const ZSTD_CCtx_params* sourceParams;
|
||||
int streamStage;
|
||||
const void* cdict;
|
||||
} ZSTD_rust_setParametersUsingCCtxParamsState;
|
||||
size_t ZSTD_rust_setParametersUsingCCtxParams(
|
||||
const ZSTD_rust_setParametersUsingCCtxParamsState* state);
|
||||
typedef char ZSTD_rust_set_parameters_using_cctx_params_state_layout[
|
||||
(offsetof(ZSTD_rust_setParametersUsingCCtxParamsState, requestedParams) == 0
|
||||
&& offsetof(ZSTD_rust_setParametersUsingCCtxParamsState, sourceParams)
|
||||
== sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_setParametersUsingCCtxParamsState, streamStage)
|
||||
== 2 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_setParametersUsingCCtxParamsState, cdict)
|
||||
== 3 * sizeof(void*)
|
||||
&& sizeof(ZSTD_rust_setParametersUsingCCtxParamsState)
|
||||
== 4 * sizeof(void*))
|
||||
? 1 : -1];
|
||||
typedef void (*ZSTD_rust_resetCCtxClearAllDicts_f)(void* context);
|
||||
typedef size_t (*ZSTD_rust_resetCCtxResetParams_f)(void* context);
|
||||
typedef struct {
|
||||
@@ -1942,14 +1961,11 @@ size_t ZSTD_CCtx_setParametersUsingCCtxParams(
|
||||
ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params)
|
||||
{
|
||||
DEBUGLOG(4, "ZSTD_CCtx_setParametersUsingCCtxParams");
|
||||
RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong,
|
||||
"The context is in the wrong stage!");
|
||||
RETURN_ERROR_IF(cctx->cdict, stage_wrong,
|
||||
"Can't override parameters with cdict attached (some must "
|
||||
"be inherited from the cdict).");
|
||||
|
||||
cctx->requestedParams = *params;
|
||||
return 0;
|
||||
{ ZSTD_rust_setParametersUsingCCtxParamsState const state = {
|
||||
&cctx->requestedParams, params, (int)cctx->streamStage, cctx->cdict
|
||||
};
|
||||
return ZSTD_rust_setParametersUsingCCtxParams(&state);
|
||||
}
|
||||
}
|
||||
|
||||
static size_t ZSTD_rust_setCParams_checkCParams(
|
||||
|
||||
Reference in New Issue
Block a user