Skip to content

Commit

Permalink
evtimer_gettime was broken on MacOs.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmn64k committed Feb 8, 2009
1 parent cf5f386 commit 9f4d2b0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions evloop/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ int
evtimer_gettime(struct timespec *ts)
{
uint64_t nsecs;
static double nsmul;
static mach_timebase_info_data_t nsratio = { 0, 0 };
if (nsratio.denom == 0)
if (nsratio.denom == 0) {
mach_timebase_info(&nsratio);
nsecs = mach_absolute_time() * nsratio.numer / nsratio.denom;
ts->tv_sec = nsecs / 1000000000;
ts->tv_nsec = nsecs - ts->tv_sec * 1000000000;
nsmul = (double)nsratio.numer / nsratio.denom;
}
nsecs = mach_absolute_time() * nsmul;
ts->tv_sec = nsecs / 1000000000ULL;
ts->tv_nsec = nsecs - ts->tv_sec * 1000000000ULL;
return 0;
}

Expand Down

0 comments on commit 9f4d2b0

Please sign in to comment.