there is odp_time_diff(), forget about this patch.

Maxim.

On 09/14/16 20:16, Maxim Uvarov wrote:
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.uva...@linaro.org>
---
  include/odp/api/spec/time.h       | 10 ++++++++++
  platform/linux-generic/odp_time.c | 17 +++++++++++++++++
  2 files changed, 27 insertions(+)

diff --git a/include/odp/api/spec/time.h b/include/odp/api/spec/time.h
index fcc94c9..5e94b70 100644
--- a/include/odp/api/spec/time.h
+++ b/include/odp/api/spec/time.h
@@ -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
diff --git a/platform/linux-generic/odp_time.c 
b/platform/linux-generic/odp_time.c
index 81e0522..7fef46f 100644
--- a/platform/linux-generic/odp_time.c
+++ b/platform/linux-generic/odp_time.c
@@ -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();

Reply via email to