[rtems commit] sptests/spcpucounter01: Resurrect workaround

Sebastian Huber sebh at rtems.org
Tue Jun 21 13:55:04 UTC 2016


Module:    rtems
Branch:    master
Commit:    7222a65f0e2992b9f8dd556d9a72c79a2421fe3a
Changeset: http://git.rtems.org/rtems/commit/?id=7222a65f0e2992b9f8dd556d9a72c79a2421fe3a

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Jun 21 09:45:39 2016 +0200

sptests/spcpucounter01: Resurrect workaround

Resurrect workaround accidentially removed by
3e2a3c49480b9888362d016dd202edd562d9e069.

---

 testsuites/sptests/spcpucounter01/init.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/testsuites/sptests/spcpucounter01/init.c b/testsuites/sptests/spcpucounter01/init.c
index 3fe12b0..92f2e15 100644
--- a/testsuites/sptests/spcpucounter01/init.c
+++ b/testsuites/sptests/spcpucounter01/init.c
@@ -158,6 +158,25 @@ static void report_overhead(
   );
 }
 
+static uint64_t large_delta_to_ns(rtems_counter_ticks d)
+{
+  uint64_t ns;
+
+  ns = rtems_counter_ticks_to_nanoseconds(d);
+
+  /* Special case for CPU counters using the clock driver counter */
+  if (ns < rtems_configuration_get_nanoseconds_per_tick()) {
+    printf(
+      "warning: the RTEMS counter seems to be unable to\n"
+      "  measure intervals greater than the clock tick interval\n"
+    );
+
+    ns += rtems_configuration_get_nanoseconds_per_tick();
+  }
+
+  return ns;
+}
+
 static void test_report(test_context *ctx)
 {
   double ns_per_tick = NS_PER_TICK;
@@ -169,7 +188,7 @@ static void test_report(test_context *ctx)
 
   for (i = 0; i < N; ++i) {
     d = rtems_counter_difference(ctx->delay_ns_t[i][1], ctx->delay_ns_t[i][0]);
-    ns = rtems_counter_ticks_to_nanoseconds(d);
+    ns = large_delta_to_ns(d);
 
     printf(
       "ns busy wait duration: %" PRIu64 "ns\n"
@@ -186,7 +205,7 @@ static void test_report(test_context *ctx)
       ctx->delay_ticks_t[i][1],
       ctx->delay_ticks_t[i][0]
     );
-    ns = rtems_counter_ticks_to_nanoseconds(d);
+    ns = large_delta_to_ns(d);
 
     printf(
       "ticks busy wait duration: %" PRIu64 "ns\n"




More information about the vc mailing list