summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/prwlocktimedwrlock.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-23 13:37:59 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-26 21:44:31 +0200
commitdce487912d98835b8168e755b60514f5a8592b27 (patch)
tree8778547fbb0f2dbb07bb6a83f28d3f4464924141 /cpukit/posix/src/prwlocktimedwrlock.c
parentposix: Fix sem_init() with too large initial value (diff)
downloadrtems-dce487912d98835b8168e755b60514f5a8592b27.tar.bz2
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/prwlocktimedwrlock.c')
-rw-r--r--cpukit/posix/src/prwlocktimedwrlock.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/cpukit/posix/src/prwlocktimedwrlock.c b/cpukit/posix/src/prwlocktimedwrlock.c
index 6be8397ef7..8080a8a920 100644
--- a/cpukit/posix/src/prwlocktimedwrlock.c
+++ b/cpukit/posix/src/prwlocktimedwrlock.c
@@ -21,6 +21,7 @@
#endif
#include <rtems/posix/rwlockimpl.h>
+#include <rtems/posix/posixapi.h>
#include <rtems/score/todimpl.h>
int pthread_rwlock_timedwrlock(
@@ -32,8 +33,8 @@ int pthread_rwlock_timedwrlock(
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
@@ -41,15 +42,15 @@ int pthread_rwlock_timedwrlock(
* 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 );
@@ -57,32 +58,26 @@ int pthread_rwlock_timedwrlock(
return EINVAL;
}
- executing = _Thread_Executing;
- _CORE_RWLock_Seize_for_writing(
+ status = _CORE_RWLock_Seize_for_writing(
&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 );
}