refactor(decompress): move default window policy to Rust
Route the configured default maximum window size through the Rust policy layer while keeping the build-time C configuration value and decoder layout in C. The explicit projection preserves overridden builds exactly and gives the scalar policy a focused null-input contract and tests. Test Plan: - git diff --check -- lib/decompress/zstd_decompress.c rust/src/zstd_decompress.rs - capped serial cargo check, clippy, nightly fmt, C syntax checks, and focused default-window tests (passed in the worker)
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
#include "zstd_ddict.h"
|
||||
|
||||
/* Keep the three public build-time tuning knobs in the C configuration domain.
|
||||
* Rust queries them through the small leaves below rather than baking a second
|
||||
* set of defaults into its source. */
|
||||
* Rust receives them through the small scalar-policy leaves below rather than
|
||||
* baking a second set of defaults into its source. */
|
||||
#ifndef ZSTD_HEAPMODE
|
||||
# define ZSTD_HEAPMODE 1
|
||||
#endif
|
||||
@@ -187,6 +187,16 @@ typedef char ZSTD_rust_decompress_stack_callbacks_layout[
|
||||
size_t ZSTD_rust_decompress_stack_action(
|
||||
const ZSTD_rustDecompressStackProjection* projection,
|
||||
const ZSTD_rustDecompressStackCallbacks* callbacks);
|
||||
typedef struct {
|
||||
size_t configured_max_window_size;
|
||||
} ZSTD_rustDefaultMaxWindowProjection;
|
||||
typedef char ZSTD_rust_default_max_window_projection_layout[
|
||||
(offsetof(ZSTD_rustDefaultMaxWindowProjection,
|
||||
configured_max_window_size) == 0
|
||||
&& sizeof(ZSTD_rustDefaultMaxWindowProjection) == sizeof(size_t))
|
||||
? 1 : -1];
|
||||
size_t ZSTD_rust_default_max_window_policy(
|
||||
const ZSTD_rustDefaultMaxWindowProjection* projection);
|
||||
typedef struct {
|
||||
int configured_max;
|
||||
} ZSTD_rustNoForwardProgressProjection;
|
||||
@@ -328,7 +338,10 @@ void ZSTD_dctx_init_platform(ZSTD_DCtx* dctx)
|
||||
|
||||
size_t ZSTD_rust_dctx_default_max_window_size(void)
|
||||
{
|
||||
return ZSTD_MAXWINDOWSIZE_DEFAULT;
|
||||
ZSTD_rustDefaultMaxWindowProjection const projection = {
|
||||
ZSTD_MAXWINDOWSIZE_DEFAULT
|
||||
};
|
||||
return ZSTD_rust_default_max_window_policy(&projection);
|
||||
}
|
||||
|
||||
int ZSTD_rust_no_forward_progress_max(void)
|
||||
|
||||
Reference in New Issue
Block a user