diff options
Diffstat (limited to 'darwin/Platform.c')
-rw-r--r-- | darwin/Platform.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/darwin/Platform.c b/darwin/Platform.c index 3842fddc..ca8df611 100644 --- a/darwin/Platform.c +++ b/darwin/Platform.c @@ -37,6 +37,10 @@ in the source distribution for its full text. #include "zfs/ZfsArcMeter.h" #include "zfs/ZfsCompressedArcMeter.h" +#ifdef HAVE_HOST_GET_CLOCK_SERVICE +#include <mach/clock.h> +#include <mach/mach.h> +#endif #ifdef HAVE_MACH_MACH_TIME_H #include <mach/mach_time.h> #endif @@ -405,3 +409,23 @@ void Platform_getBattery(double* percent, ACPresence* isOnAC) { CFRelease(list); CFRelease(power_sources); } + +void Platform_gettime_monotonic(uint64_t* msec) { + +#ifdef HAVE_HOST_GET_CLOCK_SERVICE + + clock_serv_t cclock; + mach_timespec_t mts; + + host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock); + clock_get_time(cclock, &mts); + mach_port_deallocate(mach_task_self(), cclock); + + *msec = ((uint64_t)mts.tv_sec * 1000) + ((uint64_t)mts.tv_nsec / 1000000); + +#else + + Generic_gettime_monotomic(msec); + +#endif +} |