summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/watchdogimpl.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-29 20:29:05 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-11-02 14:08:32 +0100
commit3e81d52e27ea030fc93580c610c40616ab2b0559 (patch)
tree5fe2bbc0217d90328a9c6d8ad43fb9bb3cbb0ddf /cpukit/score/include/rtems/score/watchdogimpl.h
parenttests: Use printf() instead of fprintf() (diff)
downloadrtems-3e81d52e27ea030fc93580c610c40616ab2b0559.tar.bz2
posix: Use far future for very long timeouts
Close #3205.
Diffstat (limited to 'cpukit/score/include/rtems/score/watchdogimpl.h')
-rw-r--r--cpukit/score/include/rtems/score/watchdogimpl.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/cpukit/score/include/rtems/score/watchdogimpl.h b/cpukit/score/include/rtems/score/watchdogimpl.h
index 7866c0ce44..f219a70768 100644
--- a/cpukit/score/include/rtems/score/watchdogimpl.h
+++ b/cpukit/score/include/rtems/score/watchdogimpl.h
@@ -324,6 +324,36 @@ RTEMS_INLINE_ROUTINE bool _Watchdog_Is_valid_interval_timespec(
return _Watchdog_Is_valid_timespec( ts ) && ts->tv_sec >= 0;
}
+RTEMS_INLINE_ROUTINE const struct timespec * _Watchdog_Future_timespec(
+ struct timespec *now,
+ const struct timespec *delta
+)
+{
+ uint64_t sec;
+
+ if ( !_Watchdog_Is_valid_interval_timespec( delta ) ) {
+ return NULL;
+ }
+
+ sec = (uint64_t) now->tv_sec;
+ sec += (uint64_t) delta->tv_sec;
+ now->tv_nsec += delta->tv_nsec;
+
+ /* We have 2 * (2**63 - 1) + 1 == UINT64_MAX */
+ if ( now->tv_nsec >= WATCHDOG_NANOSECONDS_PER_SECOND ) {
+ now->tv_nsec -= WATCHDOG_NANOSECONDS_PER_SECOND;
+ ++sec;
+ }
+
+ if ( sec <= INT64_MAX ) {
+ now->tv_sec = sec;
+ } else {
+ now->tv_sec = INT64_MAX;
+ }
+
+ return now;
+}
+
RTEMS_INLINE_ROUTINE bool _Watchdog_Is_far_future_monotonic_timespec(
const struct timespec *ts
)