- if (type == CLOCK_REALTIME)
- return clock_gettime_realtime(tv);
- else
- return clock_gettime_monotonic(tv);
+ int retval = -1;
+ mach_timespec_t mts;
+
+ switch (type) {
+ case CLOCK_REALTIME:
+ retval = clock_get_time(clock_realtime, &mts);
+ break;
+ case CLOCK_MONOTONIC:
+ retval = clock_get_time(clock_monotonic, &mts);
+ break;
+ default:
+ goto out;
+ }
+
+ tv->tv_sec = mts.tv_sec;
+ tv->tv_nsec = mts.tv_nsec;
+out:
+ return retval;