[API-NEXT,5/6] api: timer: add odp_timer_pool_res()

Message ID 20170528192302.56363-5-brian.brooks@arm.com
State New
Headers show
Series
  • [API-NEXT,1/6] api: time: add odp_tick_t
Related show

Commit Message

Brian Brooks May 28, 2017, 7:23 p.m.
Signed-off-by: Brian Brooks <brian.brooks@arm.com>

Reviewed-by: Ola Liljedahl <ola.liljedahl@arm.com>

Reviewed-by: Kevin Wang <kevin.wang@arm.com>

---
 include/odp/api/spec/timer.h                  | 9 +++++++++
 platform/linux-generic/odp_timer.c            | 5 +++++
 test/common_plat/validation/api/timer/timer.c | 2 ++
 3 files changed, 16 insertions(+)

-- 
2.13.0

Patch hide | download patch | download mbox

diff --git a/include/odp/api/spec/timer.h b/include/odp/api/spec/timer.h
index 75f9db98..633cbe47 100644
--- a/include/odp/api/spec/timer.h
+++ b/include/odp/api/spec/timer.h
@@ -196,6 +196,15 @@  int odp_timer_pool_info(odp_timer_pool_t tpid,
 			odp_timer_pool_info_t *info);
 
 /**
+ * Get resolution from timer pool
+ *
+ * @param tpid Timer pool identifier
+ *
+ * @return Timeout resolution in nanoseconds
+ */
+uint64_t odp_timer_pool_res(odp_timer_pool_t tpid);
+
+/**
  * Allocate a timer
  *
  * Create a timer (allocating all necessary resources e.g. timeout event) from
diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c
index 4539ea48..80dce873 100644
--- a/platform/linux-generic/odp_timer.c
+++ b/platform/linux-generic/odp_timer.c
@@ -842,6 +842,11 @@  int odp_timer_pool_info(odp_timer_pool_t tpid,
 	return 0;
 }
 
+uint64_t odp_timer_pool_res(odp_timer_pool_t tpid)
+{
+	return tpid->param.res_ns;
+}
+
 uint64_t odp_timer_pool_to_u64(odp_timer_pool_t tpid)
 {
 	return _odp_pri(tpid);
diff --git a/test/common_plat/validation/api/timer/timer.c b/test/common_plat/validation/api/timer/timer.c
index b7d84c64..0fb4631e 100644
--- a/test/common_plat/validation/api/timer/timer.c
+++ b/test/common_plat/validation/api/timer/timer.c
@@ -529,6 +529,8 @@  void timer_test_odp_timer_all(void)
 	CU_ASSERT(tpinfo.param.max_tmo == MAX);
 	CU_ASSERT(strcmp(tpinfo.name, NAME) == 0);
 
+	CU_ASSERT(odp_timer_pool_res(tp) == RES);
+
 	LOG_DBG("Timer pool handle: %" PRIu64 "\n", odp_timer_pool_to_u64(tp));
 	LOG_DBG("#timers..: %u\n", NTIMERS);
 	LOG_DBG("Tmo range: %u ms (%" PRIu64 " ticks)\n", RANGE_MS,