1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 19:54:57 +08:00

on OS X, use SYSTEM_CLOCK, not CALENDAR_CLOCK

Analogously to using `CLOCK_MONOTONIC` on Linux to time events in favor of `CLOCK_REALTIME`, `SYSTEM_CLOCK` should be used in favor of `CALENDAR_CLOCK` on OS X.

Ref: http://stackoverflow.com/questions/11680461/monotonic-clock-on-osx
This commit is contained in:
Patrick O'Leary 2015-11-10 17:28:45 -06:00
parent 98f1c31e81
commit c5b4bbd181

View File

@ -85,7 +85,7 @@ 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;