Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@ int alt_clock_gettime (int clock_id, timespec *ts)
{
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service (mach_host_self (), clock_id, &cclock);
clock_get_time (cclock, &mts);
mach_port_deallocate (mach_task_self (), cclock);
kern_return_t kr;

kr = host_get_clock_service (mach_host_self (), clock_id, &cclock);
if (kr == KERN_SUCCESS) {
kr = clock_get_time (cclock, &mts);
mach_port_deallocate (mach_task_self (), cclock);
}

if (kr != KERN_SUCCESS)
return -1;

ts->tv_sec = mts.tv_sec;
ts->tv_nsec = mts.tv_nsec;
return 0;
Expand Down
Loading