refactor(compress): expose pure parameter policy leaves from Rust
The compression-parameter check, clamp, and cycle-log helpers were still translation-unit C bodies that only forwarded value arguments to Rust. That left redundant C ownership and made the direct Rust ABI names differ from the public or internal C symbols used by callers. Export the existing C names from the Rust parameter module and remove the forwarding bodies. Crate-local aliases retain the old Rust-side names for existing Rust callers; all private context, configuration, assertion, and stateful adapters remain on the C side. Test Plan: - `cc -fsyntax-only -Ilib -Icommon lib/compress/zstd_compress.c` -- passed. - `cargo +nightly fmt --manifest-path rust/Cargo.toml --all -- --check` -- 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:
@@ -1924,12 +1924,10 @@ void ZSTD_rust_setBufferExpectations(
|
||||
* scalar inputs. The ZSTD_CParamMode_e and ZSTD_ParamSwitch_e enums are
|
||||
* passed as int; the Rust side mirrors their values. */
|
||||
ZSTD_bounds ZSTD_rust_params_getBounds(int param);
|
||||
size_t ZSTD_rust_params_checkCParams(ZSTD_compressionParameters cParams);
|
||||
void ZSTD_rust_params_assertEqualCParams(ZSTD_compressionParameters cParams1,
|
||||
ZSTD_compressionParameters cParams2);
|
||||
ZSTD_compressionParameters
|
||||
ZSTD_rust_params_clampCParams(ZSTD_compressionParameters cParams);
|
||||
U32 ZSTD_rust_params_cycleLog(U32 hashLog, int strategy);
|
||||
ZSTD_clampCParams(ZSTD_compressionParameters cParams);
|
||||
ZSTD_compressionParameters
|
||||
ZSTD_rust_params_selectCParams(int compressionLevel, U64 srcSizeHint,
|
||||
size_t dictSize, int mode);
|
||||
@@ -3849,30 +3847,6 @@ size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset)
|
||||
}
|
||||
|
||||
|
||||
/** ZSTD_checkCParams() :
|
||||
control CParam values remain within authorized range.
|
||||
@return : 0, or an error code if one value is beyond authorized range */
|
||||
size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
|
||||
{
|
||||
return ZSTD_rust_params_checkCParams(cParams);
|
||||
}
|
||||
|
||||
/** ZSTD_clampCParams() :
|
||||
* make CParam values within valid range.
|
||||
* @return : valid CParams */
|
||||
static ZSTD_compressionParameters
|
||||
ZSTD_clampCParams(ZSTD_compressionParameters cParams)
|
||||
{
|
||||
return ZSTD_rust_params_clampCParams(cParams);
|
||||
}
|
||||
|
||||
/** ZSTD_cycleLog() :
|
||||
* condition for correct operation : hashLog > 1 */
|
||||
U32 ZSTD_cycleLog(U32 hashLog, ZSTD_strategy strat)
|
||||
{
|
||||
return ZSTD_rust_params_cycleLog(hashLog, (int)strat);
|
||||
}
|
||||
|
||||
U32 ZSTD_getCParamsExclusionMask(void);
|
||||
|
||||
/** ZSTD_adjustCParams_internal() :
|
||||
|
||||
@@ -1136,7 +1136,7 @@ pub extern "C" fn ZSTD_defaultCLevel() -> c_int {
|
||||
}
|
||||
|
||||
/* Keep existing Rust parameter-module callers source-compatible while the
|
||||
* public C symbols are owned directly by these Rust leaves. */
|
||||
* C symbols are owned directly by these Rust leaves. */
|
||||
pub(crate) use ZSTD_defaultCLevel as ZSTD_rust_params_defaultCLevel;
|
||||
|
||||
/// Returns bounds for the seven core compression parameters and compression
|
||||
@@ -1148,7 +1148,7 @@ pub extern "C" fn ZSTD_rust_params_getBounds(param: c_int) -> ZSTD_bounds {
|
||||
|
||||
/// Checks the seven fields of `ZSTD_compressionParameters`.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ZSTD_rust_params_checkCParams(cparams: ZSTD_compressionParameters) -> usize {
|
||||
pub extern "C" fn ZSTD_checkCParams(cparams: ZSTD_compressionParameters) -> usize {
|
||||
check_cparams(cparams)
|
||||
}
|
||||
|
||||
@@ -1166,7 +1166,7 @@ pub extern "C" fn ZSTD_rust_params_assertEqualCParams(
|
||||
|
||||
/// Clamps the seven fields of `ZSTD_compressionParameters` to public bounds.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ZSTD_rust_params_clampCParams(
|
||||
pub extern "C" fn ZSTD_clampCParams(
|
||||
cparams: ZSTD_compressionParameters,
|
||||
) -> ZSTD_compressionParameters {
|
||||
clamp_cparams(cparams)
|
||||
@@ -1174,10 +1174,16 @@ pub extern "C" fn ZSTD_rust_params_clampCParams(
|
||||
|
||||
/// C ABI for `ZSTD_cycleLog()`.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ZSTD_rust_params_cycleLog(hashLog: u32, strategy: c_int) -> u32 {
|
||||
pub extern "C" fn ZSTD_cycleLog(hashLog: u32, strategy: c_int) -> u32 {
|
||||
cycle_log(hashLog, strategy)
|
||||
}
|
||||
|
||||
/* Keep existing Rust parameter-module callers source-compatible while the
|
||||
* C symbols are owned directly by these Rust leaves. */
|
||||
pub(crate) use ZSTD_checkCParams as ZSTD_rust_params_checkCParams;
|
||||
pub(crate) use ZSTD_clampCParams as ZSTD_rust_params_clampCParams;
|
||||
pub(crate) use ZSTD_cycleLog as ZSTD_rust_params_cycleLog;
|
||||
|
||||
/// C ABI for private `ZSTD_getCParamRowSize()`.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ZSTD_rust_params_getCParamRowSize(
|
||||
|
||||
Reference in New Issue
Block a user