diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-20 06:43:11 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-22 09:25:08 +0200 |
commit | 2dd5e6fb320a5309e02570fad93d4b5fc09328a7 (patch) | |
tree | 0600823693f0c6d2e521537622d2ac89809765a0 /cpukit/posix/src/semdestroy.c | |
parent | score: Avoid Giant lock for CORE mtx/sem (diff) | |
download | rtems-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/semdestroy.c')
-rw-r--r-- | cpukit/posix/src/semdestroy.c | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/cpukit/posix/src/semdestroy.c b/cpukit/posix/src/semdestroy.c index 751169941b..5264472156 100644 --- a/cpukit/posix/src/semdestroy.c +++ b/cpukit/posix/src/semdestroy.c @@ -26,44 +26,31 @@ int sem_destroy( 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, - &lock_context - ); - switch ( location ) { + the_semaphore = _POSIX_Semaphore_Get( sem, &lock_context ); - case OBJECTS_LOCAL: - _CORE_semaphore_Acquire_critical( - &the_semaphore->Semaphore, - &lock_context - ); + if ( the_semaphore == NULL ) { + _Objects_Allocator_unlock(); + rtems_set_errno_and_return_minus_one( EINVAL ); + } - /* - * Undefined operation on a named semaphore. Release the object - * and fall to the EINVAL return at the bottom. - */ - if ( the_semaphore->named ) { - _CORE_semaphore_Release( &the_semaphore->Semaphore, &lock_context ); - } else { - _POSIX_Semaphore_Delete( the_semaphore, &lock_context ); - _Objects_Allocator_unlock(); - return 0; - } + _CORE_semaphore_Acquire_critical( + &the_semaphore->Semaphore, + &lock_context + ); -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; + if ( the_semaphore->named ) { + /* Undefined operation on a named semaphore */ + _CORE_semaphore_Release( &the_semaphore->Semaphore, &lock_context ); + _Objects_Allocator_unlock(); + rtems_set_errno_and_return_minus_one( EINVAL ); } - _Objects_Allocator_unlock(); + _POSIX_Semaphore_Delete( the_semaphore, &lock_context ); - rtems_set_errno_and_return_minus_one( EINVAL ); + _Objects_Allocator_unlock(); + return 0; } |