[rtems commit] rtems: rtems_clock_get_ticks_per_second()
Sebastian Huber
sebh at rtems.org
Wed Oct 25 05:41:52 UTC 2017
Module: rtems
Branch: master
Commit: 34799c3bc1667dfe99cb929c3703ee994836487c
Changeset: http://git.rtems.org/rtems/commit/?id=34799c3bc1667dfe99cb929c3703ee994836487c
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue Oct 24 09:35:06 2017 +0200
rtems: rtems_clock_get_ticks_per_second()
Add macro implementation for rtems_clock_get_ticks_per_second() for
C/C++ to avoid the function call overhead. A
rtems_clock_get_ticks_per_second() is still provided for language
bindings (e.g. Ada).
---
cpukit/rtems/include/rtems/rtems/clock.h | 3 +++
cpukit/rtems/src/clockgettickspersecond.c | 2 ++
testsuites/sptests/spwatchdog/init.c | 3 +++
3 files changed, 8 insertions(+)
diff --git a/cpukit/rtems/include/rtems/rtems/clock.h b/cpukit/rtems/include/rtems/rtems/clock.h
index b1ae884..a837b88 100644
--- a/cpukit/rtems/include/rtems/rtems/clock.h
+++ b/cpukit/rtems/include/rtems/rtems/clock.h
@@ -198,6 +198,9 @@ RTEMS_INLINE_ROUTINE bool rtems_clock_tick_before(
*/
rtems_interval rtems_clock_get_ticks_per_second(void);
+/* Optimized variant for C/C++ without function call overhead */
+#define rtems_clock_get_ticks_per_second() ( _Watchdog_Ticks_per_second )
+
/**
* @brief Set the Current TOD
*
diff --git a/cpukit/rtems/src/clockgettickspersecond.c b/cpukit/rtems/src/clockgettickspersecond.c
index a2f78eb..07497cf 100644
--- a/cpukit/rtems/src/clockgettickspersecond.c
+++ b/cpukit/rtems/src/clockgettickspersecond.c
@@ -20,6 +20,8 @@
#include <rtems/rtems/clock.h>
+#undef rtems_clock_get_ticks_per_second
+
rtems_interval rtems_clock_get_ticks_per_second(void)
{
return _Watchdog_Ticks_per_second;
diff --git a/testsuites/sptests/spwatchdog/init.c b/testsuites/sptests/spwatchdog/init.c
index d212fbb..5ab6958 100644
--- a/testsuites/sptests/spwatchdog/init.c
+++ b/testsuites/sptests/spwatchdog/init.c
@@ -62,6 +62,9 @@ static void test_watchdog_config( void )
rtems_test_assert( _Watchdog_Nanoseconds_per_tick == 10000000 );
rtems_test_assert( _Watchdog_Ticks_per_second == 100 );
rtems_test_assert( _Watchdog_Monotonic_max_seconds == 184467440737095516 );
+ rtems_test_assert( rtems_clock_get_ticks_per_second() == 100 );
+ #undef rtems_clock_get_ticks_per_second
+ rtems_test_assert( rtems_clock_get_ticks_per_second() == 100 );
}
static bool test_watchdog_is_inactive( test_watchdog *watchdog )
More information about the vc
mailing list