+/*
+ * Approximation of NTP time of day to clock monotonic correlation,
+ * taken at start of trace. Keep the measurement that took the less time
+ * to complete, thus removing imprecision caused by preemption.
+ */
+static
+uint64_t measure_clock_offset(void)
+{
+ int i;
+ struct offset_sample offset_best_sample = {
+ .offset = 0,
+ .measure_delta = UINT64_MAX,
+ };
+
+ for (i = 0; i < NR_CLOCK_OFFSET_SAMPLES; i++) {
+ if (measure_single_clock_offset(&offset_best_sample)) {
+ return 0;
+ }
+ }
+ return offset_best_sample.offset;
+}