I have a function that I'm porting from Linux to MacOSX that makes use of clock_gettime with CLOCK_THREAD_CPUTIME_ID to measure the time spent on the process. I found this code on the internet that would give me the equivalent to CLOCK_REALTIME:
#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
clock_serv_t cclock;
mach_timespec_t ts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
clock_get_time(cclock, &ts);
mach_port_deallocate(mach_task_self(), cclock);
#else
timespec ts;
clock_gettime(CLOCK_REALTIME, ts);
#endif
But I can't seem to figure out an easy way to get the clock_gettime(CLOCK_THREAD_CPUTIME_ID, ts); Anyone knows a good solution for this?