[rtems commit] score: _Watchdog_Is_far_future_monotonic_timespec
Sebastian Huber
sebh at rtems.org
Tue Oct 24 08:21:41 UTC 2017
Module: rtems
Branch: master
Commit: 7ed377bc69e8cf96b989018322dc43bc0f2d2e36
Changeset: http://git.rtems.org/rtems/commit/?id=7ed377bc69e8cf96b989018322dc43bc0f2d2e36
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Oct 20 08:43:15 2017 +0200
score: _Watchdog_Is_far_future_monotonic_timespec
Update #3117.
Update #3182.
---
cpukit/sapi/include/confdefs.h | 3 +++
cpukit/score/include/rtems/score/watchdog.h | 9 +++++++++
cpukit/score/include/rtems/score/watchdogimpl.h | 7 +++++++
testsuites/sptests/spwatchdog/init.c | 1 +
4 files changed, 20 insertions(+)
diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 13e97c9..aed740b 100755
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -3110,6 +3110,9 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
const uint32_t _Watchdog_Ticks_per_second = _CONFIGURE_TICKS_PER_SECOND;
+ const uint64_t _Watchdog_Monotonic_max_seconds =
+ UINT64_MAX / _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 bbe2a93..8c37103 100644
--- a/cpukit/score/include/rtems/score/watchdog.h
+++ b/cpukit/score/include/rtems/score/watchdog.h
@@ -166,6 +166,15 @@ extern volatile Watchdog_Interval _Watchdog_Ticks_since_boot;
*/
extern const uint32_t _Watchdog_Ticks_per_second;
+/**
+ * @brief The maximum number of seconds representable in the monotonic watchdog
+ * format.
+ *
+ * This constant is defined by the application configuration via
+ * <rtems/confdefs.h>.
+ */
+extern const uint64_t _Watchdog_Monotonic_max_seconds;
+
/**@}*/
#ifdef __cplusplus
diff --git a/cpukit/score/include/rtems/score/watchdogimpl.h b/cpukit/score/include/rtems/score/watchdogimpl.h
index 9fc1f05..31b44f1 100644
--- a/cpukit/score/include/rtems/score/watchdogimpl.h
+++ b/cpukit/score/include/rtems/score/watchdogimpl.h
@@ -319,6 +319,13 @@ RTEMS_INLINE_ROUTINE bool _Watchdog_Is_valid_interval_timespec(
return _Watchdog_Is_valid_timespec( ts ) && ts->tv_sec >= 0;
}
+RTEMS_INLINE_ROUTINE bool _Watchdog_Is_far_future_monotonic_timespec(
+ const struct timespec *ts
+)
+{
+ return ts->tv_sec >= _Watchdog_Monotonic_max_seconds;
+}
+
RTEMS_INLINE_ROUTINE bool _Watchdog_Is_far_future_realtime_timespec(
const struct timespec *ts
)
diff --git a/testsuites/sptests/spwatchdog/init.c b/testsuites/sptests/spwatchdog/init.c
index f027236..274def9 100644
--- a/testsuites/sptests/spwatchdog/init.c
+++ b/testsuites/sptests/spwatchdog/init.c
@@ -60,6 +60,7 @@ static void test_watchdog_static_init( void )
static void test_watchdog_config( void )
{
rtems_test_assert( _Watchdog_Ticks_per_second == 100 );
+ rtems_test_assert( _Watchdog_Monotonic_max_seconds == 184467440737095516 );
}
static bool test_watchdog_is_inactive( test_watchdog *watchdog )
More information about the vc
mailing list