[PATCH 1/2] rtems: rtems_clock_get_ticks_per_second()

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Oct 24 08:33:40 UTC 2017


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 ++
 2 files changed, 5 insertions(+)

diff --git a/cpukit/rtems/include/rtems/rtems/clock.h b/cpukit/rtems/include/rtems/rtems/clock.h
index b1ae8845a6..a837b88700 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 a2f78eb627..07497cfd58 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;
-- 
2.12.3



More information about the devel mailing list