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/score/src | |
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 '')
25 files changed, 109 insertions, 156 deletions
diff --git a/cpukit/score/src/condition.c b/cpukit/score/src/condition.c index c0320b28d4..39924e8c92 100644 --- a/cpukit/score/src/condition.c +++ b/cpukit/score/src/condition.c @@ -91,14 +91,12 @@ static Per_CPU_Control *_Condition_Do_wait( executing = _Condition_Queue_acquire_critical( condition, lock_context ); cpu_self = _Thread_Dispatch_disable_critical( lock_context ); - executing->Wait.return_code = 0; _Thread_queue_Enqueue_critical( &condition->Queue.Queue, CONDITION_TQ_OPERATIONS, executing, STATES_WAITING_FOR_SYS_LOCK_CONDITION, timeout, - ETIMEDOUT, lock_context ); @@ -152,7 +150,7 @@ int _Condition_Wait_timed( _Mutex_Release( _mutex ); executing = cpu_self->executing; _Thread_Dispatch_enable( cpu_self ); - eno = (int) executing->Wait.return_code; + eno = STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) ); _Mutex_Acquire( _mutex ); return eno; @@ -212,7 +210,7 @@ int _Condition_Wait_recursive_timed( _Mutex_recursive_Release( _mutex ); executing = cpu_self->executing; _Thread_Dispatch_enable( cpu_self ); - eno = (int) executing->Wait.return_code; + eno = STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) ); _Mutex_recursive_Acquire( _mutex ); _mutex->_nest_level = nest_level; diff --git a/cpukit/score/src/corebarrier.c b/cpukit/score/src/corebarrier.c index a32f88c46b..8da3ca1063 100644 --- a/cpukit/score/src/corebarrier.c +++ b/cpukit/score/src/corebarrier.c @@ -31,14 +31,3 @@ void _CORE_barrier_Initialize( _Thread_queue_Initialize( &the_barrier->Wait_queue ); } - -Thread_Control *_CORE_barrier_Was_deleted( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -) -{ - the_thread->Wait.return_code = CORE_BARRIER_WAS_DELETED; - - return the_thread; -} diff --git a/cpukit/score/src/corebarrierwait.c b/cpukit/score/src/corebarrierwait.c index 33f1718a66..a1c862d293 100644 --- a/cpukit/score/src/corebarrierwait.c +++ b/cpukit/score/src/corebarrierwait.c @@ -20,8 +20,9 @@ #include <rtems/score/corebarrierimpl.h> #include <rtems/score/statesimpl.h> +#include <rtems/score/threadimpl.h> -void _CORE_barrier_Seize( +Status_Control _CORE_barrier_Seize( CORE_barrier_Control *the_barrier, Thread_Control *executing, bool wait, @@ -31,8 +32,6 @@ void _CORE_barrier_Seize( { uint32_t number_of_waiting_threads; - executing->Wait.return_code = CORE_BARRIER_STATUS_SUCCESSFUL; - _CORE_barrier_Acquire_critical( the_barrier, queue_context ); number_of_waiting_threads = the_barrier->number_of_waiting_threads; @@ -42,8 +41,8 @@ void _CORE_barrier_Seize( _CORE_barrier_Is_automatic( &the_barrier->Attributes ) && number_of_waiting_threads == the_barrier->Attributes.maximum_count ) { - executing->Wait.return_code = CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED; _CORE_barrier_Surrender( the_barrier, queue_context ); + return STATUS_BARRIER_AUTOMATICALLY_RELEASED; } else { the_barrier->number_of_waiting_threads = number_of_waiting_threads; _Thread_queue_Enqueue_critical( @@ -52,8 +51,8 @@ void _CORE_barrier_Seize( executing, STATES_WAITING_FOR_BARRIER, timeout, - CORE_BARRIER_TIMEOUT, &queue_context->Lock_context ); + return _Thread_Wait_get_status( executing ); } } diff --git a/cpukit/score/src/coremsgbroadcast.c b/cpukit/score/src/coremsgbroadcast.c index 23dd343c05..f7579c2d98 100644 --- a/cpukit/score/src/coremsgbroadcast.c +++ b/cpukit/score/src/coremsgbroadcast.c @@ -21,7 +21,7 @@ #include <rtems/score/coremsgimpl.h> #include <rtems/score/objectimpl.h> -CORE_message_queue_Status _CORE_message_queue_Broadcast( +Status_Control _CORE_message_queue_Broadcast( CORE_message_queue_Control *the_message_queue, const void *buffer, size_t size, @@ -34,7 +34,7 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast( if ( size > the_message_queue->maximum_message_size ) { _ISR_lock_ISR_enable( &queue_context->Lock_context ); - return CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE; + return STATUS_MESSAGE_INVALID_SIZE; } number_broadcasted = 0; @@ -60,5 +60,5 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast( _CORE_message_queue_Release( the_message_queue, queue_context ); *count = number_broadcasted; - return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL; + return STATUS_SUCCESSFUL; } diff --git a/cpukit/score/src/coremsgclose.c b/cpukit/score/src/coremsgclose.c index e24d756002..f8a53a2fcd 100644 --- a/cpukit/score/src/coremsgclose.c +++ b/cpukit/score/src/coremsgclose.c @@ -27,7 +27,7 @@ static Thread_Control *_CORE_message_queue_Was_deleted( Thread_queue_Context *queue_context ) { - the_thread->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED; + the_thread->Wait.return_code = STATUS_MESSAGE_QUEUE_WAS_DELETED; return the_thread; } diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c index b05ddd63f3..00ff437e01 100644 --- a/cpukit/score/src/coremsgseize.c +++ b/cpukit/score/src/coremsgseize.c @@ -22,10 +22,10 @@ #include <rtems/score/chain.h> #include <rtems/score/isr.h> #include <rtems/score/coremsgimpl.h> -#include <rtems/score/thread.h> +#include <rtems/score/threadimpl.h> #include <rtems/score/statesimpl.h> -void _CORE_message_queue_Seize( +Status_Control _CORE_message_queue_Seize( CORE_message_queue_Control *the_message_queue, Thread_Control *executing, void *buffer, @@ -37,7 +37,6 @@ void _CORE_message_queue_Seize( { CORE_message_queue_Buffer_control *the_message; - executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL; the_message = _CORE_message_queue_Get_pending_message( the_message_queue ); if ( the_message != NULL ) { the_message_queue->number_of_pending_messages -= 1; @@ -58,7 +57,7 @@ void _CORE_message_queue_Seize( */ _CORE_message_queue_Free_message_buffer(the_message_queue, the_message); _CORE_message_queue_Release( the_message_queue, queue_context ); - return; + return STATUS_SUCCESSFUL; #else { Thread_Control *the_thread; @@ -80,7 +79,7 @@ void _CORE_message_queue_Seize( the_message ); _CORE_message_queue_Release( the_message_queue, queue_context ); - return; + return STATUS_SUCCESSFUL; } /* @@ -101,15 +100,14 @@ void _CORE_message_queue_Seize( the_thread, queue_context ); - return; + return STATUS_SUCCESSFUL; } #endif } if ( !wait ) { _CORE_message_queue_Release( the_message_queue, queue_context ); - executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT; - return; + return STATUS_UNSATISFIED; } executing->Wait.return_argument_second.mutable_object = buffer; @@ -122,7 +120,7 @@ void _CORE_message_queue_Seize( executing, STATES_WAITING_FOR_MESSAGE, timeout, - CORE_MESSAGE_QUEUE_STATUS_TIMEOUT, &queue_context->Lock_context ); + return _Thread_Wait_get_status( executing ); } diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c index a86774175f..a623291776 100644 --- a/cpukit/score/src/coremsgsubmit.c +++ b/cpukit/score/src/coremsgsubmit.c @@ -22,10 +22,11 @@ #include <rtems/score/coremsgimpl.h> #include <rtems/score/objectimpl.h> #include <rtems/score/isr.h> +#include <rtems/score/threadimpl.h> #include <rtems/score/statesimpl.h> #include <rtems/score/wkspace.h> -CORE_message_queue_Status _CORE_message_queue_Submit( +Status_Control _CORE_message_queue_Submit( CORE_message_queue_Control *the_message_queue, Thread_Control *executing, const void *buffer, @@ -41,7 +42,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit( if ( size > the_message_queue->maximum_message_size ) { _CORE_message_queue_Release( the_message_queue, queue_context ); - return CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE; + return STATUS_MESSAGE_INVALID_SIZE; } /* @@ -56,7 +57,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit( queue_context ); if ( the_thread != NULL ) { - return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL; + return STATUS_SUCCESSFUL; } /* @@ -95,12 +96,12 @@ CORE_message_queue_Status _CORE_message_queue_Submit( _CORE_message_queue_Release( the_message_queue, queue_context ); #endif - return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL; + return STATUS_SUCCESSFUL; } #if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND) _CORE_message_queue_Release( the_message_queue, queue_context ); - return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY; + return STATUS_TOO_MANY; #else /* * No message buffers were available so we may need to return an @@ -109,7 +110,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit( */ if ( !wait ) { _CORE_message_queue_Release( the_message_queue, queue_context ); - return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY; + return STATUS_TOO_MANY; } /* @@ -118,7 +119,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit( */ if ( _ISR_Is_in_progress() ) { _CORE_message_queue_Release( the_message_queue, queue_context ); - return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED; + return STATUS_MESSAGE_QUEUE_WAIT_IN_ISR; } /* @@ -127,7 +128,6 @@ CORE_message_queue_Status _CORE_message_queue_Submit( * it as a variable. Doing this emphasizes how dangerous it * would be to use this variable prior to here. */ - executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL; executing->Wait.return_argument_second.immutable_object = buffer; executing->Wait.option = (uint32_t) size; executing->Wait.count = submit_type; @@ -138,9 +138,8 @@ CORE_message_queue_Status _CORE_message_queue_Submit( executing, STATES_WAITING_FOR_MESSAGE, timeout, - CORE_MESSAGE_QUEUE_STATUS_TIMEOUT, &queue_context->Lock_context ); - return executing->Wait.return_code; + return _Thread_Wait_get_status( executing ); #endif } diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c index ecca2441e0..ec073ff999 100644 --- a/cpukit/score/src/coremutex.c +++ b/cpukit/score/src/coremutex.c @@ -23,7 +23,7 @@ #include <rtems/score/coremuteximpl.h> #include <rtems/score/thread.h> -CORE_mutex_Status _CORE_mutex_Initialize( +Status_Control _CORE_mutex_Initialize( CORE_mutex_Control *the_mutex, Thread_Control *executing, const CORE_mutex_Attributes *the_mutex_attributes, @@ -64,7 +64,7 @@ CORE_mutex_Status _CORE_mutex_Initialize( * the object creation. */ _Thread_Dispatch_enable( cpu_self ); - return CORE_MUTEX_STATUS_CEILING_VIOLATED; + return STATUS_MUTEX_CEILING_VIOLATED; } executing->resource_count++; @@ -88,27 +88,5 @@ CORE_mutex_Status _CORE_mutex_Initialize( the_mutex->operations = &_Thread_queue_Operations_priority; } - return CORE_MUTEX_STATUS_SUCCESSFUL; -} - -Thread_Control *_CORE_mutex_Was_deleted( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -) -{ - the_thread->Wait.return_code = CORE_MUTEX_WAS_DELETED; - - return the_thread; -} - -Thread_Control *_CORE_mutex_Unsatisfied_nowait( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -) -{ - the_thread->Wait.return_code = CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT; - - return the_thread; + return STATUS_SUCCESSFUL; } diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c index 168d69716f..0fc63f4693 100644 --- a/cpukit/score/src/coremutexseize.c +++ b/cpukit/score/src/coremutexseize.c @@ -24,7 +24,7 @@ #include <rtems/score/statesimpl.h> #include <rtems/score/thread.h> -void _CORE_mutex_Seize_interrupt_blocking( +Status_Control _CORE_mutex_Seize_interrupt_blocking( CORE_mutex_Control *the_mutex, Thread_Control *executing, Watchdog_Interval timeout, @@ -67,12 +67,13 @@ void _CORE_mutex_Seize_interrupt_blocking( executing, STATES_WAITING_FOR_MUTEX, timeout, - CORE_MUTEX_TIMEOUT, lock_context ); #if !defined(RTEMS_SMP) _Thread_Dispatch_enable( _Per_CPU_Get() ); #endif + + return _Thread_Wait_get_status( executing ); } diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c index 040a580592..1da98276bf 100644 --- a/cpukit/score/src/coremutexsurrender.c +++ b/cpukit/score/src/coremutexsurrender.c @@ -23,7 +23,7 @@ #include <rtems/score/coremuteximpl.h> #include <rtems/score/thread.h> -CORE_mutex_Status _CORE_mutex_Surrender( +Status_Control _CORE_mutex_Surrender( CORE_mutex_Control *the_mutex, Thread_queue_Context *queue_context ) @@ -44,7 +44,7 @@ CORE_mutex_Status _CORE_mutex_Surrender( if ( the_mutex->Attributes.only_owner_release ) { if ( !_Thread_Is_executing( holder ) ) { _ISR_lock_ISR_enable( &queue_context->Lock_context ); - return CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE; + return STATUS_NOT_OWNER; } } @@ -54,7 +54,7 @@ CORE_mutex_Status _CORE_mutex_Surrender( if ( !the_mutex->nest_count ) { _CORE_mutex_Release( the_mutex, queue_context ); - return CORE_MUTEX_STATUS_SUCCESSFUL; + return STATUS_SUCCESSFUL; } the_mutex->nest_count--; @@ -69,12 +69,12 @@ CORE_mutex_Status _CORE_mutex_Surrender( switch ( the_mutex->Attributes.lock_nesting_behavior ) { case CORE_MUTEX_NESTING_ACQUIRES: _CORE_mutex_Release( the_mutex, queue_context ); - return CORE_MUTEX_STATUS_SUCCESSFUL; + return STATUS_SUCCESSFUL; #if defined(RTEMS_POSIX_API) case CORE_MUTEX_NESTING_IS_ERROR: /* should never occur */ _CORE_mutex_Release( the_mutex, queue_context ); - return CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED; + return STATUS_NESTING_NOT_ALLOWED; #endif case CORE_MUTEX_NESTING_BLOCKS: /* Currently no API exercises this behavior. */ @@ -83,7 +83,7 @@ CORE_mutex_Status _CORE_mutex_Surrender( #else _CORE_mutex_Release( the_mutex, queue_context ); /* must be CORE_MUTEX_NESTING_ACQUIRES or we wouldn't be here */ - return CORE_MUTEX_STATUS_SUCCESSFUL; + return STATUS_SUCCESSFUL; #endif } @@ -179,5 +179,5 @@ CORE_mutex_Status _CORE_mutex_Surrender( } } - return CORE_MUTEX_STATUS_SUCCESSFUL; + return STATUS_SUCCESSFUL; } diff --git a/cpukit/score/src/corerwlockobtainread.c b/cpukit/score/src/corerwlockobtainread.c index 639ea7052d..5192eb1f8f 100644 --- a/cpukit/score/src/corerwlockobtainread.c +++ b/cpukit/score/src/corerwlockobtainread.c @@ -19,11 +19,12 @@ #endif #include <rtems/score/corerwlockimpl.h> +#include <rtems/score/threadimpl.h> #include <rtems/score/threadqimpl.h> #include <rtems/score/statesimpl.h> #include <rtems/score/watchdog.h> -void _CORE_RWLock_Seize_for_reading( +Status_Control _CORE_RWLock_Seize_for_reading( CORE_RWLock_Control *the_rwlock, Thread_Control *executing, bool wait, @@ -44,8 +45,7 @@ void _CORE_RWLock_Seize_for_reading( the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_READING; the_rwlock->number_of_readers += 1; _CORE_RWLock_Release( the_rwlock, queue_context ); - executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL; - return; + return STATUS_SUCCESSFUL; case CORE_RWLOCK_LOCKED_FOR_READING: { Thread_Control *waiter; @@ -56,8 +56,7 @@ void _CORE_RWLock_Seize_for_reading( if ( !waiter ) { the_rwlock->number_of_readers += 1; _CORE_RWLock_Release( the_rwlock, queue_context ); - executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL; - return; + return STATUS_SUCCESSFUL; } break; } @@ -71,16 +70,14 @@ void _CORE_RWLock_Seize_for_reading( if ( !wait ) { _CORE_RWLock_Release( the_rwlock, queue_context ); - executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE; - return; + return STATUS_UNAVAILABLE; } /* * We need to wait to enter this critical section */ - executing->Wait.option = CORE_RWLOCK_THREAD_WAITING_FOR_READ; - executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL; + executing->Wait.option = CORE_RWLOCK_THREAD_WAITING_FOR_READ; _Thread_queue_Enqueue_critical( &the_rwlock->Wait_queue.Queue, @@ -88,7 +85,7 @@ void _CORE_RWLock_Seize_for_reading( executing, STATES_WAITING_FOR_RWLOCK, timeout, - CORE_RWLOCK_TIMEOUT, &queue_context->Lock_context ); + return _Thread_Wait_get_status( executing ); } diff --git a/cpukit/score/src/corerwlockobtainwrite.c b/cpukit/score/src/corerwlockobtainwrite.c index a7d1bb1b6a..0536b8287f 100644 --- a/cpukit/score/src/corerwlockobtainwrite.c +++ b/cpukit/score/src/corerwlockobtainwrite.c @@ -19,11 +19,12 @@ #endif #include <rtems/score/corerwlockimpl.h> +#include <rtems/score/threadimpl.h> #include <rtems/score/threadqimpl.h> #include <rtems/score/statesimpl.h> #include <rtems/score/watchdog.h> -void _CORE_RWLock_Seize_for_writing( +Status_Control _CORE_RWLock_Seize_for_writing( CORE_RWLock_Control *the_rwlock, Thread_Control *executing, bool wait, @@ -44,8 +45,7 @@ void _CORE_RWLock_Seize_for_writing( case CORE_RWLOCK_UNLOCKED: the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING; _CORE_RWLock_Release( the_rwlock, queue_context ); - executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL; - return; + return STATUS_SUCCESSFUL; case CORE_RWLOCK_LOCKED_FOR_READING: case CORE_RWLOCK_LOCKED_FOR_WRITING: @@ -58,16 +58,14 @@ void _CORE_RWLock_Seize_for_writing( if ( !wait ) { _CORE_RWLock_Release( the_rwlock, queue_context ); - executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE; - return; + return STATUS_UNAVAILABLE; } /* * We need to wait to enter this critical section */ - executing->Wait.option = CORE_RWLOCK_THREAD_WAITING_FOR_WRITE; - executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL; + executing->Wait.option = CORE_RWLOCK_THREAD_WAITING_FOR_WRITE; _Thread_queue_Enqueue_critical( &the_rwlock->Wait_queue.Queue, @@ -75,7 +73,7 @@ void _CORE_RWLock_Seize_for_writing( executing, STATES_WAITING_FOR_RWLOCK, timeout, - CORE_RWLOCK_TIMEOUT, &queue_context->Lock_context ); + return _Thread_Wait_get_status( executing ); } diff --git a/cpukit/score/src/corerwlockrelease.c b/cpukit/score/src/corerwlockrelease.c index 81e01d1b67..71aa12a190 100644 --- a/cpukit/score/src/corerwlockrelease.c +++ b/cpukit/score/src/corerwlockrelease.c @@ -73,7 +73,7 @@ static Thread_Control *_CORE_RWLock_Flush_filter( return the_thread; } -CORE_RWLock_Status _CORE_RWLock_Surrender( +Status_Control _CORE_RWLock_Surrender( CORE_RWLock_Control *the_rwlock, Thread_queue_Context *queue_context ) @@ -90,7 +90,7 @@ CORE_RWLock_Status _CORE_RWLock_Surrender( if ( the_rwlock->current_state == CORE_RWLOCK_UNLOCKED){ /* This is an error at the caller site */ _CORE_RWLock_Release( the_rwlock, queue_context ); - return CORE_RWLOCK_SUCCESSFUL; + return STATUS_SUCCESSFUL; } if ( the_rwlock->current_state == CORE_RWLOCK_LOCKED_FOR_READING ) { @@ -99,7 +99,7 @@ CORE_RWLock_Status _CORE_RWLock_Surrender( if ( the_rwlock->number_of_readers != 0 ) { /* must be unlocked again */ _CORE_RWLock_Release( the_rwlock, queue_context ); - return CORE_RWLOCK_SUCCESSFUL; + return STATUS_SUCCESSFUL; } } @@ -121,5 +121,5 @@ CORE_RWLock_Status _CORE_RWLock_Surrender( _CORE_RWLock_Flush_filter, queue_context ); - return CORE_RWLOCK_SUCCESSFUL; + return STATUS_SUCCESSFUL; } diff --git a/cpukit/score/src/coresem.c b/cpukit/score/src/coresem.c index c94f2b7e86..2bdd81c76a 100644 --- a/cpukit/score/src/coresem.c +++ b/cpukit/score/src/coresem.c @@ -36,25 +36,3 @@ void _CORE_semaphore_Initialize( the_semaphore->operations = &_Thread_queue_Operations_FIFO; } } - -Thread_Control *_CORE_semaphore_Was_deleted( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -) -{ - the_thread->Wait.return_code = CORE_SEMAPHORE_WAS_DELETED; - - return the_thread; -} - -Thread_Control *_CORE_semaphore_Unsatisfied_nowait( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -) -{ - the_thread->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT; - - return the_thread; -} diff --git a/cpukit/score/src/corespinlockrelease.c b/cpukit/score/src/corespinlockrelease.c index 6f2ea71ac2..4a4f9528b3 100644 --- a/cpukit/score/src/corespinlockrelease.c +++ b/cpukit/score/src/corespinlockrelease.c @@ -21,7 +21,7 @@ #include <rtems/score/corespinlockimpl.h> #include <rtems/score/percpu.h> -CORE_spinlock_Status _CORE_spinlock_Surrender( +Status_Control _CORE_spinlock_Surrender( CORE_spinlock_Control *the_spinlock, ISR_lock_Context *lock_context ) @@ -36,7 +36,7 @@ CORE_spinlock_Status _CORE_spinlock_Surrender( || the_spinlock->holder != _Thread_Executing ) { _CORE_spinlock_Release( the_spinlock, lock_context ); - return CORE_SPINLOCK_NOT_HOLDER; + return STATUS_NOT_OWNER; } /* @@ -47,5 +47,5 @@ CORE_spinlock_Status _CORE_spinlock_Surrender( the_spinlock->holder = 0; _CORE_spinlock_Release( the_spinlock, lock_context ); - return CORE_SPINLOCK_SUCCESSFUL; + return STATUS_SUCCESSFUL; } diff --git a/cpukit/score/src/corespinlockwait.c b/cpukit/score/src/corespinlockwait.c index cc939c2344..4aacb60b74 100644 --- a/cpukit/score/src/corespinlockwait.c +++ b/cpukit/score/src/corespinlockwait.c @@ -21,7 +21,7 @@ #include <rtems/score/corespinlockimpl.h> #include <rtems/score/percpu.h> -CORE_spinlock_Status _CORE_spinlock_Seize( +Status_Control _CORE_spinlock_Seize( CORE_spinlock_Control *the_spinlock, bool wait, Watchdog_Interval timeout, @@ -40,7 +40,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize( if ( the_spinlock->lock == CORE_SPINLOCK_LOCKED && the_spinlock->holder == executing ) { _CORE_spinlock_Release( the_spinlock, lock_context ); - return CORE_SPINLOCK_HOLDER_RELOCKING; + return STATUS_NESTING_NOT_ALLOWED; } the_spinlock->users += 1; for ( ;; ) { @@ -48,7 +48,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize( the_spinlock->lock = CORE_SPINLOCK_LOCKED; the_spinlock->holder = executing; _CORE_spinlock_Release( the_spinlock, lock_context ); - return CORE_SPINLOCK_SUCCESSFUL; + return STATUS_SUCCESSFUL; } /* @@ -57,7 +57,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize( if ( !wait ) { the_spinlock->users -= 1; _CORE_spinlock_Release( the_spinlock, lock_context ); - return CORE_SPINLOCK_UNAVAILABLE; + return STATUS_UNAVAILABLE; } #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API) @@ -67,7 +67,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize( if ( timeout && (limit <= _Watchdog_Ticks_since_boot) ) { the_spinlock->users -= 1; _CORE_spinlock_Release( the_spinlock, lock_context ); - return CORE_SPINLOCK_TIMEOUT; + return STATUS_TIMEOUT; } #endif diff --git a/cpukit/score/src/futex.c b/cpukit/score/src/futex.c index d7945d12ee..980c7fbccc 100644 --- a/cpukit/score/src/futex.c +++ b/cpukit/score/src/futex.c @@ -90,8 +90,7 @@ int _Futex_Wait( struct _Futex_Control *_futex, int *uaddr, int val ) FUTEX_TQ_OPERATIONS, executing, STATES_WAITING_FOR_SYS_LOCK_FUTEX, - 0, - 0, + WATCHDOG_NO_TIMEOUT, &lock_context ); eno = 0; diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c index 3442bbd2c7..78d8e657fa 100644 --- a/cpukit/score/src/mpci.c +++ b/cpukit/score/src/mpci.c @@ -225,11 +225,10 @@ void _MPCI_Send_process_packet ( (*_MPCI_table->send_packet)( destination, the_packet ); } -uint32_t _MPCI_Send_request_packet ( - uint32_t destination, - MP_packet_Prefix *the_packet, - States_Control extra_state, - uint32_t timeout_code +Status_Control _MPCI_Send_request_packet( + uint32_t destination, + MP_packet_Prefix *the_packet, + States_Control extra_state ) { Per_CPU_Control *cpu_self; @@ -260,13 +259,12 @@ uint32_t _MPCI_Send_request_packet ( &_Thread_queue_Operations_FIFO, executing, STATES_WAITING_FOR_RPC_REPLY | extra_state, - the_packet->timeout, - timeout_code + the_packet->timeout ); _Thread_Dispatch_enable( cpu_self ); - return executing->Wait.return_code; + return _Thread_Wait_get_status( executing ); } void _MPCI_Send_response_packet ( diff --git a/cpukit/score/src/mutex.c b/cpukit/score/src/mutex.c index 0b12232145..28936d6bfc 100644 --- a/cpukit/score/src/mutex.c +++ b/cpukit/score/src/mutex.c @@ -119,7 +119,6 @@ static void _Mutex_Acquire_slow( executing, STATES_WAITING_FOR_SYS_LOCK_MUTEX, timeout, - ETIMEDOUT, lock_context ); } @@ -262,10 +261,9 @@ int _Mutex_Acquire_timed( break; } - executing->Wait.return_code = 0; _Mutex_Acquire_slow( mutex, owner, executing, ticks, &lock_context ); - return (int) executing->Wait.return_code; + return STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) ); } } @@ -382,7 +380,6 @@ int _Mutex_recursive_Acquire_timed( break; } - executing->Wait.return_code = 0; _Mutex_Acquire_slow( &mutex->Mutex, owner, @@ -391,7 +388,7 @@ int _Mutex_recursive_Acquire_timed( &lock_context ); - return (int) executing->Wait.return_code; + return STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) ); } } diff --git a/cpukit/score/src/semaphore.c b/cpukit/score/src/semaphore.c index 3d0d5f53ab..ea0835d7b5 100644 --- a/cpukit/score/src/semaphore.c +++ b/cpukit/score/src/semaphore.c @@ -101,8 +101,7 @@ void _Semaphore_Wait( struct _Semaphore_Control *_sem ) SEMAPHORE_TQ_OPERATIONS, executing, STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE, - 0, - 0, + WATCHDOG_NO_TIMEOUT, &lock_context ); } diff --git a/cpukit/score/src/threadmp.c b/cpukit/score/src/threadmp.c index 177a60894e..a991d03760 100644 --- a/cpukit/score/src/threadmp.c +++ b/cpukit/score/src/threadmp.c @@ -146,7 +146,6 @@ Thread_Control *_Thread_MP_Allocate_proxy ( the_proxy->Wait.return_argument_second = executing->Wait.return_argument_second; the_proxy->Wait.option = executing->Wait.option; the_proxy->Wait.return_code = executing->Wait.return_code; - the_proxy->Wait.timeout_code = executing->Wait.timeout_code; the_proxy->thread_queue_callout = _Thread_queue_MP_callout_do_nothing; diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c index a1a37e1ed1..948275b74c 100644 --- a/cpukit/score/src/threadqenqueue.c +++ b/cpukit/score/src/threadqenqueue.c @@ -22,6 +22,7 @@ #include <rtems/score/assert.h> #include <rtems/score/threaddispatch.h> #include <rtems/score/threadimpl.h> +#include <rtems/score/status.h> #include <rtems/score/watchdogimpl.h> #define THREAD_QUEUE_INTEND_TO_BLOCK \ @@ -39,7 +40,6 @@ void _Thread_queue_Enqueue_critical( Thread_Control *the_thread, States_Control state, Watchdog_Interval timeout, - uint32_t timeout_code, ISR_lock_Context *lock_context ) { @@ -54,6 +54,7 @@ void _Thread_queue_Enqueue_critical( _Thread_Lock_set( the_thread, &queue->Lock ); + the_thread->Wait.return_code = STATUS_SUCCESSFUL; _Thread_Wait_set_queue( the_thread, queue ); _Thread_Wait_set_operations( the_thread, operations ); @@ -72,7 +73,6 @@ void _Thread_queue_Enqueue_critical( * If the thread wants to timeout, then schedule its timer. */ if ( timeout != WATCHDOG_NO_TIMEOUT ) { - _Thread_Wait_set_timeout_code( the_thread, timeout_code ); _Thread_Timer_insert_relative( the_thread, cpu_self, diff --git a/cpukit/score/src/threadqflush.c b/cpukit/score/src/threadqflush.c index 8b23194357..df2859d51f 100644 --- a/cpukit/score/src/threadqflush.c +++ b/cpukit/score/src/threadqflush.c @@ -19,6 +19,7 @@ #endif #include <rtems/score/threadimpl.h> +#include <rtems/score/status.h> Thread_Control *_Thread_queue_Flush_default_filter( Thread_Control *the_thread, @@ -31,6 +32,32 @@ Thread_Control *_Thread_queue_Flush_default_filter( return the_thread; } +Thread_Control *_Thread_queue_Flush_status_object_was_deleted( + Thread_Control *the_thread, + Thread_queue_Queue *queue, + Thread_queue_Context *queue_context +) +{ + the_thread->Wait.return_code = STATUS_OBJECT_WAS_DELETED; + + (void) queue; + (void) queue_context; + return the_thread; +} + +Thread_Control *_Thread_queue_Flush_status_unavailable( + Thread_Control *the_thread, + Thread_queue_Queue *queue, + Thread_queue_Context *queue_context +) +{ + the_thread->Wait.return_code = STATUS_UNAVAILABLE; + + (void) queue; + (void) queue_context; + return the_thread; +} + size_t _Thread_queue_Flush_critical( Thread_queue_Queue *queue, const Thread_queue_Operations *operations, diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c index 52d68de69a..f9636e61c7 100644 --- a/cpukit/score/src/threadrestart.c +++ b/cpukit/score/src/threadrestart.c @@ -443,17 +443,16 @@ static void _Thread_Finalize_life_change( } void _Thread_Join( - Thread_Control *the_thread, - States_Control waiting_for_join, - Thread_Control *executing, - ISR_lock_Context *lock_context + Thread_Control *the_thread, + States_Control waiting_for_join, + Thread_Control *executing, + ISR_lock_Context *lock_context ) { _Assert( the_thread != executing ); _Assert( _Thread_State_is_owner( the_thread ) ); #if defined(RTEMS_POSIX_API) - executing->Wait.return_code = 0; executing->Wait.return_argument = NULL; #endif @@ -463,7 +462,6 @@ void _Thread_Join( executing, waiting_for_join, WATCHDOG_NO_TIMEOUT, - 0, lock_context ); } diff --git a/cpukit/score/src/threadtimeout.c b/cpukit/score/src/threadtimeout.c index 59f6bd97f0..9b5cfa637d 100644 --- a/cpukit/score/src/threadtimeout.c +++ b/cpukit/score/src/threadtimeout.c @@ -20,10 +20,11 @@ #endif #include <rtems/score/threadimpl.h> +#include <rtems/score/status.h> static void _Thread_Do_timeout( Thread_Control *the_thread ) { - the_thread->Wait.return_code = the_thread->Wait.timeout_code; + the_thread->Wait.return_code = STATUS_TIMEOUT; ( *the_thread->Wait.operations->extract )( the_thread->Wait.queue, the_thread |