feat(compress): move frame chunk checksum into Rust
Project the frame-chunk XXH64 state as a typed pointer so Rust owns the checksum update while preserving the existing pre-block ordering and error behavior. Remove the now-redundant C checksum callback and shrink the cross-language frame-chunk state layout assertions. Test Plan: - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo fmt --all -- --check - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --lib zstd_compress::tests::frame_chunk -- --nocapture - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --all-targets -- -D warnings - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test - ulimit -v 41943040; make -j1 - ulimit -v 41943040; make -j1 -C tests test-zstream ZSTREAM_TESTTIME=-T2s - ulimit -v 41943040; make -j1 -C tests test-fuzzer FUZZERTEST=-T3s FUZZER_FLAGS=--no-big-tests
This commit is contained in:
@@ -821,13 +821,10 @@ typedef size_t (*ZSTD_rust_frameChunkCompress_f)(void* context,
|
||||
const void* src,
|
||||
size_t srcSize,
|
||||
U32 lastBlock);
|
||||
typedef void (*ZSTD_rust_frameChunkChecksum_f)(void* state,
|
||||
const void* src,
|
||||
size_t srcSize);
|
||||
typedef struct {
|
||||
void* callbackContext;
|
||||
void* tmpWorkspace;
|
||||
void* checksumState;
|
||||
XXH64_state_t* checksumState;
|
||||
int* isFirstBlock;
|
||||
ZSTD_compressionStage_e* stage;
|
||||
size_t tmpWkspSize;
|
||||
@@ -843,7 +840,6 @@ typedef struct {
|
||||
ZSTD_rust_frameChunkCompress_f compressTarget;
|
||||
ZSTD_rust_frameChunkCompress_f compressSplit;
|
||||
ZSTD_rust_frameChunkCompress_f compressInternal;
|
||||
ZSTD_rust_frameChunkChecksum_f updateChecksum;
|
||||
} ZSTD_rust_frameChunkState;
|
||||
size_t ZSTD_rust_compressFrameChunk(
|
||||
const ZSTD_rust_frameChunkState* state,
|
||||
@@ -874,7 +870,7 @@ typedef char ZSTD_rust_frame_chunk_state_layout[
|
||||
&& offsetof(ZSTD_rust_frameChunkState, prepareState)
|
||||
== 7 * sizeof(void*) + sizeof(S64) + 6 * sizeof(int)
|
||||
&& sizeof(ZSTD_rust_frameChunkState)
|
||||
== 12 * sizeof(void*) + sizeof(S64) + 6 * sizeof(int))
|
||||
== 11 * sizeof(void*) + sizeof(S64) + 6 * sizeof(int))
|
||||
? 1 : -1];
|
||||
|
||||
/* The high-level continue/block entry points are Rust-owned. This projection
|
||||
@@ -5575,12 +5571,6 @@ static size_t ZSTD_rust_frameChunk_compressInternal(
|
||||
1 /* frame */);
|
||||
}
|
||||
|
||||
static void ZSTD_rust_frameChunk_updateChecksum(
|
||||
void* state, const void* src, size_t srcSize)
|
||||
{
|
||||
(void)XXH64_update((XXH64_state_t*)state, src, srcSize);
|
||||
}
|
||||
|
||||
/*! ZSTD_compress_frameChunk() :
|
||||
* Compress a chunk of data into one or multiple blocks.
|
||||
* All blocks will be terminated, all input will be consumed.
|
||||
@@ -5623,7 +5613,6 @@ static size_t ZSTD_compress_frameChunk(ZSTD_CCtx* cctx,
|
||||
state.compressTarget = ZSTD_rust_frameChunk_compressTarget;
|
||||
state.compressSplit = ZSTD_rust_frameChunk_compressSplit;
|
||||
state.compressInternal = ZSTD_rust_frameChunk_compressInternal;
|
||||
state.updateChecksum = ZSTD_rust_frameChunk_updateChecksum;
|
||||
return ZSTD_rust_compressFrameChunk(
|
||||
&state, dst, dstCapacity, src, srcSize, lastFrameChunk);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user