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:
+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.
|
||||
#[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 };
|
||||
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.
|
||||
#[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 should_display = ctx.nbFilesProcessed >= 1 && ctx.nbFilesTotal > 1;
|
||||
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
|
||||
/// wins the max scan exactly as it does in the original C implementation.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn FIO_rust_getLargestFileSize(
|
||||
pub unsafe extern "C" fn FIO_getLargestFileSize(
|
||||
file_names: *const *const c_char,
|
||||
nb_files: c_uint,
|
||||
) -> u64 {
|
||||
@@ -2976,7 +2976,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
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]
|
||||
@@ -2990,7 +2990,7 @@ mod tests {
|
||||
let names = [smaller.as_ptr(), larger.as_ptr()];
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
@@ -3009,7 +3009,7 @@ mod tests {
|
||||
let missing = CString::new(missing_path.to_string_lossy().as_bytes()).unwrap();
|
||||
let names = [missing.as_ptr()];
|
||||
assert_eq!(
|
||||
unsafe { FIO_rust_getLargestFileSize(names.as_ptr(), 1) },
|
||||
unsafe { FIO_getLargestFileSize(names.as_ptr(), 1) },
|
||||
UTIL_FILESIZE_UNKNOWN
|
||||
);
|
||||
}
|
||||
@@ -3973,17 +3973,17 @@ mod tests {
|
||||
|
||||
for display_level in [0, 2] {
|
||||
FIO_setNotificationLevel(display_level);
|
||||
assert_eq!(unsafe { FIO_rust_shouldDisplayFileSummary(&ctx) }, 1);
|
||||
assert_eq!(unsafe { FIO_shouldDisplayFileSummary(&ctx) }, 1);
|
||||
}
|
||||
|
||||
ctx.nbFilesTotal = 2;
|
||||
for display_level in [0, 2] {
|
||||
FIO_setNotificationLevel(display_level);
|
||||
assert_eq!(unsafe { FIO_rust_shouldDisplayFileSummary(&ctx) }, 0);
|
||||
assert_eq!(unsafe { FIO_shouldDisplayFileSummary(&ctx) }, 0);
|
||||
}
|
||||
|
||||
FIO_setNotificationLevel(3);
|
||||
assert_eq!(unsafe { FIO_rust_shouldDisplayFileSummary(&ctx) }, 1);
|
||||
assert_eq!(unsafe { FIO_shouldDisplayFileSummary(&ctx) }, 1);
|
||||
|
||||
FIO_setNotificationLevel(2);
|
||||
}
|
||||
@@ -3995,7 +3995,7 @@ mod tests {
|
||||
for display_level in [0, 2, 3] {
|
||||
FIO_setNotificationLevel(display_level);
|
||||
assert_eq!(
|
||||
unsafe { FIO_rust_shouldDisplayMultipleFileSummary(&ctx) },
|
||||
unsafe { FIO_shouldDisplayMultipleFileSummary(&ctx) },
|
||||
0
|
||||
);
|
||||
}
|
||||
@@ -4004,7 +4004,7 @@ mod tests {
|
||||
for display_level in [0, 2, 3] {
|
||||
FIO_setNotificationLevel(display_level);
|
||||
assert_eq!(
|
||||
unsafe { FIO_rust_shouldDisplayMultipleFileSummary(&ctx) },
|
||||
unsafe { FIO_shouldDisplayMultipleFileSummary(&ctx) },
|
||||
1
|
||||
);
|
||||
}
|
||||
@@ -4012,13 +4012,13 @@ mod tests {
|
||||
ctx.nbFilesProcessed = 2;
|
||||
FIO_setNotificationLevel(0);
|
||||
assert_eq!(
|
||||
unsafe { FIO_rust_shouldDisplayMultipleFileSummary(&ctx) },
|
||||
unsafe { FIO_shouldDisplayMultipleFileSummary(&ctx) },
|
||||
1
|
||||
);
|
||||
|
||||
ctx.nbFilesTotal = 1;
|
||||
assert_eq!(
|
||||
unsafe { FIO_rust_shouldDisplayMultipleFileSummary(&ctx) },
|
||||
unsafe { FIO_shouldDisplayMultipleFileSummary(&ctx) },
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user