]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
rust/timer: Define NANOSECONDS_PER_SECOND binding as u64
authorZhao Liu <zhao1.liu@intel.com>
Mon, 14 Apr 2025 14:49:39 +0000 (22:49 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 2 May 2025 15:37:46 +0000 (17:37 +0200)
NANOSECONDS_PER_SECOND is often used in operations with get_ns(), which
currently returns a u64.

Therefore, define a new NANOSECONDS_PER_SECOND binding is with u64 type
to eliminate unnecessary type conversions (from u32 to u64).

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250414144943.1112885-6-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/qemu-api/src/timer.rs

index f0b04ef95d7ebc6c91c7a03c4f3148e140d6315b..e769f8bc910d81718093b1a5ddfa610ab61e4ff9 100644 (file)
@@ -121,3 +121,5 @@ impl ClockType {
 pub const CLOCK_VIRTUAL: ClockType = ClockType {
     id: QEMUClockType::QEMU_CLOCK_VIRTUAL,
 };
+
+pub const NANOSECONDS_PER_SECOND: u64 = 1000000000;