diff --git a/programs/fileio.c b/programs/fileio.c index cca96365e..5688d43b9 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -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) diff --git a/rust/src/fileio_prefs.rs b/rust/src/fileio_prefs.rs index 5c3b9c128..4f5bafd2e 100644 --- a/rust/src/fileio_prefs.rs +++ b/rust/src/fileio_prefs.rs @@ -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();