5#ifdef HAVE_CLOCK_GETTIME
14#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
16static int monotonic_works;
24 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts)) {
33 if (monotonic_works) {
36 if (0 > clock_gettime(CLOCK_MONOTONIC, &ts)) {
41 tv->tv_sec = ts.tv_sec;
42 tv->tv_usec = ts.tv_nsec / 1000;
51#elif defined(HAVE_CLOCK_GET_TIME)
54#include <mach/clock.h>
55#include <mach/mach_error.h>
57static clock_serv_t mach_clock;
64 mach_timespec_t aTime;
66 ret = host_get_clock_service(mach_host_self(), REALTIME_CLOCK, &mach_clock);
68 if (
ret != KERN_SUCCESS) {
74 ret = clock_get_time(mach_clock, &aTime);
76 if (
ret != KERN_SUCCESS) {
87 mach_timespec_t aTime;
89 ret = clock_get_time(mach_clock, &aTime);
91 if (
ret != KERN_SUCCESS) {
96 tv->tv_sec = aTime.tv_sec;
97 tv->tv_usec = aTime.tv_nsec / 1000;
gettimeofday(bool $as_float=false)
int fpm_clock_get(struct timeval *tv)