On 05.11.15 15:15, Savolainen, Petri (Nokia - FI/Espoo) wrote:
+
+/**
+ * Compare two times
+ *
+ * @param t1    First time
+ * @param t2    Second time
+ *
+ * @retval -1 if t2 < t1, 0 if t1 = t2, 1 if t2 > t1
+ */
+int odp_time_cmp(odp_time_t t1, odp_time_t t2);


Return values should be <0 and >0, instead of -1 and 1.


May be it's logical to follow C lib time.h/difftime() and swap t1/t2. When that 
is changed to diff(t2, t1), this call should be also changed to cmp(t2, t1).

t1 = odp_time_global(); // on thread A
t2 = odp_time_global(); // on thread B

if (odp_time_cmp(t2, t1) > 0) {
        // t2 > t1: this is the common case, the caller expected the right 
order of t2 vs. t1
        diff = odp_time_diff(t2, t1);
}

if (odp_time_cmp(t2, t1) < 0) {
        // t2 < t1: caller didn't know that t2 was stamped before t1


}

Agree. I will send new version.



Could you add also a patch after 6/6 which swaps the same for cpu_cycles. So 
that  odp_cpu_cycles_diff() parameter order keeps in sync.

I keep my attention on it. And send it as separate patch soon, after this 
series is applied, just to follow the name of series.


Otherwise, this set is a good step to the right direction.

-Petri






--
Regards,
Ivan Khoronzhuk
_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to