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/semgetvalue.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/semgetvalue.c')
-rw-r--r-- | cpukit/posix/src/semgetvalue.c | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/cpukit/posix/src/semgetvalue.c b/cpukit/posix/src/semgetvalue.c index f89526610f..63e3823dff 100644 --- a/cpukit/posix/src/semgetvalue.c +++ b/cpukit/posix/src/semgetvalue.c @@ -18,49 +18,30 @@ #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/posix/semaphoreimpl.h> -#include <rtems/seterr.h> int sem_getvalue( sem_t *__restrict sem, int *__restrict sval ) { - POSIX_Semaphore_Control *the_semaphore; - Objects_Locations location; - ISR_lock_Context lock_context; - - the_semaphore = _POSIX_Semaphore_Get_interrupt_disable( - sem, - &location, - &lock_context - ); - switch ( location ) { + POSIX_Semaphore_Control *the_semaphore; + ISR_lock_Context lock_context; - case OBJECTS_LOCAL: - /* - * Assume a relaxed atomic load of the value on SMP configurations. - * Thus, there is no need to acquire a lock. - */ - *sval = _CORE_semaphore_Get_count( &the_semaphore->Semaphore ); - _ISR_lock_ISR_enable( &lock_context ); - return 0; + the_semaphore = _POSIX_Semaphore_Get( sem, &lock_context ); -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; + if ( the_semaphore == NULL ) { + rtems_set_errno_and_return_minus_one( EINVAL ); } - rtems_set_errno_and_return_minus_one( EINVAL ); + /* + * Assume a relaxed atomic load of the value on SMP configurations. + * Thus, there is no need to acquire a lock. + */ + *sval = _CORE_semaphore_Get_count( &the_semaphore->Semaphore ); + + _ISR_lock_ISR_enable( &lock_context ); + return 0; } |