[rtems commit] score: Add _Watchdog_Monotonic_from_timespec()

Sebastian Huber sebh at rtems.org
Tue Oct 24 08:22:05 UTC 2017


Module:    rtems
Branch:    master
Commit:    b13ec804763d8f428161a50fd1846d567982ed4b
Changeset: http://git.rtems.org/rtems/commit/?id=b13ec804763d8f428161a50fd1846d567982ed4b

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Oct 20 15:23:49 2017 +0200

score: Add _Watchdog_Monotonic_from_timespec()

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 31b44f1..b3f396b 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
 )




More information about the vc mailing list