Skip to content

Commit 99ad0cf

Browse files
committed
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.
1 parent 67f5c71 commit 99ad0cf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

utils.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ static uint64_t semu_timer_clocksource(uint64_t freq)
4848
static mach_timebase_info_data_t t;
4949
if (t.denom == 0)
5050
(void) mach_timebase_info(&t);
51-
return mult_frac(mach_absolute_time() * freq, t.numer, t.denom);
51+
return mult_frac(mult_frac(mach_absolute_time(), freq, 1e9), t.numer,
52+
t.denom);
5253
#else
5354
return time(0) * freq;
5455
#endif

0 commit comments

Comments
 (0)