refactor(compress): expose compressed block reset from Rust
The compressed-block reset logic was already implemented in Rust, but the Rust export used a private bridge name and C retained a forwarding wrapper under the original ABI name. Export the original `ZSTD_reset_compressedBlockState` symbol directly from Rust, keep the `ZSTD_rust_resetCompressedBlockState` crate-local alias for existing Rust callers, and remove only the redundant C declaration and body. Private context-layout code and other C functions remain unchanged. Test Plan: - `git diff --check` -- passed. - `cc -std=c99 -Ilib -Ilib/common -Ilib/compress -Ilib/decompress -Ilib/dict -fsyntax-only lib/compress/zstd_compress.c` -- passed. - `cargo +nightly fmt --manifest-path rust/Cargo.toml --all -- --check` -- passed. - Cargo build/test and make were intentionally not run per the requested lightweight-only scope.
This commit is contained in:
@@ -2125,7 +2125,6 @@ size_t ZSTD_rust_buildBlockEntropyStats(
|
|||||||
int strategy, int disableLiteralCompression,
|
int strategy, int disableLiteralCompression,
|
||||||
ZSTD_entropyCTablesMetadata_t* entropyMetadata,
|
ZSTD_entropyCTablesMetadata_t* entropyMetadata,
|
||||||
void* workspace, size_t wkspSize);
|
void* workspace, size_t wkspSize);
|
||||||
void ZSTD_rust_resetCompressedBlockState(ZSTD_compressedBlockState_t* bs);
|
|
||||||
void ZSTD_rust_invalidateRepCodes(U32 rep[ZSTD_REP_NUM]);
|
void ZSTD_rust_invalidateRepCodes(U32 rep[ZSTD_REP_NUM]);
|
||||||
void ZSTD_rust_invalidateMatchState(
|
void ZSTD_rust_invalidateMatchState(
|
||||||
size_t endT, U32* lowLimit, U32* dictLimit,
|
size_t endT, U32* lowLimit, U32* dictLimit,
|
||||||
@@ -4163,11 +4162,6 @@ size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx)
|
|||||||
return ZSTD_rust_toFlushNow(&state);
|
return ZSTD_rust_toFlushNow(&state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZSTD_reset_compressedBlockState(ZSTD_compressedBlockState_t* bs)
|
|
||||||
{
|
|
||||||
ZSTD_rust_resetCompressedBlockState(bs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls, for this matchState reset, whether the tables need to be cleared /
|
* Controls, for this matchState reset, whether the tables need to be cleared /
|
||||||
* prepared for the coming compression (ZSTDcrp_makeClean), or whether the
|
* prepared for the coming compression (ZSTDcrp_makeClean), or whether the
|
||||||
|
|||||||
@@ -1089,7 +1089,7 @@ pub unsafe extern "C" fn ZSTD_rust_postProcessSequenceProducerResult(
|
|||||||
/// `ZSTD_reset_compressedBlockState()`. The caller must provide a valid
|
/// `ZSTD_reset_compressedBlockState()`. The caller must provide a valid
|
||||||
/// mutable compressed block state.
|
/// mutable compressed block state.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn ZSTD_rust_resetCompressedBlockState(
|
pub unsafe extern "C" fn ZSTD_reset_compressedBlockState(
|
||||||
block_state: *mut ZSTD_compressedBlockState_t,
|
block_state: *mut ZSTD_compressedBlockState_t,
|
||||||
) {
|
) {
|
||||||
let block_state = unsafe { &mut *block_state };
|
let block_state = unsafe { &mut *block_state };
|
||||||
@@ -1100,6 +1100,8 @@ pub unsafe extern "C" fn ZSTD_rust_resetCompressedBlockState(
|
|||||||
block_state.entropy.fse.litlength_repeatMode = FSE_REPEAT_NONE;
|
block_state.entropy.fse.litlength_repeatMode = FSE_REPEAT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) use ZSTD_reset_compressedBlockState as ZSTD_rust_resetCompressedBlockState;
|
||||||
|
|
||||||
/// Swaps the two C-owned block-state pointers after a block is confirmed.
|
/// Swaps the two C-owned block-state pointers after a block is confirmed.
|
||||||
///
|
///
|
||||||
/// The enclosing `ZSTD_blockState_t` contains C-only match-state storage, so
|
/// The enclosing `ZSTD_blockState_t` contains C-only match-state storage, so
|
||||||
@@ -3287,7 +3289,7 @@ mod tests {
|
|||||||
block_state.entropy.fse.matchlength_repeatMode = 1;
|
block_state.entropy.fse.matchlength_repeatMode = 1;
|
||||||
block_state.entropy.fse.litlength_repeatMode = 2;
|
block_state.entropy.fse.litlength_repeatMode = 2;
|
||||||
|
|
||||||
unsafe { ZSTD_rust_resetCompressedBlockState(&mut block_state) };
|
unsafe { ZSTD_reset_compressedBlockState(&mut block_state) };
|
||||||
|
|
||||||
assert_eq!(block_state.rep, [1, 4, 8]);
|
assert_eq!(block_state.rep, [1, 4, 8]);
|
||||||
assert_eq!(block_state.entropy.huf.repeatMode, HUF_REPEAT_NONE);
|
assert_eq!(block_state.entropy.huf.repeatMode, HUF_REPEAT_NONE);
|
||||||
|
|||||||
Reference in New Issue
Block a user