From 2dd5e6fb320a5309e02570fad93d4b5fc09328a7 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 20 Apr 2016 06:43:11 +0200 Subject: posix: Use _Objects_Get_local() for semaphores This simplifies the code since the object location is no longer used. Remove superfluous header includes. --- cpukit/posix/src/semaphorewaitsupp.c | 60 +++++++++++++----------------------- 1 file changed, 21 insertions(+), 39 deletions(-) (limited to 'cpukit/posix/src/semaphorewaitsupp.c') diff --git a/cpukit/posix/src/semaphorewaitsupp.c b/cpukit/posix/src/semaphorewaitsupp.c index cf8fe63c93..84ebe3d9e2 100644 --- a/cpukit/posix/src/semaphorewaitsupp.c +++ b/cpukit/posix/src/semaphorewaitsupp.c @@ -18,18 +18,10 @@ #include "config.h" #endif -#include - -#include -#include -#include #include -#include -#include -#include #include -#include +#include THREAD_WAIT_QUEUE_OBJECT_ASSERT( POSIX_Semaphore_Control, @@ -43,43 +35,33 @@ int _POSIX_Semaphore_Wait_support( ) { POSIX_Semaphore_Control *the_semaphore; - Objects_Locations location; Thread_Control *executing; ISR_lock_Context lock_context; - the_semaphore = _POSIX_Semaphore_Get_interrupt_disable( - sem, - &location, - &lock_context - ); - switch ( location ) { + the_semaphore = _POSIX_Semaphore_Get( sem, &lock_context ); - case OBJECTS_LOCAL: - executing = _Thread_Executing; - _CORE_semaphore_Seize( - &the_semaphore->Semaphore, - executing, - the_semaphore->Object.id, - blocking, - timeout, - &lock_context - ); + if ( the_semaphore == NULL ) { + rtems_set_errno_and_return_minus_one( EINVAL ); + } - if ( !executing->Wait.return_code ) - return 0; + executing = _Thread_Executing; - rtems_set_errno_and_return_minus_one( - _POSIX_Semaphore_Translate_core_semaphore_return_code( - executing->Wait.return_code - ) - ); + _CORE_semaphore_Seize( + &the_semaphore->Semaphore, + executing, + the_semaphore->Object.id, + blocking, + timeout, + &lock_context + ); -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; + if ( executing->Wait.return_code == CORE_SEMAPHORE_STATUS_SUCCESSFUL ) { + return 0; } - rtems_set_errno_and_return_minus_one( EINVAL ); + rtems_set_errno_and_return_minus_one( + _POSIX_Semaphore_Translate_core_semaphore_return_code( + executing->Wait.return_code + ) + ); } -- cgit v1.2.3