refactor(cli): expose summary policy leaves from Rust
Export the file-summary predicates and largest-file-size scan directly from Rust under their existing caller symbols. Remove the redundant C forwarding wrappers while preserving pointer contracts, assertions, return widths, and filesystem behavior. Test Plan: - worker capped format, C syntax, and diff checks - parent capped root clippy and native build - parent capped upstream make -j1 -C tests test - parent capped CLI clippy and tests
This commit is contained in:
+3
-19
@@ -289,8 +289,8 @@ typedef char FIO_rust_compression_params_size[
|
|||||||
(sizeof(ZSTD_compressionParameters)
|
(sizeof(ZSTD_compressionParameters)
|
||||||
== 7 * sizeof(unsigned)) ? 1 : -1];
|
== 7 * sizeof(unsigned)) ? 1 : -1];
|
||||||
|
|
||||||
int FIO_rust_shouldDisplayFileSummary(const FIO_ctx_t* fCtx);
|
int FIO_shouldDisplayFileSummary(const FIO_ctx_t* fCtx);
|
||||||
int FIO_rust_shouldDisplayMultipleFileSummary(const FIO_ctx_t* fCtx);
|
int FIO_shouldDisplayMultipleFileSummary(const FIO_ctx_t* fCtx);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
FIO_RUST_MULTI_FILES_ACTION_PROCEED = 0,
|
FIO_RUST_MULTI_FILES_ACTION_PROCEED = 0,
|
||||||
@@ -309,17 +309,6 @@ int FIO_rust_multiFilesConcatAction(int nbFilesTotal,
|
|||||||
int displayLevel,
|
int displayLevel,
|
||||||
int displayLevelCutoff);
|
int displayLevelCutoff);
|
||||||
|
|
||||||
static int FIO_shouldDisplayFileSummary(FIO_ctx_t const* fCtx)
|
|
||||||
{
|
|
||||||
return FIO_rust_shouldDisplayFileSummary(fCtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int FIO_shouldDisplayMultipleFileSummary(FIO_ctx_t const* fCtx)
|
|
||||||
{
|
|
||||||
return FIO_rust_shouldDisplayMultipleFileSummary(fCtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*-*************************************
|
/*-*************************************
|
||||||
* Parameters: Initialization
|
* Parameters: Initialization
|
||||||
***************************************/
|
***************************************/
|
||||||
@@ -334,7 +323,7 @@ static int FIO_shouldDisplayMultipleFileSummary(FIO_ctx_t const* fCtx)
|
|||||||
int FIO_rust_checkFilenameCollisions(const char** filenameTable, unsigned nbFiles);
|
int FIO_rust_checkFilenameCollisions(const char** filenameTable, unsigned nbFiles);
|
||||||
/* FIO_highbit64() is a Rust-owned scalar policy leaf. */
|
/* FIO_highbit64() is a Rust-owned scalar policy leaf. */
|
||||||
unsigned FIO_highbit64(unsigned long long v);
|
unsigned FIO_highbit64(unsigned long long v);
|
||||||
unsigned long long FIO_rust_getLargestFileSize(const char** inFileNames, unsigned nbFiles);
|
unsigned long long FIO_getLargestFileSize(const char** inFileNames, unsigned nbFiles);
|
||||||
int FIO_rust_adjustParamsForPatchFromMode(FIO_prefs_t* prefs,
|
int FIO_rust_adjustParamsForPatchFromMode(FIO_prefs_t* prefs,
|
||||||
ZSTD_compressionParameters* comprParams,
|
ZSTD_compressionParameters* comprParams,
|
||||||
unsigned long long dictSize,
|
unsigned long long dictSize,
|
||||||
@@ -3492,11 +3481,6 @@ FIO_determineCompressedName(const char* srcFileName, const char* outDirName, con
|
|||||||
return FIO_rust_determineCompressedName(srcFileName, outDirName, suffix);
|
return FIO_rust_determineCompressedName(srcFileName, outDirName, suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long long FIO_getLargestFileSize(const char** inFileNames, unsigned nbFiles)
|
|
||||||
{
|
|
||||||
return FIO_rust_getLargestFileSize(inFileNames, nbFiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FIO_ctx_t* fCtx;
|
FIO_ctx_t* fCtx;
|
||||||
FIO_prefs_t* prefs;
|
FIO_prefs_t* prefs;
|
||||||
|
|||||||
+13
-13
@@ -1635,7 +1635,7 @@ fn should_display_file_summary(ctx: &FIO_ctx_t) -> bool {
|
|||||||
|
|
||||||
/// Return whether the single-file summary should be displayed.
|
/// Return whether the single-file summary should be displayed.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn FIO_rust_shouldDisplayFileSummary(ctx: *const FIO_ctx_t) -> c_int {
|
pub unsafe extern "C" fn FIO_shouldDisplayFileSummary(ctx: *const FIO_ctx_t) -> c_int {
|
||||||
let ctx = unsafe { &*ctx };
|
let ctx = unsafe { &*ctx };
|
||||||
c_int::from(should_display_file_summary(ctx))
|
c_int::from(should_display_file_summary(ctx))
|
||||||
}
|
}
|
||||||
@@ -1644,7 +1644,7 @@ pub unsafe extern "C" fn FIO_rust_shouldDisplayFileSummary(ctx: *const FIO_ctx_t
|
|||||||
///
|
///
|
||||||
/// The assertion mirrors the original C helper's invariant exactly.
|
/// The assertion mirrors the original C helper's invariant exactly.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn FIO_rust_shouldDisplayMultipleFileSummary(ctx: *const FIO_ctx_t) -> c_int {
|
pub unsafe extern "C" fn FIO_shouldDisplayMultipleFileSummary(ctx: *const FIO_ctx_t) -> c_int {
|
||||||
let ctx = unsafe { &*ctx };
|
let ctx = unsafe { &*ctx };
|
||||||
let should_display = ctx.nbFilesProcessed >= 1 && ctx.nbFilesTotal > 1;
|
let should_display = ctx.nbFilesProcessed >= 1 && ctx.nbFilesTotal > 1;
|
||||||
assert!(should_display || should_display_file_summary(ctx) || ctx.nbFilesProcessed == 0);
|
assert!(should_display || should_display_file_summary(ctx) || ctx.nbFilesProcessed == 0);
|
||||||
@@ -1829,7 +1829,7 @@ where
|
|||||||
/// In particular, an unknown size is `UTIL_FILESIZE_UNKNOWN` and therefore
|
/// In particular, an unknown size is `UTIL_FILESIZE_UNKNOWN` and therefore
|
||||||
/// wins the max scan exactly as it does in the original C implementation.
|
/// wins the max scan exactly as it does in the original C implementation.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn FIO_rust_getLargestFileSize(
|
pub unsafe extern "C" fn FIO_getLargestFileSize(
|
||||||
file_names: *const *const c_char,
|
file_names: *const *const c_char,
|
||||||
nb_files: c_uint,
|
nb_files: c_uint,
|
||||||
) -> u64 {
|
) -> u64 {
|
||||||
@@ -2976,7 +2976,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn largest_file_size_scan_handles_empty_input() {
|
fn largest_file_size_scan_handles_empty_input() {
|
||||||
assert_eq!(unsafe { FIO_rust_getLargestFileSize(ptr::null(), 0) }, 0);
|
assert_eq!(unsafe { FIO_getLargestFileSize(ptr::null(), 0) }, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -2990,7 +2990,7 @@ mod tests {
|
|||||||
let names = [smaller.as_ptr(), larger.as_ptr()];
|
let names = [smaller.as_ptr(), larger.as_ptr()];
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
unsafe { FIO_rust_getLargestFileSize(names.as_ptr(), names.len() as c_uint) },
|
unsafe { FIO_getLargestFileSize(names.as_ptr(), names.len() as c_uint) },
|
||||||
11
|
11
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -3009,7 +3009,7 @@ mod tests {
|
|||||||
let missing = CString::new(missing_path.to_string_lossy().as_bytes()).unwrap();
|
let missing = CString::new(missing_path.to_string_lossy().as_bytes()).unwrap();
|
||||||
let names = [missing.as_ptr()];
|
let names = [missing.as_ptr()];
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
unsafe { FIO_rust_getLargestFileSize(names.as_ptr(), 1) },
|
unsafe { FIO_getLargestFileSize(names.as_ptr(), 1) },
|
||||||
UTIL_FILESIZE_UNKNOWN
|
UTIL_FILESIZE_UNKNOWN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3973,17 +3973,17 @@ mod tests {
|
|||||||
|
|
||||||
for display_level in [0, 2] {
|
for display_level in [0, 2] {
|
||||||
FIO_setNotificationLevel(display_level);
|
FIO_setNotificationLevel(display_level);
|
||||||
assert_eq!(unsafe { FIO_rust_shouldDisplayFileSummary(&ctx) }, 1);
|
assert_eq!(unsafe { FIO_shouldDisplayFileSummary(&ctx) }, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.nbFilesTotal = 2;
|
ctx.nbFilesTotal = 2;
|
||||||
for display_level in [0, 2] {
|
for display_level in [0, 2] {
|
||||||
FIO_setNotificationLevel(display_level);
|
FIO_setNotificationLevel(display_level);
|
||||||
assert_eq!(unsafe { FIO_rust_shouldDisplayFileSummary(&ctx) }, 0);
|
assert_eq!(unsafe { FIO_shouldDisplayFileSummary(&ctx) }, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
FIO_setNotificationLevel(3);
|
FIO_setNotificationLevel(3);
|
||||||
assert_eq!(unsafe { FIO_rust_shouldDisplayFileSummary(&ctx) }, 1);
|
assert_eq!(unsafe { FIO_shouldDisplayFileSummary(&ctx) }, 1);
|
||||||
|
|
||||||
FIO_setNotificationLevel(2);
|
FIO_setNotificationLevel(2);
|
||||||
}
|
}
|
||||||
@@ -3995,7 +3995,7 @@ mod tests {
|
|||||||
for display_level in [0, 2, 3] {
|
for display_level in [0, 2, 3] {
|
||||||
FIO_setNotificationLevel(display_level);
|
FIO_setNotificationLevel(display_level);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
unsafe { FIO_rust_shouldDisplayMultipleFileSummary(&ctx) },
|
unsafe { FIO_shouldDisplayMultipleFileSummary(&ctx) },
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -4004,7 +4004,7 @@ mod tests {
|
|||||||
for display_level in [0, 2, 3] {
|
for display_level in [0, 2, 3] {
|
||||||
FIO_setNotificationLevel(display_level);
|
FIO_setNotificationLevel(display_level);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
unsafe { FIO_rust_shouldDisplayMultipleFileSummary(&ctx) },
|
unsafe { FIO_shouldDisplayMultipleFileSummary(&ctx) },
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -4012,13 +4012,13 @@ mod tests {
|
|||||||
ctx.nbFilesProcessed = 2;
|
ctx.nbFilesProcessed = 2;
|
||||||
FIO_setNotificationLevel(0);
|
FIO_setNotificationLevel(0);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
unsafe { FIO_rust_shouldDisplayMultipleFileSummary(&ctx) },
|
unsafe { FIO_shouldDisplayMultipleFileSummary(&ctx) },
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.nbFilesTotal = 1;
|
ctx.nbFilesTotal = 1;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
unsafe { FIO_rust_shouldDisplayMultipleFileSummary(&ctx) },
|
unsafe { FIO_shouldDisplayMultipleFileSummary(&ctx) },
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user