fix(fileio): keep zstd display callback optional
The Rust zstd stream callback initially called a display helper defined only in programs/fileio.c. The CLI linked successfully, but the upstream C tests also link the shared Rust archive without the CLI translation unit, leaving that symbol unresolved even though those tests do not use the fileio projection. Keep the diagnostic implementation in C, but pass it as an optional final field of the zstd compression projection. Rust invokes it from the stream loop after a successful codec call, using the same directive, input position, input size, and produced-output count as the former C callback. Test projections can leave the hook empty, so the reusable Rust archive has no dependency on CLI-only symbols while the production CLI preserves its level-6 diagnostic. Test Plan: - `cargo +nightly fmt --manifest-path rust/Cargo.toml --all` -- passed - `cc -fsyntax-only -Werror=incompatible-pointer-types -Ilib -Ilib/common -Ilib/compress -Ilib/decompress -Ilib/dict -Ilib/legacy programs/fileio.c` -- passed - `git diff --check` and `git diff --cached --check` -- passed - `make -j1 -C tests test` reached the suite but failed before this fix on the now-removed unresolved `FIO_rust_zstd_compressStreamDisplay` reference
This commit is contained in:
@@ -1331,6 +1331,8 @@ typedef int (*FIO_rust_zstd_compress_stream_fn)(
|
||||
unsigned char* output, size_t outputSize,
|
||||
size_t* inputPosAfter, size_t* outputProduced,
|
||||
size_t* toFlushNow, size_t* zstdResult);
|
||||
typedef void (*FIO_rust_zstd_compress_display_fn)(
|
||||
int directive, size_t inputPos, size_t inputSize, size_t outputProduced);
|
||||
int FIO_rust_zstd_compressStream(
|
||||
void* opaque, const char* srcFileName, int directive,
|
||||
const unsigned char* input, size_t inputSize, size_t inputPos,
|
||||
@@ -1357,6 +1359,7 @@ typedef struct {
|
||||
FIO_rust_zstd_sparse_write_end_fn sparseWriteEnd;
|
||||
FIO_rust_zstd_compress_stream_fn compressStream;
|
||||
FIO_rust_zstd_iteration_fn iteration;
|
||||
FIO_rust_zstd_compress_display_fn compressStreamDisplay;
|
||||
} FIO_rust_zstd_compress_projection_t;
|
||||
|
||||
int FIO_rust_compressZstdFrame(
|
||||
@@ -2759,6 +2762,7 @@ FIO_rust_compressZstdCallback(void* fCtx, void* prefs, void* ress,
|
||||
projection.sparseWriteEnd = FIO_rust_zstd_sparseWriteEnd;
|
||||
projection.compressStream = FIO_rust_zstd_compressStream;
|
||||
projection.iteration = FIO_rust_zstd_iteration;
|
||||
projection.compressStreamDisplay = FIO_rust_zstd_compressStreamDisplay;
|
||||
|
||||
DISPLAYLEVEL(6, "compression using zstd format \n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user