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

Merge aca89433a3c87a3c1a89ca0f9261ee33076c8954 into 69e0372cf0d3796e84ce9a09aff1d74496f68720

This commit is contained in:
ajackson-adi 2022-06-15 11:04:56 +12:00 committed by GitHub
commit d33b4daf0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,7 +82,12 @@ timespec
MillisecondTimer::timespec_now ()
{
timespec time;
# ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
// OS X does not have clock_gettime until 10.12, use clock_get_time
#if defined(__MACH__) && MAC_OS_X_VERSION_MIN_REQUIRED < 101200
if (__builtin_available(macOS 10.12, *)) {
clock_gettime(CLOCK_MONOTONIC, &time);
}
else {
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
@ -90,6 +95,7 @@ MillisecondTimer::timespec_now ()
mach_port_deallocate(mach_task_self(), cclock);
time.tv_sec = mts.tv_sec;
time.tv_nsec = mts.tv_nsec;
}
# else
clock_gettime(CLOCK_MONOTONIC, &time);
# endif