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:
@@ -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