refactor(compress): expose block policy leaves from Rust
Export ZSTD_useTargetCBlockSize and ZSTD_blockSplitterEnabled directly from Rust under their existing caller symbols. Remove the redundant C forwarding wrappers while preserving diagnostics, ABI signatures, and parameter layout. Test Plan: - worker capped format, C syntax, and diff checks - parent capped root clippy and native build - parent capped upstream make -j1 -C tests test - parent capped CLI clippy and tests
This commit is contained in:
@@ -2025,8 +2025,8 @@ 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_rust_useTargetCBlockSize(const ZSTD_CCtx_params* cctxParams);
|
||||
int ZSTD_rust_blockSplitterEnabled(ZSTD_CCtx_params* cctxParams);
|
||||
int ZSTD_useTargetCBlockSize(const ZSTD_CCtx_params* cctxParams);
|
||||
int ZSTD_blockSplitterEnabled(ZSTD_CCtx_params* cctxParams);
|
||||
|
||||
#define ZSTD_RUST_CCTX_PARAMS_ASSERT(name, condition) \
|
||||
typedef char name[(condition) ? 1 : -1]
|
||||
@@ -5363,26 +5363,8 @@ static void ZSTD_reduceIndex (ZSTD_MatchState_t* ms, ZSTD_CCtx_params const* par
|
||||
|
||||
/* ZSTD_seqToCodes() lives in rust/src/zstd_compress_stats.rs. */
|
||||
|
||||
/* ZSTD_useTargetCBlockSize():
|
||||
* Returns if target compressed block size param is being used.
|
||||
* If used, compression will do best effort to make a compressed block size to be around targetCBlockSize.
|
||||
* Returns 1 if true, 0 otherwise. */
|
||||
static int ZSTD_useTargetCBlockSize(const ZSTD_CCtx_params* cctxParams)
|
||||
{
|
||||
DEBUGLOG(5, "ZSTD_useTargetCBlockSize (targetCBlockSize=%zu)", cctxParams->targetCBlockSize);
|
||||
return ZSTD_rust_useTargetCBlockSize(cctxParams);
|
||||
}
|
||||
|
||||
/* ZSTD_blockSplitterEnabled():
|
||||
* Returns if block splitting param is being used
|
||||
* If used, compression will do best effort to split a block in order to improve compression ratio.
|
||||
* At the time this function is called, the parameter must be finalized.
|
||||
* Returns 1 if true, 0 otherwise. */
|
||||
static int ZSTD_blockSplitterEnabled(ZSTD_CCtx_params* cctxParams)
|
||||
{
|
||||
DEBUGLOG(5, "ZSTD_blockSplitterEnabled (postBlockSplitter=%d)", cctxParams->postBlockSplitter);
|
||||
return ZSTD_rust_blockSplitterEnabled(cctxParams);
|
||||
}
|
||||
/* ZSTD_useTargetCBlockSize() and ZSTD_blockSplitterEnabled() are Rust-owned
|
||||
* ABI leaves. Their diagnostics remain at the call boundary below. */
|
||||
|
||||
/* ZSTD_buildSequencesStatistics() and the ZSTD_entropyCompressSeqStore*()
|
||||
* implementations live in rust/src/zstd_compress_stats.rs. The wrappers
|
||||
@@ -6001,7 +5983,9 @@ static void ZSTD_compressContinue_prepare(
|
||||
context->frameChunkState.savings = (S64)cctx->consumedSrcSize - (S64)cctx->producedCSize;
|
||||
context->frameChunkState.preBlockSplitterLevel = cctx->appliedParams.preBlockSplitter_level;
|
||||
context->frameChunkState.strategy = (int)cctx->appliedParams.cParams.strategy;
|
||||
DEBUGLOG(5, "ZSTD_useTargetCBlockSize (targetCBlockSize=%zu)", cctx->appliedParams.targetCBlockSize);
|
||||
context->frameChunkState.useTargetCBlockSize = ZSTD_useTargetCBlockSize(&cctx->appliedParams);
|
||||
DEBUGLOG(5, "ZSTD_blockSplitterEnabled (postBlockSplitter=%d)", cctx->appliedParams.postBlockSplitter);
|
||||
context->frameChunkState.blockSplitterEnabled = ZSTD_blockSplitterEnabled(&cctx->appliedParams);
|
||||
context->frameChunkState.checksumFlag = cctx->appliedParams.fParams.checksumFlag;
|
||||
context->frameChunkState.endingStage = (int)ZSTDcs_ending;
|
||||
|
||||
@@ -363,9 +363,7 @@ unsafe fn use_target_c_block_size(cctx_params: *const ZSTD_CCtx_params) -> c_int
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn ZSTD_rust_useTargetCBlockSize(
|
||||
cctx_params: *const ZSTD_CCtx_params,
|
||||
) -> c_int {
|
||||
pub unsafe extern "C" fn ZSTD_useTargetCBlockSize(cctx_params: *const ZSTD_CCtx_params) -> c_int {
|
||||
unsafe { use_target_c_block_size(cctx_params) }
|
||||
}
|
||||
|
||||
@@ -377,9 +375,7 @@ unsafe fn block_splitter_enabled(cctx_params: *mut ZSTD_CCtx_params) -> c_int {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn ZSTD_rust_blockSplitterEnabled(
|
||||
cctx_params: *mut ZSTD_CCtx_params,
|
||||
) -> c_int {
|
||||
pub unsafe extern "C" fn ZSTD_blockSplitterEnabled(cctx_params: *mut ZSTD_CCtx_params) -> c_int {
|
||||
unsafe { block_splitter_enabled(cctx_params) }
|
||||
}
|
||||
|
||||
@@ -1344,10 +1340,10 @@ mod tests {
|
||||
let params = storage.as_mut_ptr();
|
||||
unsafe {
|
||||
(*params).targetCBlockSize = 0;
|
||||
assert_eq!(ZSTD_rust_useTargetCBlockSize(params), 0);
|
||||
assert_eq!(ZSTD_useTargetCBlockSize(params), 0);
|
||||
|
||||
(*params).targetCBlockSize = 1;
|
||||
assert_eq!(ZSTD_rust_useTargetCBlockSize(params), 1);
|
||||
assert_eq!(ZSTD_useTargetCBlockSize(params), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1357,10 +1353,10 @@ mod tests {
|
||||
let params = storage.as_mut_ptr();
|
||||
unsafe {
|
||||
(*params).postBlockSplitter = ZSTD_RUST_PS_ENABLE;
|
||||
assert_eq!(ZSTD_rust_blockSplitterEnabled(params), 1);
|
||||
assert_eq!(ZSTD_blockSplitterEnabled(params), 1);
|
||||
|
||||
(*params).postBlockSplitter = PS_DISABLE;
|
||||
assert_eq!(ZSTD_rust_blockSplitterEnabled(params), 0);
|
||||
assert_eq!(ZSTD_blockSplitterEnabled(params), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user