@@ -140,6 +140,7 @@ noinst_HEADERS = \
${srcdir}/include/odp_schedule_internal.h \
${srcdir}/include/odp_spin_internal.h \
${srcdir}/include/odp_timer_internal.h \
+ ${srcdir}/include/odp_cpu_internal.h \
${srcdir}/Makefile.inc
__LIB__libodp_la_SOURCES = \
new file mode 100644
@@ -0,0 +1,29 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_CPU_INTERNAL_H_
+#define ODP_CPU_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/cpu.h>
+
+static inline
+uint64_t _odp_cpu_cycles_diff(uint64_t c1, uint64_t c2)
+{
+ if (odp_likely(c2 >= c1))
+ return c2 - c1;
+
+ return c2 + (odp_cpu_cycles_max() - c1);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
@@ -6,11 +6,9 @@
#include <odp/cpu.h>
#include <odp/hints.h>
+#include <odp_cpu_internal.h>
uint64_t odp_cpu_cycles_diff(uint64_t c1, uint64_t c2)
{
- if (odp_likely(c2 >= c1))
- return c2 - c1;
-
- return c2 + (odp_cpu_cycles_max() - c1);
+ return _odp_cpu_cycles_diff(c1, c2);
}
@@ -10,6 +10,7 @@
#include <odp/hints.h>
#include <odp/system_info.h>
#include <odp/cpu.h>
+#include <odp_cpu_internal.h>
#define GIGA 1000000000
@@ -20,10 +21,7 @@ uint64_t odp_time_cycles(void)
uint64_t odp_time_diff_cycles(uint64_t t1, uint64_t t2)
{
- if (odp_likely(t2 >= t1))
- return t2 - t1;
-
- return t2 + (UINT64_MAX - t1);
+ return _odp_cpu_cycles_diff(t1, t2);
}
uint64_t odp_time_cycles_to_ns(uint64_t cycles)
Currently, time API reuses cpu API to get ticks, but uses it's own function to count diff but it can differ from cpu diff function. So, better to use the same function in order to eliminate possible difference in counting. Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> --- platform/linux-generic/Makefile.am | 1 + platform/linux-generic/include/odp_cpu_internal.h | 29 +++++++++++++++++++++++ platform/linux-generic/odp_cpu.c | 6 ++--- platform/linux-generic/odp_time.c | 6 ++--- 4 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 platform/linux-generic/include/odp_cpu_internal.h