From 7222a65f0e2992b9f8dd556d9a72c79a2421fe3a Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 21 Jun 2016 09:45:39 +0200 Subject: 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 3fe12b0b17..92f2e15c72 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" -- cgit v1.2.3