5 #include <sys/_types/_timespec.h>
7 #include <mach/clock.h>
8 #include <mach/mach_time.h>
15 #define TIMER_ABSTIME -1
16 #define CLOCK_REALTIME CALENDAR_CLOCK
17 #define CLOCK_MONOTONIC SYSTEM_CLOCK
27 #include <mach/mach_time.h>
29 #define MT_NANO (+1.0E-9)
30 #define MT_GIGA UINT64_C(1000000000)
33 static double mt_timebase = 0.0;
34 static uint64_t mt_timestart = 0;
39 kern_return_t retval = KERN_SUCCESS;
43 mach_timebase_info_data_t tb = { 0 };
44 mach_timebase_info(&tb);
45 mt_timebase = tb.numer;
46 mt_timebase /= tb.denom;
47 mt_timestart = mach_absolute_time();
50 double diff = (mach_absolute_time() - mt_timestart) * mt_timebase;
52 tp->tv_nsec = diff - (tp->tv_sec *
MT_GIGA);
59 host_get_clock_service(mach_host_self(), clk_id, &cclock);
60 retval = clock_get_time(cclock, &mts);
61 mach_port_deallocate(mach_task_self(), cclock);
63 tp->tv_sec = mts.tv_sec;
64 tp->tv_nsec = mts.tv_nsec;