feat(decompress): move block decoder wrappers into Rust
Move the hidden fullbench block-decoder entrypoints and the public ZSTD_decompressBlock compatibility wrapper into Rust. The C translation unit now only projects the configuration-dependent private DCtx fields into the Rust block context, preserving the existing ABI and decoder feature modes. Test Plan: - cargo test --manifest-path rust/Cargo.toml --all-targets -- --test-threads=1 - cargo clippy --manifest-path rust/Cargo.toml --tests -- -D warnings - make -B -C lib -j2 lib - make -B -C tests -j2 test-rust-lib-smoke - make -B -C tests -j2 test-cli-tests
This commit is contained in:
@@ -102,73 +102,13 @@ static ZSTD_rustBlockCtx ZSTD_rust_block_context(ZSTD_DCtx* dctx)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
size_t ZSTD_rust_decodeLiteralsBlock_wrapper(
|
||||
ZSTD_rustBlockCtx* ctx,
|
||||
const void* src, size_t srcSize,
|
||||
void* dst, size_t dstCapacity);
|
||||
size_t ZSTD_rust_decodeSeqHeaders(
|
||||
ZSTD_rustBlockCtx* ctx, int* nbSeqPtr,
|
||||
const void* src, size_t srcSize);
|
||||
size_t ZSTD_rust_decompressBlock_internal(
|
||||
ZSTD_rustBlockCtx* ctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize, int streaming);
|
||||
void ZSTD_rust_checkContinuity(
|
||||
ZSTD_rustBlockCtx* ctx, const void* dst, size_t dstSize);
|
||||
size_t ZSTD_rust_decompressBlock_deprecated(
|
||||
ZSTD_rustBlockCtx* ctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize);
|
||||
/* Rust owns the hidden fullbench wrappers, the block decoder's internal
|
||||
* entrypoints, and the public ZSTD_decompressBlock ABI. Keep only this
|
||||
* private-context projection in C: the layout is configuration-dependent and
|
||||
* must continue to be assembled next to ZSTD_DCtx. */
|
||||
void ZSTD_rust_block_context_init(ZSTD_rustBlockCtx* out, ZSTD_DCtx* dctx);
|
||||
|
||||
/* Hidden declaration for fullbench. */
|
||||
size_t ZSTD_decodeLiteralsBlock_wrapper(ZSTD_DCtx* dctx,
|
||||
const void* src, size_t srcSize,
|
||||
void* dst, size_t dstCapacity);
|
||||
size_t ZSTD_decodeLiteralsBlock_wrapper(ZSTD_DCtx* dctx,
|
||||
const void* src, size_t srcSize,
|
||||
void* dst, size_t dstCapacity)
|
||||
void ZSTD_rust_block_context_init(ZSTD_rustBlockCtx* out, ZSTD_DCtx* dctx)
|
||||
{
|
||||
ZSTD_rustBlockCtx ctx = ZSTD_rust_block_context(dctx);
|
||||
return ZSTD_rust_decodeLiteralsBlock_wrapper(
|
||||
&ctx, src, srcSize, dst, dstCapacity);
|
||||
}
|
||||
|
||||
size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
|
||||
const void* src, size_t srcSize)
|
||||
{
|
||||
ZSTD_rustBlockCtx ctx = ZSTD_rust_block_context(dctx);
|
||||
return ZSTD_rust_decodeSeqHeaders(&ctx, nbSeqPtr, src, srcSize);
|
||||
}
|
||||
|
||||
size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize,
|
||||
const streaming_operation streaming)
|
||||
{
|
||||
ZSTD_rustBlockCtx ctx = ZSTD_rust_block_context(dctx);
|
||||
return ZSTD_rust_decompressBlock_internal(&ctx, dst, dstCapacity, src, srcSize,
|
||||
(int)streaming);
|
||||
}
|
||||
|
||||
void ZSTD_checkContinuity(ZSTD_DCtx* dctx, const void* dst, size_t dstSize)
|
||||
{
|
||||
ZSTD_rustBlockCtx ctx = ZSTD_rust_block_context(dctx);
|
||||
ZSTD_rust_checkContinuity(&ctx, dst, dstSize);
|
||||
}
|
||||
|
||||
size_t ZSTD_decompressBlock_deprecated(ZSTD_DCtx* dctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize)
|
||||
{
|
||||
ZSTD_rustBlockCtx ctx = ZSTD_rust_block_context(dctx);
|
||||
return ZSTD_rust_decompressBlock_deprecated(&ctx,
|
||||
dst, dstCapacity, src, srcSize);
|
||||
}
|
||||
|
||||
/* NOTE: Must just wrap ZSTD_decompressBlock_deprecated(). */
|
||||
size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize)
|
||||
{
|
||||
return ZSTD_decompressBlock_deprecated(dctx, dst, dstCapacity, src, srcSize);
|
||||
*out = ZSTD_rust_block_context(dctx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user