From: Carl Worth Date: Tue, 12 Nov 2013 18:30:18 +0000 (-0800) Subject: Use consistent argument order for subtract functions and macros. X-Git-Url: https://git.cworth.org/git?p=fips;a=commitdiff_plain;h=39b71bb28a1ea89b694fe12f1d2d0e914ae528d7 Use consistent argument order for subtract functions and macros. We were calling subtract_timestamp() on the line just before TIMESPEC_DIFF() but with reversed argument order in the two. This could obviously lead to convention. So we stick adopt the (a - b) convention for both, (as well as the name "subtract" for both). --- diff --git a/metrics.c b/metrics.c index c52bf2e..7b2a558 100644 --- a/metrics.c +++ b/metrics.c @@ -819,9 +819,9 @@ metrics_collect_available (metrics_t *metrics) } } -/* Return the difference from ts0 to ts1 as floating-point seconds. */ -#define TIMESPEC_DIFF(ts0, ts1) (double) (ts1.tv_sec - ts0.tv_sec + \ - (ts1.tv_nsec - ts0.tv_nsec) / 1e9) +/* Subtract timespec values: Return (a - b) in seconds as a double. */ +#define SUBTRACT_TIMESPEC(a, b) (double) (a.tv_sec - b.tv_sec + \ + (a.tv_nsec - b.tv_nsec) / 1e9) void metrics_end_frame_pre_swap (metrics_t *metrics) @@ -864,7 +864,8 @@ metrics_end_frame_pre_swap (metrics_t *metrics) latency_ns = subtract_timestamp (swap_end_timestamp, metrics->swap_begin_timestamp); - cpu_time = TIMESPEC_DIFF (metrics->previous_cpu_time_ts, metrics->cpu_time_ts); + cpu_time = SUBTRACT_TIMESPEC (metrics->cpu_time_ts, + metrics->previous_cpu_time_ts); /* We've waited one frame to ensure we have a timestamp * result. So the time we've actually measured here is