+
+ /*
+ * If Linux is using the tsc clock on non-synced processors,
+ * sometimes time can appear to drift backwards. Fix that up.
+ */
+ if (last_tv_valid) {
+ if (tp->tv_sec < last_tv.tv_sec)
+ tp->tv_sec = last_tv.tv_sec;
+ else if (last_tv.tv_sec == tp->tv_sec &&
+ tp->tv_usec < last_tv.tv_usec)
+ tp->tv_usec = last_tv.tv_usec;
+ }
+ last_tv_valid = 1;
+ memcpy(&last_tv, tp, sizeof(*tp));
+}
+
+void fio_gtod_init(void)
+{
+ fio_tv = smalloc(sizeof(struct timeval));
+ assert(fio_tv);
+}
+
+void fio_gtod_update(void)
+{
+ gettimeofday(fio_tv, NULL);