diff mbox

[API-NEXT,v6,6/6] api: time: change order of arguments for diff function

Message ID 1446721478-30656-7-git-send-email-ivan.khoronzhuk@linaro.org
State Superseded
Headers show

Commit Message

Ivan Khoronzhuk Nov. 5, 2015, 11:04 a.m. UTC
It's more convenient to pass parameters in order, like t2 - t1,
when t2 is supposed to be more.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 example/generator/odp_generator.c     |  2 +-
 include/odp/api/time.h                |  4 ++--
 platform/linux-generic/odp_schedule.c |  2 +-
 platform/linux-generic/odp_time.c     |  2 +-
 test/performance/odp_pktio_perf.c     | 10 +++++-----
 test/validation/pktio/pktio.c         |  4 ++--
 test/validation/time/time.c           |  4 ++--
 7 files changed, 14 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index 0cb5cda..c06675f 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -604,7 +604,7 @@  static void print_global_stats(int num_workers)
 			break;
 		}
 
-		diff = odp_time_diff(start, odp_time_local());
+		diff = odp_time_diff(odp_time_local(), start);
 		if (odp_time_cmp(diff, wait) > 0)
 			continue;
 
diff --git a/include/odp/api/time.h b/include/odp/api/time.h
index b3782b2..ba307d5 100644
--- a/include/odp/api/time.h
+++ b/include/odp/api/time.h
@@ -54,12 +54,12 @@  odp_time_t odp_time_local(void);
 /**
  * Time difference
  *
- * @param t1    First time stamp
  * @param t2    Second time stamp
+ * @param t1    First time stamp
  *
  * @return Difference of time stamps
  */
-odp_time_t odp_time_diff(odp_time_t t1, odp_time_t t2);
+odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1);
 
 /**
  * Time sum
diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c
index 98f7e9a..528844c 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -608,7 +608,7 @@  static int schedule_loop(odp_queue_t *out_queue, uint64_t wait,
 		}
 
 		time = odp_time_local();
-		diff  = odp_time_diff(start_time, time);
+		diff = odp_time_diff(time, start_time);
 
 		if (odp_time_cmp(diff, wait) > 0)
 			break;
diff --git a/platform/linux-generic/odp_time.c b/platform/linux-generic/odp_time.c
index 3fe0a5e..3b87e58 100644
--- a/platform/linux-generic/odp_time.c
+++ b/platform/linux-generic/odp_time.c
@@ -31,7 +31,7 @@  odp_time_t odp_time_local(void)
 	return tick_to_time(odp_cpu_cycles());
 }
 
-odp_time_t odp_time_diff(odp_time_t t1, odp_time_t t2)
+odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1)
 {
 	return tick_to_time(_odp_cpu_cycles_diff(t1, t2));
 }
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index 531c94a..4bedeee 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -337,11 +337,11 @@  static void *run_thread_tx(void *arg)
 
 	cur_time     = odp_time_local();
 	start_time   = cur_time;
-	burst_start_time = odp_time_diff(burst_gap, cur_time);
-	while (odp_time_diff(start_time, cur_time) < send_duration) {
+	burst_start_time = odp_time_diff(cur_time, burst_gap);
+	while (odp_time_diff(cur_time, start_time) < send_duration) {
 		unsigned alloc_cnt = 0, tx_cnt;
 
-		if (odp_time_diff(burst_start_time, cur_time) < burst_gap) {
+		if (odp_time_diff(cur_time, burst_start_time) < burst_gap) {
 			cur_time = odp_time_local();
 			if (!odp_time_cmp(ODP_TIME_NULL, idle_start))
 				idle_start = cur_time;
@@ -349,7 +349,7 @@  static void *run_thread_tx(void *arg)
 		}
 
 		if (odp_time_cmp(ODP_TIME_NULL, idle_start)) {
-			odp_time_t diff = odp_time_diff(idle_start, cur_time);
+			odp_time_t diff = odp_time_diff(cur_time, idle_start);
 
 			stats->s.idle_ticks =
 				odp_time_sum(diff, stats->s.idle_ticks);
@@ -600,7 +600,7 @@  static void busy_loop_ns(uint64_t wait_ns)
 	odp_time_t wait = odp_time_local_from_ns(wait_ns);
 
 	do {
-		diff = odp_time_diff(start_time, odp_time_local());
+		diff = odp_time_diff(odp_time_local(), start_time);
 	} while (odp_time_cmp(diff, wait) > 0);
 }
 
diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index 6a36100..0073d04 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -345,7 +345,7 @@  static odp_event_t queue_deq_wait_time(odp_queue_t queue, uint64_t ns)
 		if (ev != ODP_EVENT_INVALID)
 			return ev;
 		now = odp_time_local();
-		diff = odp_time_diff(start, now);
+		diff = odp_time_diff(now, start);
 	} while (odp_time_to_ns(diff) < ns);
 
 	return ODP_EVENT_INVALID;
@@ -389,7 +389,7 @@  static odp_packet_t wait_for_packet(pktio_info_t *pktio_rx,
 		}
 
 		now = odp_time_local();
-		diff = odp_time_diff(start, now);
+		diff = odp_time_diff(now, start);
 	} while (odp_time_to_ns(diff) < ns);
 
 	CU_FAIL("failed to receive transmitted packet");
diff --git a/test/validation/time/time.c b/test/validation/time/time.c
index 9c79929..39c5ec8 100644
--- a/test/validation/time/time.c
+++ b/test/validation/time/time.c
@@ -27,7 +27,7 @@  void time_test_odp_diff(void)
 	t2 = odp_time_local();
 	CU_ASSERT(odp_time_cmp(t1, t2) > 0);
 
-	diff = odp_time_diff(t1, t2);
+	diff = odp_time_diff(t2, t1);
 	CU_ASSERT(odp_time_cmp(ODP_TIME_NULL, diff) > 0);
 }
 
@@ -38,7 +38,7 @@  void time_test_odp_negative_diff(void)
 
 	t1 = 10;
 	t2 = 5;
-	diff = odp_time_diff(t1, t2);
+	diff = odp_time_diff(t2, t1);
 	CU_ASSERT(odp_time_cmp(ODP_TIME_NULL, diff) > 0);
 }