score: Simplify _CORE_mutex_Seize_interrupt_try*

This commit is contained in:
Sebastian Huber
2013-06-05 17:13:14 +02:00
parent dcb4daf8e1
commit 4f5baffd75
3 changed files with 17 additions and 17 deletions

View File

@@ -281,7 +281,7 @@ CORE_mutex_Status _CORE_mutex_Initialize(
* available. * available.
* *
* @param[in] the_mutex is the mutex to attempt to lock * @param[in] the_mutex is the mutex to attempt to lock
* @param[in] level_p is the interrupt level holder * @param[in] level is the interrupt level
* *
* @retval This routine returns 0 if "trylock" can resolve whether or not * @retval This routine returns 0 if "trylock" can resolve whether or not
* the mutex is immediately obtained or there was an error attempting to * the mutex is immediately obtained or there was an error attempting to
@@ -294,7 +294,7 @@ CORE_mutex_Status _CORE_mutex_Initialize(
RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body( RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
CORE_mutex_Control *the_mutex, CORE_mutex_Control *the_mutex,
ISR_Level *level_p ISR_Level level
); );
#if defined(__RTEMS_DO_NOT_INLINE_CORE_MUTEX_SEIZE__) #if defined(__RTEMS_DO_NOT_INLINE_CORE_MUTEX_SEIZE__)
@@ -307,11 +307,11 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
* which makes it harder to get full binary test coverage. * which makes it harder to get full binary test coverage.
* *
* @param[in] the_mutex will attempt to lock * @param[in] the_mutex will attempt to lock
* @param[in] level_p is the interrupt level holder * @param[in] level_p is the interrupt level
*/ */
int _CORE_mutex_Seize_interrupt_trylock( int _CORE_mutex_Seize_interrupt_trylock(
CORE_mutex_Control *the_mutex, CORE_mutex_Control *the_mutex,
ISR_Level *level_p ISR_Level level
); );
#else #else
/** /**
@@ -319,10 +319,10 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
* a few instructions. This is very important for mutex performance. * a few instructions. This is very important for mutex performance.
* *
* @param[in] _mutex will attempt to lock * @param[in] _mutex will attempt to lock
* @param[in] _level_p is the interrupt level holder * @param[in] _level is the interrupt level
*/ */
#define _CORE_mutex_Seize_interrupt_trylock( _mutex, _level_p ) \ #define _CORE_mutex_Seize_interrupt_trylock( _mutex, _level ) \
_CORE_mutex_Seize_interrupt_trylock_body( _mutex, _level_p ) _CORE_mutex_Seize_interrupt_trylock_body( _mutex, _level )
#endif #endif
/** /**
@@ -394,7 +394,7 @@ void _CORE_mutex_Seize_interrupt_blocking(
INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE \ INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE \
); \ ); \
} \ } \
if ( _CORE_mutex_Seize_interrupt_trylock( _the_mutex, &(_level) ) ) { \ if ( _CORE_mutex_Seize_interrupt_trylock( _the_mutex, _level ) ) { \
if ( !(_wait) ) { \ if ( !(_wait) ) { \
_ISR_Enable( _level ); \ _ISR_Enable( _level ); \
_Thread_Executing->Wait.return_code = \ _Thread_Executing->Wait.return_code = \

View File

@@ -130,7 +130,7 @@ RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_priority_ceiling(
RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body( RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
CORE_mutex_Control *the_mutex, CORE_mutex_Control *the_mutex,
ISR_Level *level_p ISR_Level level
) )
{ {
Thread_Control *executing; Thread_Control *executing;
@@ -157,7 +157,7 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
} }
if ( !_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) { if ( !_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
_ISR_Enable( *level_p ); _ISR_Enable( level );
return 0; return 0;
} /* else must be CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING } /* else must be CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING
* *
@@ -171,13 +171,13 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
ceiling = the_mutex->Attributes.priority_ceiling; ceiling = the_mutex->Attributes.priority_ceiling;
current = executing->current_priority; current = executing->current_priority;
if ( current == ceiling ) { if ( current == ceiling ) {
_ISR_Enable( *level_p ); _ISR_Enable( level );
return 0; return 0;
} }
if ( current > ceiling ) { if ( current > ceiling ) {
_Thread_Disable_dispatch(); _Thread_Disable_dispatch();
_ISR_Enable( *level_p ); _ISR_Enable( level );
_Thread_Change_priority( _Thread_Change_priority(
the_mutex->holder, the_mutex->holder,
the_mutex->Attributes.priority_ceiling, the_mutex->Attributes.priority_ceiling,
@@ -191,7 +191,7 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
the_mutex->lock = CORE_MUTEX_UNLOCKED; the_mutex->lock = CORE_MUTEX_UNLOCKED;
the_mutex->nest_count = 0; /* undo locking above */ the_mutex->nest_count = 0; /* undo locking above */
executing->resource_count--; /* undo locking above */ executing->resource_count--; /* undo locking above */
_ISR_Enable( *level_p ); _ISR_Enable( level );
return 0; return 0;
} }
} }
@@ -207,12 +207,12 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
switch ( the_mutex->Attributes.lock_nesting_behavior ) { switch ( the_mutex->Attributes.lock_nesting_behavior ) {
case CORE_MUTEX_NESTING_ACQUIRES: case CORE_MUTEX_NESTING_ACQUIRES:
the_mutex->nest_count++; the_mutex->nest_count++;
_ISR_Enable( *level_p ); _ISR_Enable( level );
return 0; return 0;
#if defined(RTEMS_POSIX_API) #if defined(RTEMS_POSIX_API)
case CORE_MUTEX_NESTING_IS_ERROR: case CORE_MUTEX_NESTING_IS_ERROR:
executing->Wait.return_code = CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED; executing->Wait.return_code = CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED;
_ISR_Enable( *level_p ); _ISR_Enable( level );
return 0; return 0;
#endif #endif
case CORE_MUTEX_NESTING_BLOCKS: case CORE_MUTEX_NESTING_BLOCKS:

View File

@@ -28,9 +28,9 @@
#if defined(__RTEMS_DO_NOT_INLINE_CORE_MUTEX_SEIZE__) #if defined(__RTEMS_DO_NOT_INLINE_CORE_MUTEX_SEIZE__)
int _CORE_mutex_Seize_interrupt_trylock( int _CORE_mutex_Seize_interrupt_trylock(
CORE_mutex_Control *the_mutex, CORE_mutex_Control *the_mutex,
ISR_Level *level_p ISR_Level level
) )
{ {
return _CORE_mutex_Seize_interrupt_trylock_body( the_mutex, level_p ); return _CORE_mutex_Seize_interrupt_trylock_body( the_mutex, level );
} }
#endif #endif