diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-23 13:37:59 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-26 21:44:31 +0200 |
commit | dce487912d98835b8168e755b60514f5a8592b27 (patch) | |
tree | 8778547fbb0f2dbb07bb6a83f28d3f4464924141 /cpukit/posix/src/prwlocktimedrdlock.c | |
parent | d887c1b5b30733fd2d6cf07a4a264f57ab9f4b4b (diff) |
score: Add Status_Control for all APIs
Unify the status codes of the Classic and POSIX API to use the new enum
Status_Control. This eliminates the Thread_Control::Wait::timeout_code
field and the timeout parameter of _Thread_queue_Enqueue_critical() and
_MPCI_Send_request_packet(). It gets rid of the status code translation
tables and instead uses simple bit operations to get the status for a
particular API. This enables translation of status code constants at
compile time. Add _Thread_Wait_get_status() to avoid direct access of
thread internal data structures.
Diffstat (limited to 'cpukit/posix/src/prwlocktimedrdlock.c')
-rw-r--r-- | cpukit/posix/src/prwlocktimedrdlock.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/cpukit/posix/src/prwlocktimedrdlock.c b/cpukit/posix/src/prwlocktimedrdlock.c index 9e849438dd..1c1059051b 100644 --- a/cpukit/posix/src/prwlocktimedrdlock.c +++ b/cpukit/posix/src/prwlocktimedrdlock.c @@ -19,6 +19,7 @@ #endif #include <rtems/posix/rwlockimpl.h> +#include <rtems/posix/posixapi.h> #include <rtems/score/todimpl.h> int pthread_rwlock_timedrdlock( @@ -30,8 +31,8 @@ int pthread_rwlock_timedrdlock( Thread_queue_Context queue_context; Watchdog_Interval ticks; bool do_wait; - TOD_Absolute_timeout_conversion_results status; - Thread_Control *executing; + TOD_Absolute_timeout_conversion_results timeout_status; + Status_Control status; /* * POSIX requires that blocking calls with timeouts that take @@ -39,15 +40,15 @@ int pthread_rwlock_timedrdlock( * time provided if the operation would otherwise succeed. * So we check the abstime provided, and hold on to whether it * is valid or not. If it isn't correct and in the future, - * then we do a polling operation and convert the UNSATISFIED + * then we do a polling operation and convert the STATUS_UNAVAILABLE * status into the appropriate error. * - * If the status is TOD_ABSOLUTE_TIMEOUT_INVALID, + * If the timeout status is TOD_ABSOLUTE_TIMEOUT_INVALID, * TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST, or TOD_ABSOLUTE_TIMEOUT_IS_NOW, * then we should not wait. */ - status = _TOD_Absolute_timeout_to_ticks( abstime, &ticks ); - do_wait = ( status == TOD_ABSOLUTE_TIMEOUT_IS_IN_FUTURE ); + timeout_status = _TOD_Absolute_timeout_to_ticks( abstime, &ticks ); + do_wait = ( timeout_status == TOD_ABSOLUTE_TIMEOUT_IS_IN_FUTURE ); the_rwlock = _POSIX_RWLock_Get( rwlock, &queue_context ); @@ -55,32 +56,26 @@ int pthread_rwlock_timedrdlock( return EINVAL; } - executing = _Thread_Executing; - _CORE_RWLock_Seize_for_reading( + status = _CORE_RWLock_Seize_for_reading( &the_rwlock->RWLock, - executing, + _Thread_Executing, do_wait, ticks, &queue_context ); - if ( - !do_wait - && ( executing->Wait.return_code == CORE_RWLOCK_UNAVAILABLE ) - ) { - if ( status == TOD_ABSOLUTE_TIMEOUT_INVALID ) { + if ( !do_wait && status == STATUS_UNAVAILABLE ) { + if ( timeout_status == TOD_ABSOLUTE_TIMEOUT_INVALID ) { return EINVAL; } if ( - status == TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST - || status == TOD_ABSOLUTE_TIMEOUT_IS_NOW + timeout_status == TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST + || timeout_status == TOD_ABSOLUTE_TIMEOUT_IS_NOW ) { return ETIMEDOUT; } } - return _POSIX_RWLock_Translate_core_RWLock_return_code( - (CORE_RWLock_Status) executing->Wait.return_code - ); + return _POSIX_Get_error( status ); } |