From 0c2ec7f52c496e436f09d44dcb880bf4ea16ba86 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 30 Oct 2006 22:21:23 +0000 Subject: 2006-10-30 Joel Sherrill PR 841/rtems * itron/inline/rtems/itron/semaphore.inl, itron/src/twai_sem.c, posix/include/rtems/posix/semaphore.h, posix/inline/rtems/posix/semaphore.inl, posix/src/semaphorewaitsupp.c, posix/src/semtimedwait.c, posix/src/semwait.c, rtems/src/semobtain.c, rtems/src/semtranslatereturncode.c, score/include/rtems/score/coresem.h, score/src/coresemseize.c: Make sem_timedwait more conformant to Open Group specification. --- cpukit/score/src/coresemseize.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'cpukit/score/src/coresemseize.c') diff --git a/cpukit/score/src/coresemseize.c b/cpukit/score/src/coresemseize.c index 49c835b80b..2648a620c2 100644 --- a/cpukit/score/src/coresemseize.c +++ b/cpukit/score/src/coresemseize.c @@ -51,10 +51,10 @@ */ void _CORE_semaphore_Seize( - CORE_semaphore_Control *the_semaphore, - Objects_Id id, - boolean wait, - Watchdog_Interval timeout + CORE_semaphore_Control *the_semaphore, + Objects_Id id, + Core_semaphore_Blocking_option wait, + Watchdog_Interval timeout ) { Thread_Control *executing; @@ -69,16 +69,22 @@ void _CORE_semaphore_Seize( return; } - if ( !wait ) { - _ISR_Enable( level ); - executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT; - return; + switch ( wait ) { + case CORE_SEMAPHORE_NO_WAIT: + _ISR_Enable( level ); + executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT; + return; + case CORE_SEMAPHORE_BAD_TIMEOUT: + executing->Wait.return_code = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE; + return; + case CORE_SEMAPHORE_BLOCK_FOREVER: + case CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT: + _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue ); + executing->Wait.queue = &the_semaphore->Wait_queue; + executing->Wait.id = id; + _ISR_Enable( level ); + _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout ); + break; } - _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue ); - executing->Wait.queue = &the_semaphore->Wait_queue; - executing->Wait.id = id; - _ISR_Enable( level ); - - _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout ); } -- cgit v1.2.3