From 99ad0cf55d91419e9bf9efb2dcf42077cf71245c Mon Sep 17 00:00:00 2001 From: chiangkd Date: Wed, 11 Sep 2024 02:48:02 +0800 Subject: [PATCH] Fix clock source unit when building on macOS The current implementation of 'semu_timer_clocksource()' returns the clock source in nanoseconds, but it should return in seconds for correct system integration. Adjust the function on macOS to divide the return value by 1e9, ensuring the clock source is provided in seconds. --- utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils.c b/utils.c index 5546383..3f81a81 100644 --- a/utils.c +++ b/utils.c @@ -48,7 +48,8 @@ static uint64_t semu_timer_clocksource(uint64_t freq) static mach_timebase_info_data_t t; if (t.denom == 0) (void) mach_timebase_info(&t); - return mult_frac(mach_absolute_time() * freq, t.numer, t.denom); + return mult_frac(mult_frac(mach_absolute_time(), freq, 1e9), t.numer, + t.denom); #else return time(0) * freq; #endif