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/condwaitsupp.c | |
parent | posix: Fix sem_init() with too large initial value (diff) | |
download | rtems-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/condwaitsupp.c')
-rw-r--r-- | cpukit/posix/src/condwaitsupp.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c index 4e89ef0b50..9270c36393 100644 --- a/cpukit/posix/src/condwaitsupp.c +++ b/cpukit/posix/src/condwaitsupp.c @@ -20,8 +20,10 @@ #include <rtems/posix/condimpl.h> #include <rtems/posix/muteximpl.h> +#include <rtems/posix/posixapi.h> #include <rtems/score/assert.h> #include <rtems/score/statesimpl.h> +#include <rtems/score/status.h> #include <rtems/score/threaddispatch.h> THREAD_QUEUE_OBJECT_ASSERT( POSIX_Condition_variables_Control, Wait_queue ); @@ -36,9 +38,9 @@ int _POSIX_Condition_variables_Wait_support( POSIX_Condition_variables_Control *the_cond; POSIX_Mutex_Control *the_mutex; Thread_queue_Context queue_context; - int status; - int mutex_status; - CORE_mutex_Status core_mutex_status; + int error; + int mutex_error; + Status_Control status; Per_CPU_Control *cpu_self; Thread_Control *executing; @@ -84,28 +86,23 @@ int _POSIX_Condition_variables_Wait_support( } if ( !already_timedout ) { - executing->Wait.return_code = 0; _Thread_queue_Enqueue_critical( &the_cond->Wait_queue.Queue, POSIX_CONDITION_VARIABLES_TQ_OPERATIONS, executing, STATES_WAITING_FOR_CONDITION_VARIABLE, timeout, - ETIMEDOUT, &queue_context.Lock_context ); } else { _POSIX_Condition_variables_Release( the_cond, &queue_context ); - executing->Wait.return_code = ETIMEDOUT; + executing->Wait.return_code = STATUS_TIMEOUT; } _ISR_lock_ISR_disable( &queue_context.Lock_context ); - core_mutex_status = _CORE_mutex_Surrender( - &the_mutex->Mutex, - &queue_context - ); - _Assert( core_mutex_status == CORE_MUTEX_STATUS_SUCCESSFUL ); - (void) core_mutex_status; + status = _CORE_mutex_Surrender( &the_mutex->Mutex, &queue_context ); + _Assert( status == STATUS_SUCCESSFUL ); + (void) status; /* * Switch ourself out because we blocked as a result of the @@ -114,7 +111,7 @@ int _POSIX_Condition_variables_Wait_support( _Thread_Dispatch_enable( cpu_self ); - status = (int) executing->Wait.return_code; + error = _POSIX_Get_error_after_wait( executing ); /* * If the thread is interrupted, while in the thread queue, by @@ -124,18 +121,18 @@ int _POSIX_Condition_variables_Wait_support( * woken up a pthread_cond_signal() or a pthread_cond_broadcast(). */ - if ( status == EINTR ) { - status = 0; + if ( error == EINTR ) { + error = 0; } /* * When we get here the dispatch disable level is 0. */ - mutex_status = pthread_mutex_lock( mutex ); - if ( mutex_status != 0 ) { + mutex_error = pthread_mutex_lock( mutex ); + if ( mutex_error != 0 ) { return EINVAL; } - return status; + return error; } |