refactor(compress): expose CCtx parameter leaves from Rust

The three public CCtx parameter APIs were still implemented as C bodies that
only forwarded into Rust symbols. Move ownership of those leaves to the Rust
ABI by using the existing public C symbol names directly, while retaining the
same signatures, behavior, and linker-visible API names. The neighboring C
helpers remain because they carry C-owned configuration or private-state
adaptation rather than being pure public forwarders.

Test Plan:
- `cargo +nightly fmt --manifest-path rust/Cargo.toml --all -- --check` -- passed.
- `cc -fsyntax-only -Ilib -Icommon lib/compress/zstd_compress.c` -- passed.
- `git diff --check` and `git diff --cached --check` -- passed.
- Heavy cargo, make, and test commands were intentionally not run per scope.
This commit is contained in:
2026-07-20 12:04:17 +02:00
parent e1d98eb8b6
commit d2a43b5080
2 changed files with 9 additions and 28 deletions
-19
View File
@@ -2001,7 +2001,6 @@ typedef char ZSTD_rust_select_block_compressor_state_layout[
/* CCtx parameter state is mirrored by rust/src/zstd_compress_params_api.rs.
* Rust owns parameter bounds and clamping; C exposes only the
* build-configuration values required by that narrow ABI. */
ZSTD_bounds ZSTD_rust_cctx_params_get_bounds(int param);
size_t ZSTD_rust_cctx_params_clamp_bounds(int param, int* value);
int ZSTD_rust_cctx_params_within_bounds(int param, int value);
int ZSTD_rust_cctx_params_is_multithreaded(void);
@@ -2009,15 +2008,12 @@ int ZSTD_rust_cctx_params_nb_workers_max(void);
int ZSTD_rust_cctx_params_job_size_min(void);
int ZSTD_rust_cctx_params_job_size_max(void);
ZSTD_CCtx_params* ZSTD_rust_createCCtxParams(ZSTD_customMem customMem);
size_t ZSTD_rust_freeCCtxParams(ZSTD_CCtx_params* params);
void ZSTD_rust_makeCCtxParamsFromCParams(
ZSTD_CCtx_params* cctxParams,
const ZSTD_compressionParameters* cParams);
void ZSTD_rust_CCtxParams_init_internal(
ZSTD_CCtx_params* cctxParams, const ZSTD_parameters* params,
int compressionLevel);
size_t ZSTD_rust_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams,
ZSTD_parameters params);
void ZSTD_rust_CCtxParams_setZstdParams(ZSTD_CCtx_params* cctxParams,
const ZSTD_parameters* params);
int ZSTD_useTargetCBlockSize(const ZSTD_CCtx_params* cctxParams);
@@ -3584,11 +3580,6 @@ ZSTD_CCtx_params* ZSTD_createCCtxParams(void)
return ZSTD_rust_createCCtxParams(ZSTD_defaultCMem);
}
size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params)
{
return ZSTD_rust_freeCCtxParams(params);
}
#define ZSTD_NO_CLEVEL 0
/**
@@ -3606,11 +3597,6 @@ ZSTD_CCtxParams_init_internal(ZSTD_CCtx_params* cctxParams,
cctxParams->useRowMatchFinder, cctxParams->postBlockSplitter, cctxParams->ldmParams.enableLdm);
}
size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params)
{
return ZSTD_rust_CCtxParams_init_advanced(cctxParams, params);
}
/**
* Sets cctxParams' cParams and fParams from params, but otherwise leaves them alone.
* @param params Validated zstd parameters.
@@ -3622,11 +3608,6 @@ static void ZSTD_CCtxParams_setZstdParams(
ZSTD_rust_CCtxParams_setZstdParams(cctxParams, params);
}
ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter param)
{
return ZSTD_rust_cctx_params_get_bounds((int)param);
}
int ZSTD_rust_cctx_params_is_multithreaded(void)
{
#ifdef ZSTD_MULTITHREAD