summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/semaphorewaitsupp.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-20 06:43:11 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-22 09:25:08 +0200
commit2dd5e6fb320a5309e02570fad93d4b5fc09328a7 (patch)
tree0600823693f0c6d2e521537622d2ac89809765a0 /cpukit/posix/src/semaphorewaitsupp.c
parentscore: Avoid Giant lock for CORE mtx/sem (diff)
downloadrtems-2dd5e6fb320a5309e02570fad93d4b5fc09328a7.tar.bz2
posix: Use _Objects_Get_local() for semaphores
This simplifies the code since the object location is no longer used. Remove superfluous header includes.
Diffstat (limited to 'cpukit/posix/src/semaphorewaitsupp.c')
-rw-r--r--cpukit/posix/src/semaphorewaitsupp.c60
1 files changed, 21 insertions, 39 deletions
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 <stdarg.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
#include <semaphore.h>
-#include <limits.h>
-#include <rtems/system.h>
-#include <rtems/score/threadimpl.h>
#include <rtems/posix/semaphoreimpl.h>
-#include <rtems/seterr.h>
+#include <rtems/score/threadimpl.h>
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
+ )
+ );
}