summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/semclose.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/semclose.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/semclose.c')
-rw-r--r--cpukit/posix/src/semclose.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/cpukit/posix/src/semclose.c b/cpukit/posix/src/semclose.c
index 1468c7fb35..3f18ff1efe 100644
--- a/cpukit/posix/src/semclose.c
+++ b/cpukit/posix/src/semclose.c
@@ -26,36 +26,24 @@ int sem_close(
sem_t *sem
)
{
- POSIX_Semaphore_Control *the_semaphore;
- Objects_Locations location;
- ISR_lock_Context lock_context;
+ POSIX_Semaphore_Control *the_semaphore;
+ ISR_lock_Context lock_context;
_Objects_Allocator_lock();
- the_semaphore = _POSIX_Semaphore_Get_interrupt_disable(
- sem,
- &location,
+ the_semaphore = _POSIX_Semaphore_Get( sem, &lock_context );
+
+ if ( the_semaphore == NULL ) {
+ _Objects_Allocator_unlock();
+ rtems_set_errno_and_return_minus_one( EINVAL );
+ }
+
+ _CORE_semaphore_Acquire_critical(
+ &the_semaphore->Semaphore,
&lock_context
);
- switch ( location ) {
-
- case OBJECTS_LOCAL:
- _CORE_semaphore_Acquire_critical(
- &the_semaphore->Semaphore,
- &lock_context
- );
- the_semaphore->open_count -= 1;
- _POSIX_Semaphore_Delete( the_semaphore, &lock_context );
- _Objects_Allocator_unlock();
- return 0;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
-#endif
- case OBJECTS_ERROR:
- break;
- }
+ the_semaphore->open_count -= 1;
+ _POSIX_Semaphore_Delete( the_semaphore, &lock_context );
_Objects_Allocator_unlock();
-
- rtems_set_errno_and_return_minus_one( EINVAL );
+ return 0;
}