From b8bdced14d82d07965a6fa45bb80687420bdbd8a Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 18 Apr 2016 17:21:43 +0200 Subject: posix: Simplify _POSIX_Mutex_Get_interrupt_disable Remove superfluous location parameter. --- cpukit/posix/src/mutexget.c | 13 ++++--- cpukit/posix/src/mutexlocksupp.c | 67 ++++++++++------------------------ cpukit/posix/src/mutexsetprioceiling.c | 55 +++++++++------------------- cpukit/posix/src/mutexunlock.c | 45 +++++++---------------- 4 files changed, 58 insertions(+), 122 deletions(-) (limited to 'cpukit/posix/src') diff --git a/cpukit/posix/src/mutexget.c b/cpukit/posix/src/mutexget.c index 5c0cc4264d..9ad226a4f9 100644 --- a/cpukit/posix/src/mutexget.c +++ b/cpukit/posix/src/mutexget.c @@ -68,20 +68,21 @@ POSIX_Mutex_Control *_POSIX_Mutex_Get ( _Objects_Get( &_POSIX_Mutex_Information, (Objects_Id) *mutex, location ); } -POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable ( - pthread_mutex_t *mutex, - Objects_Locations *location, - ISR_lock_Context *lock_context +POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable( + pthread_mutex_t *mutex, + ISR_lock_Context *lock_context ) { - if ( !_POSIX_Mutex_Check_id_and_auto_init( mutex, location ) ) { + Objects_Locations location; + + if ( !_POSIX_Mutex_Check_id_and_auto_init( mutex, &location ) ) { return NULL; } return (POSIX_Mutex_Control *) _Objects_Get_isr_disable( &_POSIX_Mutex_Information, (Objects_Id) *mutex, - location, + &location, lock_context ); } diff --git a/cpukit/posix/src/mutexlocksupp.c b/cpukit/posix/src/mutexlocksupp.c index 9e78c9ea45..3c4e26e04a 100644 --- a/cpukit/posix/src/mutexlocksupp.c +++ b/cpukit/posix/src/mutexlocksupp.c @@ -18,62 +18,35 @@ #include "config.h" #endif -#include -#include - -#include -#include -#include -#include #include -#include THREAD_WAIT_QUEUE_OBJECT_ASSERT( POSIX_Mutex_Control, Mutex.Wait_queue ); -/* - * _POSIX_Mutex_Lock_support - * - * A support routine which implements guts of the blocking, non-blocking, and - * timed wait version of mutex lock. - */ - int _POSIX_Mutex_Lock_support( - pthread_mutex_t *mutex, - bool blocking, - Watchdog_Interval timeout + pthread_mutex_t *mutex, + bool blocking, + Watchdog_Interval timeout ) { - POSIX_Mutex_Control *the_mutex; - Objects_Locations location; - ISR_lock_Context lock_context; - Thread_Control *executing; - - the_mutex = _POSIX_Mutex_Get_interrupt_disable( - mutex, - &location, - &lock_context - ); - switch ( location ) { + POSIX_Mutex_Control *the_mutex; + ISR_lock_Context lock_context; + Thread_Control *executing; - case OBJECTS_LOCAL: - executing = _Thread_Executing; - _CORE_mutex_Seize( - &the_mutex->Mutex, - executing, - blocking, - timeout, - &lock_context - ); - return _POSIX_Mutex_Translate_core_mutex_return_code( - (CORE_mutex_Status) executing->Wait.return_code - ); + the_mutex = _POSIX_Mutex_Get_interrupt_disable( mutex, &lock_context ); -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; + if ( the_mutex == NULL ) { + return EINVAL; } - return EINVAL; + executing = _Thread_Executing; + _CORE_mutex_Seize( + &the_mutex->Mutex, + executing, + blocking, + timeout, + &lock_context + ); + return _POSIX_Mutex_Translate_core_mutex_return_code( + (CORE_mutex_Status) executing->Wait.return_code + ); } diff --git a/cpukit/posix/src/mutexsetprioceiling.c b/cpukit/posix/src/mutexsetprioceiling.c index 718bfc4167..1f9f5164bb 100644 --- a/cpukit/posix/src/mutexsetprioceiling.c +++ b/cpukit/posix/src/mutexsetprioceiling.c @@ -18,14 +18,7 @@ #include "config.h" #endif -#include -#include - -#include -#include -#include #include -#include /* * 13.6.2 Change the Priority Ceiling of a Mutex, P1003.1c/Draft 10, p. 131 @@ -38,7 +31,6 @@ int pthread_mutex_setprioceiling( ) { register POSIX_Mutex_Control *the_mutex; - Objects_Locations location; Priority_Control the_priority; ISR_lock_Context lock_context; @@ -64,36 +56,25 @@ int pthread_mutex_setprioceiling( * NOTE: This makes it easier to get 100% binary coverage since the * bad Id case is handled by the switch. */ - the_mutex = _POSIX_Mutex_Get_interrupt_disable( - mutex, - &location, - &lock_context - ); - switch ( location ) { - - case OBJECTS_LOCAL: - *old_ceiling = _POSIX_Priority_From_core( - the_mutex->Mutex.Attributes.priority_ceiling - ); - the_mutex->Mutex.Attributes.priority_ceiling = the_priority; - /* - * We are required to unlock the mutex before we return. - */ - _CORE_mutex_Surrender( - &the_mutex->Mutex, - NULL, - 0, - &lock_context - ); + the_mutex = _POSIX_Mutex_Get_interrupt_disable( mutex, &lock_context ); - return 0; - -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: /* impossible to get here */ -#endif - case OBJECTS_ERROR: - break; + if ( the_mutex == NULL ) { + return EINVAL; } - return EINVAL; + *old_ceiling = _POSIX_Priority_From_core( + the_mutex->Mutex.Attributes.priority_ceiling + ); + the_mutex->Mutex.Attributes.priority_ceiling = the_priority; + + /* + * We are required to unlock the mutex before we return. + */ + _CORE_mutex_Surrender( + &the_mutex->Mutex, + NULL, + 0, + &lock_context + ); + return 0; } diff --git a/cpukit/posix/src/mutexunlock.c b/cpukit/posix/src/mutexunlock.c index 1a83a0a241..4de1917648 100644 --- a/cpukit/posix/src/mutexunlock.c +++ b/cpukit/posix/src/mutexunlock.c @@ -18,14 +18,7 @@ #include "config.h" #endif -#include -#include - -#include -#include -#include #include -#include /* * 11.3.3 Locking and Unlocking a Mutex, P1003.1c/Draft 10, p. 93 @@ -37,33 +30,21 @@ int pthread_mutex_unlock( pthread_mutex_t *mutex ) { - register POSIX_Mutex_Control *the_mutex; - Objects_Locations location; - CORE_mutex_Status status; - ISR_lock_Context lock_context; - - the_mutex = _POSIX_Mutex_Get_interrupt_disable( - mutex, - &location, - &lock_context - ); - switch ( location ) { + POSIX_Mutex_Control *the_mutex; + CORE_mutex_Status status; + ISR_lock_Context lock_context; - case OBJECTS_LOCAL: - status = _CORE_mutex_Surrender( - &the_mutex->Mutex, - NULL, - 0, - &lock_context - ); - return _POSIX_Mutex_Translate_core_mutex_return_code( status ); + the_mutex = _POSIX_Mutex_Get_interrupt_disable( mutex, &lock_context ); -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; + if ( the_mutex == NULL ) { + return EINVAL; } - return EINVAL; + status = _CORE_mutex_Surrender( + &the_mutex->Mutex, + NULL, + 0, + &lock_context + ); + return _POSIX_Mutex_Translate_core_mutex_return_code( status ); } -- cgit v1.2.3