summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/sigtimedwait.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-19 13:47:57 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-24 10:19:05 +0200
commitc31058947491ca319c901040219be39e4f8155b6 (patch)
tree435bf0887bd77e3d344b31275853a6e52fca8dd8 /cpukit/posix/src/sigtimedwait.c
parentscore: Rename function threadq support function (diff)
downloadrtems-c31058947491ca319c901040219be39e4f8155b6.tar.bz2
score: Move thread queue timeout handling
Update #3117. Update #3182.
Diffstat (limited to 'cpukit/posix/src/sigtimedwait.c')
-rw-r--r--cpukit/posix/src/sigtimedwait.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/cpukit/posix/src/sigtimedwait.c b/cpukit/posix/src/sigtimedwait.c
index 70170bf2f7..a0e18adef0 100644
--- a/cpukit/posix/src/sigtimedwait.c
+++ b/cpukit/posix/src/sigtimedwait.c
@@ -24,6 +24,8 @@
#include <rtems/posix/psignalimpl.h>
#include <rtems/posix/posixapi.h>
#include <rtems/score/threadqimpl.h>
+#include <rtems/score/todimpl.h>
+#include <rtems/score/watchdogimpl.h>
#include <rtems/score/isr.h>
static int _POSIX_signals_Get_lowest(
@@ -89,20 +91,24 @@ int sigtimedwait(
* in the Open Group specification.
*/
- if ( timeout ) {
- Watchdog_Interval interval;
+ if ( timeout != NULL ) {
+ struct timespec end;
- if ( !_Timespec_Is_valid( timeout ) )
- rtems_set_errno_and_return_minus_one( EINVAL );
+ if ( !_Watchdog_Is_valid_interval_timespec( timeout ) ) {
+ return EINVAL;
+ }
- interval = _Timespec_To_ticks( timeout );
+ _TOD_Get_zero_based_uptime_as_timespec( &end );
- if ( !interval )
- rtems_set_errno_and_return_minus_one( EINVAL );
+ /* In case this overflows, then the enqueue callout will reject it */
+ _Timespec_Add_to( &end, timeout );
- _Thread_queue_Context_set_relative_timeout( &queue_context, interval );
+ _Thread_queue_Context_set_enqueue_timeout_monotonic_timespec(
+ &queue_context,
+ &end
+ );
} else {
- _Thread_queue_Context_set_no_timeout( &queue_context );
+ _Thread_queue_Context_set_enqueue_do_nothing_extra( &queue_context );
}
/*
@@ -160,7 +166,6 @@ int sigtimedwait(
&queue_context,
STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL
);
- _Thread_queue_Context_set_enqueue_do_nothing_extra( &queue_context );
_Thread_queue_Enqueue(
&_POSIX_signals_Wait_queue.Queue,
POSIX_SIGNALS_TQ_OPERATIONS,