- uint32_t low;
- uint32_t high;
- uint64_t retval;
- __asm__ volatile ("rdtsc\n" : "=a" (low), "=d" (high));
-
- retval = high;
- retval <<= 32;
- return retval | low;
-}
-
-#endif /* __i386 || __x86_64 */
-
-#ifdef __PPC__
+ struct timespec ts;
+ u64 retval;
+ union lttng_timespec *lts = (union lttng_timespec *) &ts;
+
+ clock_gettime(ust_clock_source, &ts);
+ /*
+ * Clock source can change when loading the binary (tracectl.c)
+ * so we must check if the clock source has changed before
+ * returning the correct value
+ */
+ if (likely(ust_clock_source == CLOCK_TRACE)) {
+ retval = lts->lttng_ts;
+ } else { /* CLOCK_MONOTONIC */
+ retval = ts.tv_sec;
+ retval *= 1000000000;
+ retval += ts.tv_nsec;
+ }