This value is frequently used. Avoid the function call overhead and the integer division at run-time.
Update #3117. Update #3182. --- cpukit/rtems/Makefile.am | 1 - cpukit/rtems/include/rtems/rtems/clock.h | 5 ++++- cpukit/rtems/src/clockgettickspersecond.c | 29 ----------------------------- cpukit/sapi/include/confdefs.h | 4 ++++ cpukit/score/include/rtems/score/watchdog.h | 8 ++++++++ testsuites/sptests/spwatchdog/init.c | 6 ++++++ 6 files changed, 22 insertions(+), 31 deletions(-) delete mode 100644 cpukit/rtems/src/clockgettickspersecond.c diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am index da6e302e2e..c8ff4f4aa5 100644 --- a/cpukit/rtems/Makefile.am +++ b/cpukit/rtems/Makefile.am @@ -140,7 +140,6 @@ librtems_a_SOURCES += src/barrierwait.c ## CLOCK_C_FILES librtems_a_SOURCES += src/clockgetsecondssinceepoch.c -librtems_a_SOURCES += src/clockgettickspersecond.c librtems_a_SOURCES += src/clockgettod.c librtems_a_SOURCES += src/clockgettodtimeval.c librtems_a_SOURCES += src/clockgetuptime.c diff --git a/cpukit/rtems/include/rtems/rtems/clock.h b/cpukit/rtems/include/rtems/rtems/clock.h index b1ae8845a6..542785d50b 100644 --- a/cpukit/rtems/include/rtems/rtems/clock.h +++ b/cpukit/rtems/include/rtems/rtems/clock.h @@ -196,7 +196,10 @@ RTEMS_INLINE_ROUTINE bool rtems_clock_tick_before( * fail since RTEMS is always configured to know the number of * ticks per second. */ -rtems_interval rtems_clock_get_ticks_per_second(void); +RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_get_ticks_per_second( void ) +{ + return _Watchdog_Ticks_per_second; +} /** * @brief Set the Current TOD diff --git a/cpukit/rtems/src/clockgettickspersecond.c b/cpukit/rtems/src/clockgettickspersecond.c deleted file mode 100644 index f49c91cbd3..0000000000 --- a/cpukit/rtems/src/clockgettickspersecond.c +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @file - * - * @brief Obtain Ticks Per Seconds - * @ingroup ClassicClock - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/rtems/clock.h> -#include <rtems/score/todimpl.h> -#include <rtems/config.h> - -rtems_interval rtems_clock_get_ticks_per_second(void) -{ - return TOD_MICROSECONDS_PER_SECOND / - rtems_configuration_get_microseconds_per_tick(); -} diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h index a64170bdff..3dfcf9b2d5 100755 --- a/cpukit/sapi/include/confdefs.h +++ b/cpukit/sapi/include/confdefs.h @@ -2287,6 +2287,8 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; RTEMS_MILLISECONDS_TO_MICROSECONDS(10) #endif + #define _CONFIGURE_TICKS_PER_SECOND (1000000 / CONFIGURE_MICROSECONDS_PER_TICK) + /** The configures the number of clock ticks per timeslice. */ #ifndef CONFIGURE_TICKS_PER_TIMESLICE #define CONFIGURE_TICKS_PER_TIMESLICE 50 @@ -3102,6 +3104,8 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; const size_t _Thread_Control_add_on_count = RTEMS_ARRAY_SIZE( _Thread_Control_add_ons ); + const uint32_t _Watchdog_Ticks_per_second = _CONFIGURE_TICKS_PER_SECOND; + /** * This is the Classic API Configuration Table. */ diff --git a/cpukit/score/include/rtems/score/watchdog.h b/cpukit/score/include/rtems/score/watchdog.h index 11a5974c26..bbe2a93b26 100644 --- a/cpukit/score/include/rtems/score/watchdog.h +++ b/cpukit/score/include/rtems/score/watchdog.h @@ -158,6 +158,14 @@ struct Watchdog_Control { */ extern volatile Watchdog_Interval _Watchdog_Ticks_since_boot; +/** + * @brief The watchdog ticks per second. + * + * This constant is defined by the application configuration via + * <rtems/confdefs.h>. + */ +extern const uint32_t _Watchdog_Ticks_per_second; + /**@}*/ #ifdef __cplusplus diff --git a/testsuites/sptests/spwatchdog/init.c b/testsuites/sptests/spwatchdog/init.c index 3b08fb57e5..3ce7917166 100644 --- a/testsuites/sptests/spwatchdog/init.c +++ b/testsuites/sptests/spwatchdog/init.c @@ -55,6 +55,11 @@ static void test_watchdog_static_init( void ) rtems_test_assert( memcmp( &a, &b, sizeof( a ) ) == 0 ); } +static void test_watchdog_config( void ) +{ + rtems_test_assert( _Watchdog_Ticks_per_second == 100 ); +} + static bool test_watchdog_is_inactive( test_watchdog *watchdog ) { return _Watchdog_Get_state( &watchdog->Base ) == WATCHDOG_INACTIVE; @@ -225,6 +230,7 @@ rtems_task Init( test_watchdog_operations(); test_watchdog_static_init(); + test_watchdog_config(); build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); -- 2.12.3 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel