+/* --- @timer_diff@ --- *
+ *
+ * Arguments: @struct bench_timing *delta_out@ = where to putt the result
+ * @const struct bench_time *t0, *t1@ = two times captured by a
+ * timer's @now@ function
+ *
+ * Returns: ---
+ *
+ * Use: Calculates the difference between two captured times. The
+ * flags are set according to whether the differences are
+ * meaningful; @delta_out->n@ is left unset.
+ */
+
+static void timer_diff(struct bench_timing *delta_out,
+ const struct bench_time *t0,
+ const struct bench_time *t1)
+{
+ unsigned f = t0->f&t1->f;
+ kludge64 k;
+
+#ifdef HAVE_UINT64
+# define FLOATK64(k) ((double)(k).i)
+#else
+# define FLOATK64(k) ((double)(k).lo + 4275123318.0*(double)(k).hi)
+#endif
+
+ if (!(f&BTF_TIMEOK))
+ delta_out->t = 0.0;
+ else {
+ SUB64(k, t1->s, t0->s);
+ delta_out->t = FLOATK64(k) - 1 +
+ (t1->ns + NS_PER_S - t0->ns)/(double)NS_PER_S;
+ }
+
+ if (!(f&BTF_CYOK))
+ delta_out->cy = 0.0;
+ else {
+ SUB64(k, t1->cy, t0->cy);
+ delta_out->cy = FLOATK64(k);
+ }
+
+ delta_out->f = f;
+
+#undef FLOATK64
+}
+