@@ -87,6 +87,16 @@ odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1);
odp_time_t odp_time_sum(odp_time_t t1, odp_time_t t2);
/**
+ * Time subtract
+ *
+ * @param t1 Time stamp to subtract from
+ * @param t2 Value to subtract
+ *
+ * @return Time stamp t1 - t2
+ */
+odp_time_t odp_time_sub(odp_time_t t1, odp_time_t t2);
+
+/**
* Convert time to nanoseconds
*
* @param time Time
@@ -81,6 +81,18 @@ static inline odp_time_t time_sum(odp_time_t t1, odp_time_t t2)
return time;
}
+static inline odp_time_t time_sub(odp_time_t t1, odp_time_t t2)
+{
+ uint64_t ns;
+ odp_time_t time;
+
+ ns = time_to_ns(t1) - time_to_ns(t2);
+ time.tv_sec = ns / ODP_TIME_SEC_IN_NS;
+ time.tv_nsec = ns - time.tv_sec * ODP_TIME_SEC_IN_NS;
+
+ return time;
+}
+
static inline odp_time_t time_local_from_ns(uint64_t ns)
{
odp_time_t time;
@@ -152,6 +164,11 @@ odp_time_t odp_time_sum(odp_time_t t1, odp_time_t t2)
return time_sum(t1, t2);
}
+odp_time_t odp_time_sub(odp_time_t t1, odp_time_t t2)
+{
+ return time_sub(t1, t2);
+}
+
uint64_t odp_time_local_res(void)
{
return time_local_res();
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, Linaro Limited
+b/* Copyright (c) 2015, Linaro Limited
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
Previously we had odp_time_sum but missing call to subtract some value from odp_time_t. Because on different platforms it can be implemented differently we need this call. Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> --- include/odp/api/spec/time.h | 10 ++++++++++ platform/linux-generic/odp_time.c | 17 +++++++++++++++++ test/common_plat/validation/api/time/time.c | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) -- 2.7.1.250.gff4ea60