[PATCH 12/16] score: Add _Watchdog_Monotonic_from_timespec()

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Oct 23 13:53:43 UTC 2017


Update #3117.
Update #3182.
---
 cpukit/score/include/rtems/score/watchdogimpl.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/cpukit/score/include/rtems/score/watchdogimpl.h b/cpukit/score/include/rtems/score/watchdogimpl.h
index 31b44f1d0b..b3f396b7a3 100644
--- a/cpukit/score/include/rtems/score/watchdogimpl.h
+++ b/cpukit/score/include/rtems/score/watchdogimpl.h
@@ -326,6 +326,22 @@ RTEMS_INLINE_ROUTINE bool _Watchdog_Is_far_future_monotonic_timespec(
   return ts->tv_sec >= _Watchdog_Monotonic_max_seconds;
 }
 
+RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Monotonic_from_timespec(
+  const struct timespec *ts
+)
+{
+  uint64_t ticks;
+
+  _Assert( _Watchdog_Is_valid_timespec( ts ) );
+  _Assert( ts->tv_sec >= 0 );
+  _Assert( !_Watchdog_Is_far_future_monotonic_timespec( ts ) );
+
+  ticks = (uint64_t) ts->tv_sec * _Watchdog_Ticks_per_second;
+  ticks += (unsigned long) ts->tv_nsec / _Watchdog_Nanoseconds_per_tick;
+
+  return ticks;
+}
+
 RTEMS_INLINE_ROUTINE bool _Watchdog_Is_far_future_realtime_timespec(
   const struct timespec *ts
 )
-- 
2.12.3




More information about the devel mailing list