mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-23 04:04:54 +08:00
Merge pull request #116 from pao/patch-1
Use CLOCK_MONOTONIC (Linux)/SYSTEM_CLOCK (OS X) to time select()
This commit is contained in:
commit
e12d81eadf
@ -85,13 +85,13 @@ MillisecondTimer::timespec_now ()
|
||||
# ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t mts;
|
||||
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
|
||||
clock_get_time(cclock, &mts);
|
||||
mach_port_deallocate(mach_task_self(), cclock);
|
||||
time.tv_sec = mts.tv_sec;
|
||||
time.tv_nsec = mts.tv_nsec;
|
||||
# else
|
||||
clock_gettime(CLOCK_REALTIME, &time);
|
||||
clock_gettime(CLOCK_MONOTONIC, &time);
|
||||
# endif
|
||||
return time;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user