From b13ec804763d8f428161a50fd1846d567982ed4b Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 20 Oct 2017 15:23:49 +0200 Subject: score: Add _Watchdog_Monotonic_from_timespec() Update #3117. Update #3182. --- cpukit/score/include/rtems/score/watchdogimpl.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cpukit') 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 ) -- cgit v1.2.3