refactor(compress): expose sequence statistics leaves from Rust
The C definitions of ZSTD_get1BlockSummary() and ZSTD_resetSeqStore() only forwarded their arguments to Rust, so they duplicated the ABI boundary without contributing assertions, private-state adaptation, or C-only policy. Make Rust provide the existing internal symbols directly and remove only the corresponding C declarations and forwarding bodies. Keep crate-local aliases for the current compressor-module imports; they are Rust name aliases and do not add the former ABI symbols back. No other statistics leaf is included. Test Plan: - `ulimit -v 41943040; cc -Ilib -Ilib/common -Ilib/compress -Ilib/decompress -Ilib/dictBuilder -Ilib/legacy -Ilib/deprecated -Ilib/zstd -fsyntax-only lib/compress/zstd_compress.c` -- passed - `ulimit -v 41943040; cargo +nightly fmt --manifest-path rust/Cargo.toml --all -- --check` -- passed - `git diff --check` and `git diff --cached --check` -- passed - No cargo builds, make commands, or tests run, per request
This commit is contained in:
@@ -2137,10 +2137,7 @@ void ZSTD_rust_confirmRepcodesAndEntropyTables(
|
||||
ZSTD_compressedBlockState_t** nextCBlock);
|
||||
void ZSTD_rust_storeLastLiterals(SeqStore_t* seqStorePtr,
|
||||
const BYTE* anchor, size_t lastLLSize);
|
||||
void ZSTD_rust_resetSeqStore(SeqStore_t* ssPtr);
|
||||
void ZSTD_rust_validateSeqStore(const SeqStore_t* seqStore, U32 minMatch);
|
||||
BlockSummary ZSTD_rust_get1BlockSummary(const ZSTD_Sequence* seqs,
|
||||
size_t nbSeqs);
|
||||
U32 ZSTD_rust_resolveRepcodeToRawOffset(const U32 rep[ZSTD_REP_NUM],
|
||||
U32 offBase, U32 ll0);
|
||||
size_t ZSTD_rust_loadCEntropy(ZSTD_compressedBlockState_t* bs, void* workspace,
|
||||
@@ -5355,11 +5352,6 @@ ZSTD_BlockCompressor_f ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_Para
|
||||
return selectedCompressor;
|
||||
}
|
||||
|
||||
void ZSTD_resetSeqStore(SeqStore_t* ssPtr)
|
||||
{
|
||||
ZSTD_rust_resetSeqStore(ssPtr);
|
||||
}
|
||||
|
||||
static size_t ZSTD_rust_externalSequenceProducer_transfer(
|
||||
void* context, ZSTD_SequencePosition* seqPos,
|
||||
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||
@@ -8540,11 +8532,6 @@ ZSTD_compressSequencesAndLiterals(ZSTD_CCtx* cctx,
|
||||
litCapacity, decompressedSize);
|
||||
}
|
||||
|
||||
BlockSummary ZSTD_get1BlockSummary(const ZSTD_Sequence* seqs, size_t nbSeqs)
|
||||
{
|
||||
return ZSTD_rust_get1BlockSummary(seqs, nbSeqs);
|
||||
}
|
||||
|
||||
/*====== Finalize ======*/
|
||||
|
||||
static ZSTD_inBuffer inBuffer_forEndFlush(const ZSTD_CStream* zcs)
|
||||
|
||||
@@ -227,7 +227,7 @@ pub unsafe extern "C" fn ZSTD_rust_convertSequencesNoRepcodes(
|
||||
/// `ZSTD_get1BlockSummary()`; the delimiter is identified by zero match
|
||||
/// length and contributes its literal length to the totals.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn ZSTD_rust_get1BlockSummary(
|
||||
pub unsafe extern "C" fn ZSTD_get1BlockSummary(
|
||||
seqs: *const ZSTD_Sequence,
|
||||
nb_seqs: usize,
|
||||
) -> BlockSummary {
|
||||
@@ -261,6 +261,10 @@ pub unsafe extern "C" fn ZSTD_rust_get1BlockSummary(
|
||||
invalid()
|
||||
}
|
||||
|
||||
// Keep the old crate-local names for callers in the compressor module. These
|
||||
// aliases do not create additional ABI symbols.
|
||||
pub(crate) use ZSTD_get1BlockSummary as ZSTD_rust_get1BlockSummary;
|
||||
|
||||
/// Estimates the literal-section size used by the block splitter.
|
||||
unsafe fn estimate_block_size_literal(
|
||||
literals: *const u8,
|
||||
@@ -1128,13 +1132,15 @@ pub unsafe extern "C" fn ZSTD_rust_storeLastLiterals(
|
||||
|
||||
/// Resets the sequence and literal cursors for a new block.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn ZSTD_rust_resetSeqStore(seq_store: *mut SeqStore_t) {
|
||||
pub unsafe extern "C" fn ZSTD_resetSeqStore(seq_store: *mut SeqStore_t) {
|
||||
let seq_store = unsafe { &mut *seq_store };
|
||||
seq_store.lit = seq_store.litStart;
|
||||
seq_store.sequences = seq_store.sequencesStart;
|
||||
seq_store.longLengthType = 0;
|
||||
}
|
||||
|
||||
pub(crate) use ZSTD_resetSeqStore as ZSTD_rust_resetSeqStore;
|
||||
|
||||
/// Returns the sum of all literal and match lengths in an external sequence
|
||||
/// buffer, without looking for a block delimiter.
|
||||
#[no_mangle]
|
||||
@@ -2682,7 +2688,7 @@ mod tests {
|
||||
},
|
||||
];
|
||||
|
||||
let summary = unsafe { ZSTD_rust_get1BlockSummary(sequences.as_ptr(), sequences.len()) };
|
||||
let summary = unsafe { ZSTD_get1BlockSummary(sequences.as_ptr(), sequences.len()) };
|
||||
|
||||
assert_eq!(summary.nbSequences, 2);
|
||||
assert_eq!(summary.blockSize, 12);
|
||||
@@ -2697,13 +2703,13 @@ mod tests {
|
||||
matchLength: 4,
|
||||
rep: 0,
|
||||
}];
|
||||
let missing = unsafe { ZSTD_rust_get1BlockSummary(sequences.as_ptr(), sequences.len()) };
|
||||
let missing = unsafe { ZSTD_get1BlockSummary(sequences.as_ptr(), sequences.len()) };
|
||||
assert_eq!(
|
||||
missing.nbSequences,
|
||||
ERROR(ZstdErrorCode::ExternalSequencesInvalid)
|
||||
);
|
||||
|
||||
let empty = unsafe { ZSTD_rust_get1BlockSummary(std::ptr::null(), 0) };
|
||||
let empty = unsafe { ZSTD_get1BlockSummary(std::ptr::null(), 0) };
|
||||
assert_eq!(
|
||||
empty.nbSequences,
|
||||
ERROR(ZstdErrorCode::ExternalSequencesInvalid)
|
||||
@@ -3369,7 +3375,7 @@ mod tests {
|
||||
longLengthPos: 11,
|
||||
};
|
||||
|
||||
unsafe { ZSTD_rust_resetSeqStore(&mut seq_store) };
|
||||
unsafe { ZSTD_resetSeqStore(&mut seq_store) };
|
||||
|
||||
assert_eq!(seq_store.sequences, sequences_start);
|
||||
assert_eq!(seq_store.lit, literals_start);
|
||||
|
||||
Reference in New Issue
Block a user