diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-06-21 09:45:39 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-06-21 15:54:18 +0200 |
commit | 7222a65f0e2992b9f8dd556d9a72c79a2421fe3a (patch) | |
tree | fe9350d588a52da5c5715ea3b7224872dab5f804 /testsuites/sptests/spcpucounter01 | |
parent | fa239ff26c5bafa3ffeecfaa130084e7cacafa12 (diff) |
sptests/spcpucounter01: Resurrect workaround
Resurrect workaround accidentially removed by
3e2a3c49480b9888362d016dd202edd562d9e069.
Diffstat (limited to 'testsuites/sptests/spcpucounter01')
-rw-r--r-- | testsuites/sptests/spcpucounter01/init.c | 23 |
1 files 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" |