refactor(cli): move highbit policy leaf to Rust

Export FIO_highbit64 directly from Rust under the existing caller symbol and
remove the C forwarding wrapper. Preserve the nonzero-input contract and add
boundary tests for the scalar policy leaf.

Test Plan:
- capped nightly rustfmt check
- capped root clippy with all targets and -D warnings
- capped native make -j1
- capped upstream make -j1 -C tests test
- capped CLI clippy and 185 CLI tests

All integrated checks ran at the combined working-tree tip under a serial
40 GiB virtual-memory cap. Standalone root Rust unit linking remains
unavailable because the crate imports C-owned bridge symbols.
This commit is contained in:
2026-07-20 10:12:02 +02:00
parent 539608cac1
commit 9110af5f9e
2 changed files with 6 additions and 14 deletions
+2 -11
View File
@@ -332,7 +332,8 @@ static int FIO_shouldDisplayMultipleFileSummary(FIO_ctx_t const* fCtx)
* The declarations in fileio.h remain the C ABI shims while file-I/O
* orchestration and diagnostics stay here. */
int FIO_rust_checkFilenameCollisions(const char** filenameTable, unsigned nbFiles);
unsigned FIO_rust_highbit64(unsigned long long v);
/* FIO_highbit64() is a Rust-owned scalar policy leaf. */
unsigned FIO_highbit64(unsigned long long v);
unsigned long long FIO_rust_getLargestFileSize(const char** inFileNames, unsigned nbFiles);
int FIO_rust_adjustParamsForPatchFromMode(FIO_prefs_t* prefs,
ZSTD_compressionParameters* comprParams,
@@ -978,16 +979,6 @@ int FIO_checkFilenameCollisions(const char** filenameTable, unsigned nbFiles) {
return FIO_rust_checkFilenameCollisions(filenameTable, nbFiles);
}
/* FIO_highbit64() :
* gives position of highest bit.
* note : only works for v > 0 !
*/
static unsigned FIO_highbit64(unsigned long long v)
{
assert(v != 0);
return FIO_rust_highbit64(v);
}
static void FIO_adjustMemLimitForPatchFromMode(FIO_prefs_t* const prefs,
unsigned long long const dictSize,
unsigned long long const maxSrcFileSize)
+4 -3
View File
@@ -1680,7 +1680,7 @@ fn highbit64(value: u64) -> c_uint {
}
#[no_mangle]
pub extern "C" fn FIO_rust_highbit64(value: u64) -> c_uint {
pub extern "C" fn FIO_highbit64(value: u64) -> c_uint {
highbit64(value)
}
@@ -3001,8 +3001,9 @@ mod tests {
#[test]
fn largest_file_size_scan_preserves_large_values_and_errors() {
assert_eq!(largest_file_size([0, 1u64 << 63, 7]), 1u64 << 63);
assert_eq!(FIO_rust_highbit64(1u64 << 63), 63);
assert_eq!(FIO_rust_highbit64(u64::MAX), 63);
assert_eq!(FIO_highbit64(1), 0);
assert_eq!(FIO_highbit64(1u64 << 63), 63);
assert_eq!(FIO_highbit64(u64::MAX), 63);
let missing_path = temporary_file_path("missing");
let missing = CString::new(missing_path.to_string_lossy().as_bytes()).unwrap();