feat(cli): move file info aggregation to Rust
Mirror fileio.c's private fileInfo_t with a checked repr(C) ABI and aggregate totals, flags, and file counts through an output-pointer shim. Preserve zeroed non-aggregate fields and use wrapping arithmetic for the original integer operations. Test Plan: cargo test --manifest-path rust/cli/Cargo.toml --no-default-features --features cli,compression,decompression,benchmark (106 passed); cargo clippy --all-targets with the same features; make -B -C programs -j2 zstd zstd-small zstd-frugal; make -C tests -j2 test-cli-tests (41 passed).
This commit is contained in:
+22
-14
@@ -2780,6 +2780,28 @@ typedef struct {
|
||||
unsigned dictID;
|
||||
} fileInfo_t;
|
||||
|
||||
typedef char FIO_rust_file_info_compressed_size_offset[
|
||||
(offsetof(fileInfo_t, compressedSize) == sizeof(U64)) ? 1 : -1];
|
||||
typedef char FIO_rust_file_info_window_size_offset[
|
||||
(offsetof(fileInfo_t, windowSize) == 2 * sizeof(U64)) ? 1 : -1];
|
||||
typedef char FIO_rust_file_info_frame_counts_offset[
|
||||
(offsetof(fileInfo_t, numActualFrames) == 3 * sizeof(U64)) ? 1 : -1];
|
||||
typedef char FIO_rust_file_info_checksum_offset[
|
||||
(offsetof(fileInfo_t, checksum) == 3 * sizeof(U64) + 4 * sizeof(int)) ? 1 : -1];
|
||||
typedef char FIO_rust_file_info_size[
|
||||
(sizeof(fileInfo_t) == (sizeof(void*) == 8
|
||||
? 7 * sizeof(U64)
|
||||
: 13 * sizeof(U32))) ? 1 : -1];
|
||||
|
||||
void FIO_rust_addFInfo(fileInfo_t* output, fileInfo_t const* fi1, fileInfo_t const* fi2);
|
||||
|
||||
static fileInfo_t FIO_addFInfo(fileInfo_t fi1, fileInfo_t fi2)
|
||||
{
|
||||
fileInfo_t total;
|
||||
FIO_rust_addFInfo(&total, &fi1, &fi2);
|
||||
return total;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
info_success=0,
|
||||
info_frame_error=1,
|
||||
@@ -2978,20 +3000,6 @@ displayInfo(const char* inFileName, const fileInfo_t* info, int displayLevel)
|
||||
}
|
||||
}
|
||||
|
||||
static fileInfo_t FIO_addFInfo(fileInfo_t fi1, fileInfo_t fi2)
|
||||
{
|
||||
fileInfo_t total;
|
||||
memset(&total, 0, sizeof(total));
|
||||
total.numActualFrames = fi1.numActualFrames + fi2.numActualFrames;
|
||||
total.numSkippableFrames = fi1.numSkippableFrames + fi2.numSkippableFrames;
|
||||
total.compressedSize = fi1.compressedSize + fi2.compressedSize;
|
||||
total.decompressedSize = fi1.decompressedSize + fi2.decompressedSize;
|
||||
total.decompUnavailable = fi1.decompUnavailable | fi2.decompUnavailable;
|
||||
total.usesCheck = fi1.usesCheck & fi2.usesCheck;
|
||||
total.nbFiles = fi1.nbFiles + fi2.nbFiles;
|
||||
return total;
|
||||
}
|
||||
|
||||
static int
|
||||
FIO_listFile(fileInfo_t* total, const char* inFileName, int displayLevel)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user