<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 23, 2017 at 8:53 AM, Sebastian Huber <span dir="ltr"><<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This value is frequently used. Avoid the function call overhead and the<br>
integer division at run-time.<br>
<br>
Update #3117.<br>
Update #3182.<br>
---<br>
cpukit/rtems/Makefile.am | 1 -<br>
cpukit/rtems/include/rtems/<wbr>rtems/clock.h | 5 ++++-<br>
cpukit/rtems/src/<wbr>clockgettickspersecond.c | 29 -----------------------------<br>
cpukit/sapi/include/confdefs.h | 4 ++++<br>
cpukit/score/include/rtems/<wbr>score/watchdog.h | 8 ++++++++<br>
testsuites/sptests/spwatchdog/<wbr>init.c | 6 ++++++<br>
6 files changed, 22 insertions(+), 31 deletions(-)<br>
delete mode 100644 cpukit/rtems/src/<wbr>clockgettickspersecond.c<br>
<br>
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am<br>
index da6e302e2e..c8ff4f4aa5 100644<br>
--- a/cpukit/rtems/Makefile.am<br>
+++ b/cpukit/rtems/Makefile.am<br>
@@ -140,7 +140,6 @@ librtems_a_SOURCES += src/barrierwait.c<br>
<br>
## CLOCK_C_FILES<br>
librtems_a_SOURCES += src/clockgetsecondssinceepoch.<wbr>c<br>
-librtems_a_SOURCES += src/clockgettickspersecond.c<br>
librtems_a_SOURCES += src/clockgettod.c<br>
librtems_a_SOURCES += src/clockgettodtimeval.c<br>
librtems_a_SOURCES += src/clockgetuptime.c<br>
diff --git a/cpukit/rtems/include/rtems/<wbr>rtems/clock.h b/cpukit/rtems/include/rtems/<wbr>rtems/clock.h<br>
index b1ae8845a6..542785d50b 100644<br>
--- a/cpukit/rtems/include/rtems/<wbr>rtems/clock.h<br>
+++ b/cpukit/rtems/include/rtems/<wbr>rtems/clock.h<br>
@@ -196,7 +196,10 @@ RTEMS_INLINE_ROUTINE bool rtems_clock_tick_before(<br>
* fail since RTEMS is always configured to know the number of<br>
* ticks per second.<br>
*/<br>
-rtems_interval rtems_clock_get_ticks_per_<wbr>second(void);<br>
+RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_get_ticks_per_<wbr>second( void )<br>
+{<br>
+ return _Watchdog_Ticks_per_second;<br>
+}<br>
<br></blockquote><div><br></div><div>This is a public API method and cannot be inlined. Otherwise, it can't be accessed</div><div>from languages like assembly or Ada.</div><div><br></div><div>All public API methods need to have real bodies.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
/**<br>
* @brief Set the Current TOD<br>
diff --git a/cpukit/rtems/src/<wbr>clockgettickspersecond.c b/cpukit/rtems/src/<wbr>clockgettickspersecond.c<br>
deleted file mode 100644<br>
index f49c91cbd3..0000000000<br>
--- a/cpukit/rtems/src/<wbr>clockgettickspersecond.c<br>
+++ /dev/null<br>
@@ -1,29 +0,0 @@<br>
-/**<br>
- * @file<br>
- *<br>
- * @brief Obtain Ticks Per Seconds<br>
- * @ingroup ClassicClock<br>
- */<br>
-<br>
-/*<br>
- * COPYRIGHT (c) 1989-2008.<br>
- * On-Line Applications Research Corporation (OAR).<br>
- *<br>
- * The license and distribution terms for this file may be<br>
- * found in the file LICENSE in this distribution or at<br>
- * <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/<wbr>LICENSE</a>.<br>
- */<br>
-<br>
-#if HAVE_CONFIG_H<br>
-#include "config.h"<br>
-#endif<br>
-<br>
-#include <rtems/rtems/clock.h><br>
-#include <rtems/score/todimpl.h><br>
-#include <rtems/config.h><br>
-<br>
-rtems_interval rtems_clock_get_ticks_per_<wbr>second(void)<br>
-{<br>
- return TOD_MICROSECONDS_PER_SECOND /<br>
- rtems_configuration_get_<wbr>microseconds_per_tick();<br>
-}<br>
diff --git a/cpukit/sapi/include/<wbr>confdefs.h b/cpukit/sapi/include/<wbr>confdefs.h<br>
index a64170bdff..3dfcf9b2d5 100755<br>
--- a/cpukit/sapi/include/<wbr>confdefs.h<br>
+++ b/cpukit/sapi/include/<wbr>confdefs.h<br>
@@ -2287,6 +2287,8 @@ extern rtems_initialization_tasks_<wbr>table Initialization_tasks[];<br>
RTEMS_MILLISECONDS_TO_<wbr>MICROSECONDS(10)<br>
#endif<br>
<br>
+ #define _CONFIGURE_TICKS_PER_SECOND (1000000 / CONFIGURE_MICROSECONDS_PER_<wbr>TICK)<br>
+<br>
/** The configures the number of clock ticks per timeslice. */<br>
#ifndef CONFIGURE_TICKS_PER_TIMESLICE<br>
#define CONFIGURE_TICKS_PER_TIMESLICE 50<br>
@@ -3102,6 +3104,8 @@ extern rtems_initialization_tasks_<wbr>table Initialization_tasks[];<br>
const size_t _Thread_Control_add_on_count =<br>
RTEMS_ARRAY_SIZE( _Thread_Control_add_ons );<br>
<br>
+ const uint32_t _Watchdog_Ticks_per_second = _CONFIGURE_TICKS_PER_SECOND;<br>
+<br>
/**<br>
* This is the Classic API Configuration Table.<br>
*/<br>
diff --git a/cpukit/score/include/rtems/<wbr>score/watchdog.h b/cpukit/score/include/rtems/<wbr>score/watchdog.h<br>
index 11a5974c26..bbe2a93b26 100644<br>
--- a/cpukit/score/include/rtems/<wbr>score/watchdog.h<br>
+++ b/cpukit/score/include/rtems/<wbr>score/watchdog.h<br>
@@ -158,6 +158,14 @@ struct Watchdog_Control {<br>
*/<br>
extern volatile Watchdog_Interval _Watchdog_Ticks_since_boot;<br>
<br>
+/**<br>
+ * @brief The watchdog ticks per second.<br>
+ *<br>
+ * This constant is defined by the application configuration via<br>
+ * <rtems/confdefs.h>.<br>
+ */<br>
+extern const uint32_t _Watchdog_Ticks_per_second;<br>
+<br>
/**@}*/<br>
<br>
#ifdef __cplusplus<br>
diff --git a/testsuites/sptests/<wbr>spwatchdog/init.c b/testsuites/sptests/<wbr>spwatchdog/init.c<br>
index 3b08fb57e5..3ce7917166 100644<br>
--- a/testsuites/sptests/<wbr>spwatchdog/init.c<br>
+++ b/testsuites/sptests/<wbr>spwatchdog/init.c<br>
@@ -55,6 +55,11 @@ static void test_watchdog_static_init( void )<br>
rtems_test_assert( memcmp( &a, &b, sizeof( a ) ) == 0 );<br>
}<br>
<br>
+static void test_watchdog_config( void )<br>
+{<br>
+ rtems_test_assert( _Watchdog_Ticks_per_second == 100 );<br>
+}<br>
+<br>
static bool test_watchdog_is_inactive( test_watchdog *watchdog )<br>
{<br>
return _Watchdog_Get_state( &watchdog->Base ) == WATCHDOG_INACTIVE;<br>
@@ -225,6 +230,7 @@ rtems_task Init(<br>
<br>
test_watchdog_operations();<br>
test_watchdog_static_init();<br>
+ test_watchdog_config();<br>
<br>
build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.12.3<br>
<br>
______________________________<wbr>_________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/<wbr>mailman/listinfo/devel</a><br>
</font></span></blockquote></div><br></div></div>