refactor(decompress): remove redundant dictionary bridge
Call the authoritative DDict constructor directly from the Rust decompression policy after converting the shared repr(C) allocator projection. Remove the C forwarding declaration and wrapper so dictionary creation no longer crosses an unnecessary Rust-to-C-to-C boundary, while compile-time size and alignment checks keep the allocator conversion tied to the ABI contract. Test Plan: - `ulimit -v 41943040; cargo +nightly fmt --manifest-path rust/Cargo.toml --all -- --check` - `ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings` - `ulimit -v 41943040; make -j1` - `ulimit -v 41943040; make -j1 -C tests test` - `ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/cli/Cargo.toml --all-targets -- -D warnings` - `ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/cli/Cargo.toml --all-targets` The integrated checks ran at the combined working-tree tip, including the parallel MT checksum seam that remains as the next commit. Standalone root Rust unit linking remains unavailable because the crate imports C-owned bridge symbols without a Cargo build/link setup.
This commit is contained in:
@@ -142,10 +142,6 @@ size_t ZSTD_rust_decompress_stack(void* dst, size_t dstCapacity,
|
|||||||
size_t ZSTD_rust_decompress_stack_context(ZSTD_DCtx* dctx,
|
size_t ZSTD_rust_decompress_stack_context(ZSTD_DCtx* dctx,
|
||||||
void* dst, size_t dstCapacity,
|
void* dst, size_t dstCapacity,
|
||||||
const void* src, size_t srcSize);
|
const void* src, size_t srcSize);
|
||||||
ZSTD_DDict* ZSTD_rust_create_ddict(const void* dict, size_t dictSize,
|
|
||||||
ZSTD_dictLoadMethod_e dictLoadMethod,
|
|
||||||
ZSTD_dictContentType_e dictContentType,
|
|
||||||
ZSTD_customMem customMem);
|
|
||||||
unsigned ZSTD_rust_legacy_support(void);
|
unsigned ZSTD_rust_legacy_support(void);
|
||||||
|
|
||||||
#if ZSTD_TRACE
|
#if ZSTD_TRACE
|
||||||
@@ -291,15 +287,6 @@ size_t ZSTD_rust_decompress_stack(void* dst, size_t dstCapacity,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ZSTD_DDict* ZSTD_rust_create_ddict(const void* dict, size_t dictSize,
|
|
||||||
ZSTD_dictLoadMethod_e dictLoadMethod,
|
|
||||||
ZSTD_dictContentType_e dictContentType,
|
|
||||||
ZSTD_customMem customMem)
|
|
||||||
{
|
|
||||||
return ZSTD_createDDict_advanced(dict, dictSize, dictLoadMethod,
|
|
||||||
dictContentType, customMem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZSTD_rust_dctx_trace_view(ZSTD_DCtx* dctx,
|
void ZSTD_rust_dctx_trace_view(ZSTD_DCtx* dctx,
|
||||||
ZSTD_rustDctxTraceView* out)
|
ZSTD_rustDctxTraceView* out)
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-10
@@ -22,7 +22,7 @@ use crate::mem::{MEM_32bits, MEM_readLE16, MEM_readLE32, MEM_readLE64};
|
|||||||
use crate::xxhash::{XXH64_digest, XXH64_reset, XXH64_state_t, XXH64_update, XXH64};
|
use crate::xxhash::{XXH64_digest, XXH64_reset, XXH64_state_t, XXH64_update, XXH64};
|
||||||
use crate::zstd_ddict::{
|
use crate::zstd_ddict::{
|
||||||
ZSTD_DDict, ZSTD_DDict_dictContent, ZSTD_DDict_dictSize, ZSTD_copyDDictParameters,
|
ZSTD_DDict, ZSTD_DDict_dictContent, ZSTD_DDict_dictSize, ZSTD_copyDDictParameters,
|
||||||
ZSTD_freeDDict, ZSTD_getDictID_fromDDict,
|
ZSTD_createDDict_advanced, ZSTD_freeDDict, ZSTD_getDictID_fromDDict,
|
||||||
};
|
};
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
@@ -304,6 +304,8 @@ const _: () = {
|
|||||||
assert!(offset_of!(ZSTD_rustDctxView, static_size) == 29 * size_of::<usize>());
|
assert!(offset_of!(ZSTD_rustDctxView, static_size) == 29 * size_of::<usize>());
|
||||||
assert!(offset_of!(ZSTD_rustDctxView, dctx_size) == 67 * size_of::<usize>());
|
assert!(offset_of!(ZSTD_rustDctxView, dctx_size) == 67 * size_of::<usize>());
|
||||||
assert!(size_of::<ZSTD_rustDctxView>() == 68 * size_of::<usize>());
|
assert!(size_of::<ZSTD_rustDctxView>() == 68 * size_of::<usize>());
|
||||||
|
assert!(size_of::<ZSTD_customMem>() == size_of::<crate::zstd_ddict::ZSTD_customMem>());
|
||||||
|
assert!(align_of::<ZSTD_customMem>() == align_of::<crate::zstd_ddict::ZSTD_customMem>());
|
||||||
assert!(align_of::<ZSTD_rustDctxView>() == align_of::<usize>());
|
assert!(align_of::<ZSTD_rustDctxView>() == align_of::<usize>());
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -352,13 +354,6 @@ unsafe extern "C" {
|
|||||||
src: *const c_void,
|
src: *const c_void,
|
||||||
src_size: usize,
|
src_size: usize,
|
||||||
) -> usize;
|
) -> usize;
|
||||||
fn ZSTD_rust_create_ddict(
|
|
||||||
dict: *const c_void,
|
|
||||||
dict_size: usize,
|
|
||||||
dict_load_method: c_int,
|
|
||||||
dict_content_type: c_int,
|
|
||||||
custom_mem: ZSTD_customMem,
|
|
||||||
) -> *mut ZSTD_DDict;
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
not(test),
|
not(test),
|
||||||
any(
|
any(
|
||||||
@@ -1719,6 +1714,11 @@ unsafe fn dctx_custom_mem(view: &ZSTD_rustDctxView) -> ZSTD_customMem {
|
|||||||
unsafe { field(view.custom_mem) }
|
unsafe { field(view.custom_mem) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
unsafe fn ddict_custom_mem(view: &ZSTD_rustDctxView) -> crate::zstd_ddict::ZSTD_customMem {
|
||||||
|
unsafe { std::mem::transmute(dctx_custom_mem(view)) }
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn dctx_ddict(view: &ZSTD_rustDctxView) -> *const ZSTD_DDict {
|
unsafe fn dctx_ddict(view: &ZSTD_rustDctxView) -> *const ZSTD_DDict {
|
||||||
unsafe { field(view.ddict) }
|
unsafe { field(view.ddict) }
|
||||||
@@ -3991,12 +3991,12 @@ pub unsafe extern "C" fn ZSTD_DCtx_loadDictionary_advanced(
|
|||||||
unsafe { clear_dict(&view) };
|
unsafe { clear_dict(&view) };
|
||||||
if !dict.is_null() && dict_size != 0 {
|
if !dict.is_null() && dict_size != 0 {
|
||||||
let ddict = unsafe {
|
let ddict = unsafe {
|
||||||
ZSTD_rust_create_ddict(
|
ZSTD_createDDict_advanced(
|
||||||
dict,
|
dict,
|
||||||
dict_size,
|
dict_size,
|
||||||
dict_load_method,
|
dict_load_method,
|
||||||
dict_content_type,
|
dict_content_type,
|
||||||
dctx_custom_mem(&view),
|
ddict_custom_mem(&view),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
if ddict.is_null() {
|
if ddict.is_null() {
|
||||||
|
|||||||
Reference in New Issue
Block a user