Skip to content

Commit

Permalink
Fix clock source unit when building on macOS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chiangkd committed Sep 11, 2024
1 parent 67f5c71 commit 99ad0cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 99ad0cf

Please sign in to comment.