From dce487912d98835b8168e755b60514f5a8592b27 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 23 May 2016 13:37:59 +0200 Subject: 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. --- cpukit/libnetworking/rtems/rtems_glue.c | 16 +-- cpukit/posix/Makefile.am | 13 +- cpukit/posix/include/rtems/posix/barrierimpl.h | 14 -- cpukit/posix/include/rtems/posix/mqueueimpl.h | 8 -- cpukit/posix/include/rtems/posix/muteximpl.h | 42 ------ cpukit/posix/include/rtems/posix/posixapi.h | 25 ++++ cpukit/posix/include/rtems/posix/rwlockimpl.h | 23 ---- cpukit/posix/include/rtems/posix/semaphoreimpl.h | 27 ---- cpukit/posix/include/rtems/posix/spinlockimpl.h | 14 -- cpukit/posix/src/condwaitsupp.c | 33 +++-- cpukit/posix/src/mqueuerecvsupp.c | 12 +- cpukit/posix/src/mqueuesendsupp.c | 15 +-- cpukit/posix/src/mqueuetranslatereturncode.c | 65 --------- cpukit/posix/src/mutexlocksupp.c | 12 +- cpukit/posix/src/mutextranslatereturncode.c | 31 ----- cpukit/posix/src/mutexunlock.c | 5 +- cpukit/posix/src/nanosleep.c | 3 +- cpukit/posix/src/pbarriertranslatereturncode.c | 61 --------- cpukit/posix/src/pbarrierwait.c | 24 +--- cpukit/posix/src/prwlockrdlock.c | 12 +- cpukit/posix/src/prwlocktimedrdlock.c | 33 ++--- cpukit/posix/src/prwlocktimedwrlock.c | 33 ++--- cpukit/posix/src/prwlocktranslatereturncode.c | 47 ------- cpukit/posix/src/prwlocktryrdlock.c | 12 +- cpukit/posix/src/prwlocktrywrlock.c | 12 +- cpukit/posix/src/prwlockunlock.c | 5 +- cpukit/posix/src/prwlockwrlock.c | 15 +-- cpukit/posix/src/psignalunblockthread.c | 6 +- cpukit/posix/src/pspinlock.c | 7 +- cpukit/posix/src/pspinlocktranslatereturncode.c | 50 ------- cpukit/posix/src/pspintrylock.c | 7 +- cpukit/posix/src/pspinunlock.c | 7 +- cpukit/posix/src/pthreadjoin.c | 5 +- cpukit/posix/src/semaphoretranslatereturncode.c | 31 ----- cpukit/posix/src/semaphorewaitsupp.c | 20 +-- cpukit/posix/src/sempost.c | 12 +- cpukit/posix/src/sigtimedwait.c | 22 ++-- cpukit/rtems/Makefile.am | 3 - cpukit/rtems/include/rtems/rtems/barrierimpl.h | 14 -- cpukit/rtems/include/rtems/rtems/eventimpl.h | 2 +- cpukit/rtems/include/rtems/rtems/messageimpl.h | 14 -- cpukit/rtems/include/rtems/rtems/semimpl.h | 76 ----------- cpukit/rtems/include/rtems/rtems/statusimpl.h | 15 +++ cpukit/rtems/src/barriertranslatereturncode.c | 45 ------- cpukit/rtems/src/barrierwait.c | 12 +- cpukit/rtems/src/eventmp.c | 8 +- cpukit/rtems/src/eventreceive.c | 4 +- cpukit/rtems/src/eventseize.c | 20 +-- cpukit/rtems/src/msgmp.c | 16 +-- cpukit/rtems/src/msgqbroadcast.c | 9 +- cpukit/rtems/src/msgqreceive.c | 8 +- cpukit/rtems/src/msgqsend.c | 15 +-- cpukit/rtems/src/msgqtranslatereturncode.c | 65 --------- cpukit/rtems/src/msgqurgent.c | 15 +-- cpukit/rtems/src/partmp.c | 17 ++- cpukit/rtems/src/regiongetsegment.c | 6 +- cpukit/rtems/src/regionprocessqueue.c | 3 +- cpukit/rtems/src/semcreate.c | 25 ++-- cpukit/rtems/src/semdelete.c | 11 +- cpukit/rtems/src/semflush.c | 2 +- cpukit/rtems/src/semmp.c | 15 ++- cpukit/rtems/src/semobtain.c | 31 ++--- cpukit/rtems/src/semrelease.c | 23 ++-- cpukit/rtems/src/semtranslatereturncode.c | 41 ------ cpukit/rtems/src/signalmp.c | 8 +- cpukit/rtems/src/systemeventreceive.c | 4 +- cpukit/rtems/src/taskmp.c | 9 +- cpukit/score/Makefile.am | 1 + cpukit/score/include/rtems/score/corebarrierimpl.h | 42 +----- cpukit/score/include/rtems/score/coremsgimpl.h | 45 +------ cpukit/score/include/rtems/score/coremuteximpl.h | 146 +++++++-------------- cpukit/score/include/rtems/score/corerwlockimpl.h | 32 +---- cpukit/score/include/rtems/score/coresemimpl.h | 69 ++-------- .../score/include/rtems/score/corespinlockimpl.h | 36 +---- cpukit/score/include/rtems/score/mpciimpl.h | 11 +- cpukit/score/include/rtems/score/mrsp.h | 31 +---- cpukit/score/include/rtems/score/mrspimpl.h | 49 ++++--- cpukit/score/include/rtems/score/status.h | 129 ++++++++++++++++++ cpukit/score/include/rtems/score/thread.h | 5 - cpukit/score/include/rtems/score/threadimpl.h | 22 ++-- cpukit/score/include/rtems/score/threadqimpl.h | 40 +++++- cpukit/score/preinstall.am | 4 + cpukit/score/src/condition.c | 6 +- cpukit/score/src/corebarrier.c | 11 -- cpukit/score/src/corebarrierwait.c | 9 +- cpukit/score/src/coremsgbroadcast.c | 6 +- cpukit/score/src/coremsgclose.c | 2 +- cpukit/score/src/coremsgseize.c | 16 +-- cpukit/score/src/coremsgsubmit.c | 19 ++- cpukit/score/src/coremutex.c | 28 +--- cpukit/score/src/coremutexseize.c | 5 +- cpukit/score/src/coremutexsurrender.c | 14 +- cpukit/score/src/corerwlockobtainread.c | 17 +-- cpukit/score/src/corerwlockobtainwrite.c | 14 +- cpukit/score/src/corerwlockrelease.c | 8 +- cpukit/score/src/coresem.c | 22 ---- cpukit/score/src/corespinlockrelease.c | 6 +- cpukit/score/src/corespinlockwait.c | 10 +- cpukit/score/src/futex.c | 3 +- cpukit/score/src/mpci.c | 14 +- cpukit/score/src/mutex.c | 7 +- cpukit/score/src/semaphore.c | 3 +- cpukit/score/src/threadmp.c | 1 - cpukit/score/src/threadqenqueue.c | 4 +- cpukit/score/src/threadqflush.c | 27 ++++ cpukit/score/src/threadrestart.c | 10 +- cpukit/score/src/threadtimeout.c | 3 +- 107 files changed, 691 insertions(+), 1551 deletions(-) delete mode 100644 cpukit/posix/src/mqueuetranslatereturncode.c delete mode 100644 cpukit/posix/src/mutextranslatereturncode.c delete mode 100644 cpukit/posix/src/pbarriertranslatereturncode.c delete mode 100644 cpukit/posix/src/prwlocktranslatereturncode.c delete mode 100644 cpukit/posix/src/pspinlocktranslatereturncode.c delete mode 100644 cpukit/posix/src/semaphoretranslatereturncode.c delete mode 100644 cpukit/rtems/src/barriertranslatereturncode.c delete mode 100644 cpukit/rtems/src/msgqtranslatereturncode.c delete mode 100644 cpukit/rtems/src/semtranslatereturncode.c create mode 100644 cpukit/score/include/rtems/score/status.h (limited to 'cpukit') diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c index edf551e165..f517c22054 100644 --- a/cpukit/libnetworking/rtems/rtems_glue.c +++ b/cpukit/libnetworking/rtems/rtems_glue.c @@ -372,22 +372,20 @@ rtems_bsdnet_semaphore_obtain (void) { #ifdef RTEMS_FAST_MUTEX Thread_queue_Context queue_context; - Thread_Control *executing; + Status_Control status; if (!the_networkSemaphore) rtems_panic ("rtems-net: network sema obtain: network not initialised\n"); _Thread_queue_Context_initialize(&queue_context, NULL); _ISR_lock_ISR_disable(&queue_context.Lock_context); - executing = _Thread_Executing; - _CORE_mutex_Seize ( + status = _CORE_mutex_Seize ( &the_networkSemaphore->Core_control.mutex, - executing, + _Thread_Executing, 1, /* wait */ 0, /* forever */ &queue_context ); - if (executing->Wait.return_code) - rtems_panic ("rtems-net: can't obtain network sema: %d\n", - executing->Wait.return_code); + if (status != STATUS_SUCCESSFUL) + rtems_panic ("rtems-net: can't obtain network sema: %d\n", status); #else rtems_status_code sc; @@ -406,7 +404,7 @@ rtems_bsdnet_semaphore_release (void) { #ifdef RTEMS_FAST_MUTEX Thread_queue_Context queue_context; - CORE_mutex_Status status; + Status_Control status; if (!the_networkSemaphore) rtems_panic ("rtems-net: network sema obtain: network not initialised\n"); @@ -416,7 +414,7 @@ rtems_bsdnet_semaphore_release (void) &the_networkSemaphore->Core_control.mutex, &queue_context ); - if (status != CORE_MUTEX_STATUS_SUCCESSFUL) + if (status != STATUS_SUCCESSFUL) rtems_panic ("rtems-net: can't release network sema: %i\n"); #else rtems_status_code sc; diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am index a7632a04cc..9f73501cb0 100644 --- a/cpukit/posix/Makefile.am +++ b/cpukit/posix/Makefile.am @@ -74,7 +74,7 @@ libposix_a_SOURCES += src/pthreadatfork.c libposix_a_SOURCES += src/barrierattrdestroy.c src/barrierattrgetpshared.c \ src/barrierattrinit.c src/barrierattrsetpshared.c src/pbarrier.c \ src/pbarrierdestroy.c src/pbarrierinit.c \ - src/pbarriertranslatereturncode.c src/pbarrierwait.c + src/pbarrierwait.c ## CANCEL_C_FILES libposix_a_SOURCES += src/cancel.c \ @@ -99,7 +99,7 @@ libposix_a_SOURCES += src/mqueue.c src/mqueueclose.c \ src/mqueuenotify.c src/mqueueopen.c \ src/mqueuereceive.c src/mqueuerecvsupp.c src/mqueuesend.c \ src/mqueuesendsupp.c src/mqueuesetattr.c src/mqueuetimedreceive.c \ - src/mqueuetimedsend.c src/mqueuetranslatereturncode.c \ + src/mqueuetimedsend.c \ src/mqueueunlink.c ## MUTEX_C_FILES @@ -110,7 +110,7 @@ libposix_a_SOURCES += src/mutexattrdestroy.c src/mutexattrgetprioceiling.c \ src/mutexattrsettype.c src/mutex.c src/mutexdestroy.c src/mutexget.c \ src/mutexgetprioceiling.c src/mutexinit.c src/mutexlock.c \ src/mutexlocksupp.c src/mutexsetprioceiling.c src/mutextimedlock.c \ - src/mutextranslatereturncode.c src/mutextrylock.c src/mutexunlock.c + src/mutextrylock.c src/mutexunlock.c ## PTHREAD_C_FILES libposix_a_SOURCES += src/pthreadatfork.c src/pthreadattrdestroy.c \ @@ -175,20 +175,19 @@ libposix_a_SOURCES += src/prwlock.c src/prwlockdestroy.c src/prwlockinit.c \ src/prwlockrdlock.c src/prwlocktimedrdlock.c src/prwlocktimedwrlock.c \ src/prwlocktryrdlock.c src/prwlocktrywrlock.c src/prwlockunlock.c \ src/prwlockwrlock.c src/rwlockattrdestroy.c src/rwlockattrgetpshared.c \ - src/rwlockattrinit.c src/rwlockattrsetpshared.c \ - src/prwlocktranslatereturncode.c + src/rwlockattrinit.c src/rwlockattrsetpshared.c ## SEMAPHORE_C_FILES libposix_a_SOURCES += src/semaphore.c src/semaphorecreatesupp.c \ src/semaphoredeletesupp.c \ - src/semaphoretranslatereturncode.c src/semaphorewaitsupp.c \ + src/semaphorewaitsupp.c \ src/semclose.c src/semdestroy.c src/semgetvalue.c src/seminit.c \ src/semopen.c src/sempost.c src/semtimedwait.c src/semtrywait.c \ src/semunlink.c src/semwait.c ## SPINLOCK_C_FILES libposix_a_SOURCES += src/pspin.c src/pspindestroy.c src/pspininit.c \ - src/pspinlock.c src/pspinlocktranslatereturncode.c src/pspintrylock.c \ + src/pspinlock.c src/pspintrylock.c \ src/pspinunlock.c ## TIME_C_FILES diff --git a/cpukit/posix/include/rtems/posix/barrierimpl.h b/cpukit/posix/include/rtems/posix/barrierimpl.h index e04f1354ae..984868e7e1 100644 --- a/cpukit/posix/include/rtems/posix/barrierimpl.h +++ b/cpukit/posix/include/rtems/posix/barrierimpl.h @@ -37,20 +37,6 @@ extern "C" { extern Objects_Information _POSIX_Barrier_Information; -/** - * @brief POSIX translate barrier return code. - * - * This routine translates SuperCore Barrier status codes into the - * corresponding POSIX ones. - * - * @param[in] the_barrier_status is the SuperCore status. - * - * @return the corresponding POSIX status - */ -int _POSIX_Barrier_Translate_core_barrier_return_code( - CORE_barrier_Status the_barrier_status -); - /** * @brief Allocate a barrier control block. * diff --git a/cpukit/posix/include/rtems/posix/mqueueimpl.h b/cpukit/posix/include/rtems/posix/mqueueimpl.h index 2317358f64..480584b823 100644 --- a/cpukit/posix/include/rtems/posix/mqueueimpl.h +++ b/cpukit/posix/include/rtems/posix/mqueueimpl.h @@ -148,14 +148,6 @@ RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core( return (unsigned int) ((priority >= 0) ? priority : -priority); } -/** - * @brief POSIX Message Queue Translate Score Return Code - * - */ -int _POSIX_Message_queue_Translate_core_message_queue_return_code( - uint32_t the_message_queue_status -); - /** * @brief POSIX Message Queue Remove from Namespace */ diff --git a/cpukit/posix/include/rtems/posix/muteximpl.h b/cpukit/posix/include/rtems/posix/muteximpl.h index 4c7852b2c5..30cc19da7e 100644 --- a/cpukit/posix/include/rtems/posix/muteximpl.h +++ b/cpukit/posix/include/rtems/posix/muteximpl.h @@ -39,12 +39,6 @@ extern Objects_Information _POSIX_Mutex_Information; */ extern pthread_mutexattr_t _POSIX_Mutex_Default_attributes; -/** - * This array contains a mapping from Score Mutex return codes to - * POSIX return codes. - */ -extern const int _POSIX_Mutex_Return_codes[CORE_MUTEX_STATUS_LAST + 1]; - /** * @brief POSIX Mutex Allocate * @@ -82,42 +76,6 @@ int _POSIX_Mutex_Lock_support( Watchdog_Interval timeout ); -/** - * @brief Convert Score mutex status codes into POSIX status values - * - * A support routine which converts core mutex status codes into the - * appropriate POSIX status values. - * - * @param[in] the_mutex_status is the mutex status code to translate - * - * @retval 0 Mutex status code indicates the operation completed successfully. - * @retval EBUSY Mutex status code indicates that the operation unable to - * complete immediately because the resource was unavailable. - * @retval EDEADLK Mutex status code indicates that an attempt was made to - * relock a mutex for which nesting is not configured. - * @retval EPERM Mutex status code indicates that an attempt was made to - * release a mutex by a thread other than the thread which locked it. - * @retval EINVAL Mutex status code indicates that the thread was blocked - * waiting for an operation to complete and the mutex was deleted. - * @retval ETIMEDOUT Mutex status code indicates that the calling task was - * willing to block but the operation was unable to complete - * within the time allotted because the resource never became - * available. - */ -RTEMS_INLINE_ROUTINE int _POSIX_Mutex_Translate_core_mutex_return_code( - CORE_mutex_Status the_mutex_status -) -{ - /* - * Internal consistency check for bad status from SuperCore - */ - #if defined(RTEMS_DEBUG) - if ( the_mutex_status > CORE_MUTEX_STATUS_LAST ) - return EINVAL; - #endif - return _POSIX_Mutex_Return_codes[the_mutex_status]; -} - /** * @brief POSIX Mutex Get (Interrupt Disable) * diff --git a/cpukit/posix/include/rtems/posix/posixapi.h b/cpukit/posix/include/rtems/posix/posixapi.h index a5afe92872..fabde4d6f9 100644 --- a/cpukit/posix/include/rtems/posix/posixapi.h +++ b/cpukit/posix/include/rtems/posix/posixapi.h @@ -23,6 +23,8 @@ #include #include #include +#include +#include /** * @defgroup POSIXAPI RTEMS POSIX API @@ -60,6 +62,29 @@ RTEMS_INLINE_ROUTINE int _POSIX_Get_by_name_error( return _POSIX_Get_by_name_error_table[ error ]; } +RTEMS_INLINE_ROUTINE int _POSIX_Get_error( Status_Control status ) +{ + return STATUS_GET_POSIX( status ); +} + +RTEMS_INLINE_ROUTINE int _POSIX_Get_error_after_wait( + const Thread_Control *executing +) +{ + return _POSIX_Get_error( _Thread_Wait_get_status( executing ) ); +} + +RTEMS_INLINE_ROUTINE int _POSIX_Zero_or_minus_one_plus_errno( + Status_Control status +) +{ + if ( status == STATUS_SUCCESSFUL ) { + return 0; + } + + rtems_set_errno_and_return_minus_one( _POSIX_Get_error( status ) ); +} + /** * @brief Macro to generate a function body to get a POSIX object by * identifier. diff --git a/cpukit/posix/include/rtems/posix/rwlockimpl.h b/cpukit/posix/include/rtems/posix/rwlockimpl.h index 4ab9395489..c355f7dc19 100644 --- a/cpukit/posix/include/rtems/posix/rwlockimpl.h +++ b/cpukit/posix/include/rtems/posix/rwlockimpl.h @@ -37,29 +37,6 @@ extern "C" { extern Objects_Information _POSIX_RWLock_Information; -/** - * @brief POSIX translate core RWLock return code. - * - * This routine translates SuperCore RWLock status codes into the - * corresponding POSIX ones. - * - * - * @param[in] the_RWLock_status is the SuperCore status. - * - * @return the corresponding POSIX status - * @retval 0 The status indicates that the operation completed successfully. - * @retval EINVAL The status indicates that the thread was blocked waiting for - * an operation to complete and the RWLock was deleted. - * @retval EBUSY This status indicates that the RWLock was not - * immediately available. - * @retval ETIMEDOUT This status indicates that the calling task was - * willing to block but the operation was unable to complete within - * the time allotted because the resource never became available. - */ -int _POSIX_RWLock_Translate_core_RWLock_return_code( - CORE_RWLock_Status the_RWLock_status -); - /** * @brief Allocate a RWLock control block. * diff --git a/cpukit/posix/include/rtems/posix/semaphoreimpl.h b/cpukit/posix/include/rtems/posix/semaphoreimpl.h index 10d7cee28b..90019d7ed0 100644 --- a/cpukit/posix/include/rtems/posix/semaphoreimpl.h +++ b/cpukit/posix/include/rtems/posix/semaphoreimpl.h @@ -34,12 +34,6 @@ extern "C" { */ extern Objects_Information _POSIX_Semaphore_Information; -/** - * This defines the mapping from Score status codes to POSIX return codes. - */ -extern const int - _POSIX_Semaphore_Return_codes[CORE_SEMAPHORE_STATUS_LAST + 1]; - RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control * _POSIX_Semaphore_Allocate_unprotected( void ) { @@ -108,27 +102,6 @@ int _POSIX_Semaphore_Wait_support( bool blocking, Watchdog_Interval timeout ); - -/** - * @brief POSIX Semaphore Translate Score to POSIX Return Codes - * - * A support routine which converts core semaphore status codes into the - * appropriate POSIX status values. - */ -RTEMS_INLINE_ROUTINE int -_POSIX_Semaphore_Translate_core_semaphore_return_code( - CORE_semaphore_Status the_semaphore_status -) -{ - /* - * Internal consistency check for bad status from SuperCore - */ - #if defined(RTEMS_DEBUG) - if ( the_semaphore_status > CORE_SEMAPHORE_STATUS_LAST ) - return EINVAL; - #endif - return _POSIX_Semaphore_Return_codes[the_semaphore_status]; -} /** * @brief POSIX Semaphore Namespace Remove diff --git a/cpukit/posix/include/rtems/posix/spinlockimpl.h b/cpukit/posix/include/rtems/posix/spinlockimpl.h index e0217a0889..f1b5639bd1 100644 --- a/cpukit/posix/include/rtems/posix/spinlockimpl.h +++ b/cpukit/posix/include/rtems/posix/spinlockimpl.h @@ -36,20 +36,6 @@ extern "C" { extern Objects_Information _POSIX_Spinlock_Information; -/** - * @brief Translate core spinlock status code. - * - * This routine translates SuperCore Spinlock status codes into the - * corresponding POSIX ones. - * - * @param[in] the_spinlock_status is the SuperCore status. - * - * @return the corresponding POSIX status - */ -int _POSIX_Spinlock_Translate_core_spinlock_return_code( - CORE_spinlock_Status the_spinlock_status -); - /** * @brief Allocate a spinlock control block. * 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 #include +#include #include #include +#include #include 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; } diff --git a/cpukit/posix/src/mqueuerecvsupp.c b/cpukit/posix/src/mqueuerecvsupp.c index 541786a850..cbb0dc08b8 100644 --- a/cpukit/posix/src/mqueuerecvsupp.c +++ b/cpukit/posix/src/mqueuerecvsupp.c @@ -19,6 +19,7 @@ #endif #include +#include #include @@ -48,6 +49,7 @@ ssize_t _POSIX_Message_queue_Receive_support( size_t length_out; bool do_wait; Thread_Control *executing; + Status_Control status; the_mq = _POSIX_Message_queue_Get( mqdes, &queue_context ); @@ -95,7 +97,7 @@ ssize_t _POSIX_Message_queue_Receive_support( * Now perform the actual message receive */ executing = _Thread_Executing; - _CORE_message_queue_Seize( + status = _CORE_message_queue_Seize( &the_mq->Message_queue, executing, msg_ptr, @@ -111,12 +113,8 @@ ssize_t _POSIX_Message_queue_Receive_support( ); } - if ( executing->Wait.return_code != CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL ) { - rtems_set_errno_and_return_minus_one( - _POSIX_Message_queue_Translate_core_message_queue_return_code( - executing->Wait.return_code - ) - ); + if ( status != STATUS_SUCCESSFUL ) { + rtems_set_errno_and_return_minus_one( _POSIX_Get_error( status ) ); } return length_out; diff --git a/cpukit/posix/src/mqueuesendsupp.c b/cpukit/posix/src/mqueuesendsupp.c index 2d88eec7a8..9785fb2086 100644 --- a/cpukit/posix/src/mqueuesendsupp.c +++ b/cpukit/posix/src/mqueuesendsupp.c @@ -45,7 +45,7 @@ int _POSIX_Message_queue_Send_support( { POSIX_Message_queue_Control *the_mq; Thread_queue_Context queue_context; - CORE_message_queue_Status msg_status; + Status_Control status; bool do_wait; Thread_Control *executing; @@ -92,7 +92,7 @@ int _POSIX_Message_queue_Send_support( * Now perform the actual message receive */ executing = _Thread_Executing; - msg_status = _CORE_message_queue_Submit( + status = _CORE_message_queue_Submit( &the_mq->Message_queue, executing, msg_ptr, @@ -102,14 +102,5 @@ int _POSIX_Message_queue_Send_support( timeout, &queue_context ); - - if ( msg_status != CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL ) { - rtems_set_errno_and_return_minus_one( - _POSIX_Message_queue_Translate_core_message_queue_return_code( - msg_status - ) - ); - } - - return 0; + return _POSIX_Zero_or_minus_one_plus_errno( status ); } diff --git a/cpukit/posix/src/mqueuetranslatereturncode.c b/cpukit/posix/src/mqueuetranslatereturncode.c deleted file mode 100644 index 901d5aaa3a..0000000000 --- a/cpukit/posix/src/mqueuetranslatereturncode.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file - * - * @brief POSIX Error Translation in Message Queue - * @ingroup POSIXAPI - */ - -/* - * POSIX Message Queue Error Translation - * - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include -#include -#include - -/* - * _POSIX_Message_queue_Translate_core_message_queue_return_code - * - * Input parameters: - * the_message_queue_status - message_queue status code to translate - * - * Output parameters: - * status code - translated POSIX status code - * - */ - -static - int _POSIX_Message_queue_Return_codes[CORE_MESSAGE_QUEUE_STATUS_LAST + 1] = { - 0, /* CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL */ - EMSGSIZE, /* CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE */ - EAGAIN, /* CORE_MESSAGE_QUEUE_STATUS_TOO_MANY */ - ENOMEM, /* CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED */ - EAGAIN, /* CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT */ - EBADF, /* CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED */ - ETIMEDOUT /* CORE_MESSAGE_QUEUE_STATUS_TIMEOUT */ -}; - - -int _POSIX_Message_queue_Translate_core_message_queue_return_code( - uint32_t the_message_queue_status -) -{ - /* - * Internal consistency check for bad status from SuperCore - */ - #if defined(RTEMS_DEBUG) - if ( the_message_queue_status > CORE_MESSAGE_QUEUE_STATUS_LAST ) - return EINVAL; - #endif - return _POSIX_Message_queue_Return_codes[the_message_queue_status]; -} diff --git a/cpukit/posix/src/mutexlocksupp.c b/cpukit/posix/src/mutexlocksupp.c index f17269bf21..6ecf87cb46 100644 --- a/cpukit/posix/src/mutexlocksupp.c +++ b/cpukit/posix/src/mutexlocksupp.c @@ -19,6 +19,7 @@ #endif #include +#include THREAD_QUEUE_OBJECT_ASSERT( POSIX_Mutex_Control, Mutex.Wait_queue ); @@ -30,7 +31,7 @@ int _POSIX_Mutex_Lock_support( { POSIX_Mutex_Control *the_mutex; Thread_queue_Context queue_context; - Thread_Control *executing; + Status_Control status; the_mutex = _POSIX_Mutex_Get( mutex, &queue_context ); @@ -38,15 +39,12 @@ int _POSIX_Mutex_Lock_support( return EINVAL; } - executing = _Thread_Executing; - _CORE_mutex_Seize( + status = _CORE_mutex_Seize( &the_mutex->Mutex, - executing, + _Thread_Executing, blocking, timeout, &queue_context ); - return _POSIX_Mutex_Translate_core_mutex_return_code( - (CORE_mutex_Status) executing->Wait.return_code - ); + return _POSIX_Get_error( status ); } diff --git a/cpukit/posix/src/mutextranslatereturncode.c b/cpukit/posix/src/mutextranslatereturncode.c deleted file mode 100644 index 1cc0b5c98c..0000000000 --- a/cpukit/posix/src/mutextranslatereturncode.c +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @file - * - * @brief POSIX Mutex Translate Core Mutex Return Code - * @ingroup POSIX_MUTEX - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -const int _POSIX_Mutex_Return_codes[CORE_MUTEX_STATUS_LAST + 1] = { - 0, /* CORE_MUTEX_STATUS_SUCCESSFUL */ - EBUSY, /* CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT */ - EDEADLK, /* CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED */ - EPERM, /* CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE */ - EINVAL, /* CORE_MUTEX_WAS_DELETED */ - ETIMEDOUT, /* CORE_MUTEX_TIMEOUT */ - EINVAL /* CORE_MUTEX_STATUS_CEILING_VIOLATED */ -}; diff --git a/cpukit/posix/src/mutexunlock.c b/cpukit/posix/src/mutexunlock.c index ff7fc1c789..1c3f2d83f4 100644 --- a/cpukit/posix/src/mutexunlock.c +++ b/cpukit/posix/src/mutexunlock.c @@ -19,6 +19,7 @@ #endif #include +#include /* * 11.3.3 Locking and Unlocking a Mutex, P1003.1c/Draft 10, p. 93 @@ -31,8 +32,8 @@ int pthread_mutex_unlock( ) { POSIX_Mutex_Control *the_mutex; - CORE_mutex_Status status; Thread_queue_Context queue_context; + Status_Control status; the_mutex = _POSIX_Mutex_Get( mutex, &queue_context ); @@ -41,5 +42,5 @@ int pthread_mutex_unlock( } status = _CORE_mutex_Surrender( &the_mutex->Mutex, &queue_context ); - return _POSIX_Mutex_Translate_core_mutex_return_code( status ); + return _POSIX_Get_error( status ); } diff --git a/cpukit/posix/src/nanosleep.c b/cpukit/posix/src/nanosleep.c index b24b74d00b..21b0d15a2a 100644 --- a/cpukit/posix/src/nanosleep.c +++ b/cpukit/posix/src/nanosleep.c @@ -92,8 +92,7 @@ int nanosleep( &_Thread_queue_Operations_FIFO, executing, STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL, - ticks, - 0 + ticks ); /* diff --git a/cpukit/posix/src/pbarriertranslatereturncode.c b/cpukit/posix/src/pbarriertranslatereturncode.c deleted file mode 100644 index e3dd7bf06d..0000000000 --- a/cpukit/posix/src/pbarriertranslatereturncode.c +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @file - * - * @brief Function Translates POSIX Barrier Status Code - * @ingroup POSIXAPI - */ - -/* - * Barrier Manager -- Translate SuperCore Status - * - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include -#include - -/* - * _POSIX_Barrier_Translate_core_barrier_return_code - * - * Input parameters: - * the_barrier_status - barrier status code to translate - * - * Output parameters: - * status code - translated POSIX status code - * - */ - -static int _POSIX_Barrier_Return_codes[CORE_BARRIER_STATUS_LAST + 1] = { - 0, /* CORE_BARRIER_STATUS_SUCCESSFUL */ - PTHREAD_BARRIER_SERIAL_THREAD, - /* CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED */ - -1, /* CORE_BARRIER_WAS_DELETED */ - 0 /* CORE_BARRIER_TIMEOUT */ -}; - - -int _POSIX_Barrier_Translate_core_barrier_return_code( - CORE_barrier_Status the_barrier_status -) -{ - /* - * Internal consistency check for bad status from SuperCore - */ - #if defined(RTEMS_DEBUG) - if ( the_barrier_status > CORE_BARRIER_STATUS_LAST ) - return EINVAL; - #endif - return _POSIX_Barrier_Return_codes[the_barrier_status]; -} diff --git a/cpukit/posix/src/pbarrierwait.c b/cpukit/posix/src/pbarrierwait.c index 522c18ec84..0197e46702 100644 --- a/cpukit/posix/src/pbarrierwait.c +++ b/cpukit/posix/src/pbarrierwait.c @@ -19,26 +19,17 @@ #endif #include +#include THREAD_QUEUE_OBJECT_ASSERT( POSIX_Barrier_Control, Barrier.Wait_queue ); -/** - * This directive allows a thread to wait at a barrier. - * - * @param[in] barrier is the barrier id - * - * @retval 0 if successful - * @retval PTHREAD_BARRIER_SERIAL_THREAD if successful - * @retval error_code if unsuccessful - */ - int pthread_barrier_wait( pthread_barrier_t *barrier ) { POSIX_Barrier_Control *the_barrier; Thread_queue_Context queue_context; - Thread_Control *executing; + Status_Control status; if ( barrier == NULL ) { return EINVAL; @@ -50,15 +41,12 @@ int pthread_barrier_wait( return EINVAL; } - executing = _Thread_Executing; - _CORE_barrier_Seize( + status = _CORE_barrier_Seize( &the_barrier->Barrier, - executing, + _Thread_Executing, true, - 0, + WATCHDOG_NO_TIMEOUT, &queue_context ); - return _POSIX_Barrier_Translate_core_barrier_return_code( - executing->Wait.return_code - ); + return _POSIX_Get_error( status ); } diff --git a/cpukit/posix/src/prwlockrdlock.c b/cpukit/posix/src/prwlockrdlock.c index e59aaf9adb..295148e4bf 100644 --- a/cpukit/posix/src/prwlockrdlock.c +++ b/cpukit/posix/src/prwlockrdlock.c @@ -19,6 +19,7 @@ #endif #include +#include int pthread_rwlock_rdlock( pthread_rwlock_t *rwlock @@ -26,7 +27,7 @@ int pthread_rwlock_rdlock( { POSIX_RWLock_Control *the_rwlock; Thread_queue_Context queue_context; - Thread_Control *executing; + Status_Control status; the_rwlock = _POSIX_RWLock_Get( rwlock, &queue_context ); @@ -34,15 +35,12 @@ int pthread_rwlock_rdlock( return EINVAL; } - executing = _Thread_Executing; - _CORE_RWLock_Seize_for_reading( + status = _CORE_RWLock_Seize_for_reading( &the_rwlock->RWLock, - executing, + _Thread_Executing, true, /* we are willing to wait forever */ 0, &queue_context ); - return _POSIX_RWLock_Translate_core_RWLock_return_code( - (CORE_RWLock_Status) executing->Wait.return_code - ); + return _POSIX_Get_error( status ); } 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 +#include #include 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 ); } 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 +#include #include 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 ); } diff --git a/cpukit/posix/src/prwlocktranslatereturncode.c b/cpukit/posix/src/prwlocktranslatereturncode.c deleted file mode 100644 index dceb5f7ee4..0000000000 --- a/cpukit/posix/src/prwlocktranslatereturncode.c +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @file - * - * @brief POSIX RWLock Translate Core RWLock Return Code - * @ingroup POSIX_RWLOCK - */ - -/* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include -#include - -static int _POSIX_RWLock_Return_codes[CORE_RWLOCK_STATUS_LAST + 1] = { - 0, /* CORE_RWLOCK_SUCCESSFUL */ - EINVAL, /* CORE_RWLOCK_DELETED */ - EBUSY, /* CORE_RWLOCK_UNAVAILABLE */ - ETIMEDOUT, /* CORE_RWLOCK_TIMEOUT */ -}; - - -int _POSIX_RWLock_Translate_core_RWLock_return_code( - CORE_RWLock_Status the_rwlock_status -) -{ - /* - * Internal consistency check for bad status from SuperCore - */ - #if defined(RTEMS_DEBUG) - if ( the_rwlock_status > CORE_RWLOCK_STATUS_LAST ) - return EINVAL; - #endif - return _POSIX_RWLock_Return_codes[the_rwlock_status]; -} diff --git a/cpukit/posix/src/prwlocktryrdlock.c b/cpukit/posix/src/prwlocktryrdlock.c index 1a7cf9efe1..5c6931ec0d 100644 --- a/cpukit/posix/src/prwlocktryrdlock.c +++ b/cpukit/posix/src/prwlocktryrdlock.c @@ -19,6 +19,7 @@ #endif #include +#include int pthread_rwlock_tryrdlock( pthread_rwlock_t *rwlock @@ -26,7 +27,7 @@ int pthread_rwlock_tryrdlock( { POSIX_RWLock_Control *the_rwlock; Thread_queue_Context queue_context; - Thread_Control *executing; + Status_Control status; the_rwlock = _POSIX_RWLock_Get( rwlock, &queue_context ); @@ -34,15 +35,12 @@ int pthread_rwlock_tryrdlock( return EINVAL; } - executing = _Thread_Executing; - _CORE_RWLock_Seize_for_reading( + status = _CORE_RWLock_Seize_for_reading( &the_rwlock->RWLock, - executing, + _Thread_Executing, false, /* do not wait for the rwlock */ 0, &queue_context ); - return _POSIX_RWLock_Translate_core_RWLock_return_code( - (CORE_RWLock_Status) executing->Wait.return_code - ); + return _POSIX_Get_error( status ); } diff --git a/cpukit/posix/src/prwlocktrywrlock.c b/cpukit/posix/src/prwlocktrywrlock.c index b6031f9b42..1181382fca 100644 --- a/cpukit/posix/src/prwlocktrywrlock.c +++ b/cpukit/posix/src/prwlocktrywrlock.c @@ -19,6 +19,7 @@ #endif #include +#include int pthread_rwlock_trywrlock( pthread_rwlock_t *rwlock @@ -26,7 +27,7 @@ int pthread_rwlock_trywrlock( { POSIX_RWLock_Control *the_rwlock; Thread_queue_Context queue_context; - Thread_Control *executing; + Status_Control status; the_rwlock = _POSIX_RWLock_Get( rwlock, &queue_context ); @@ -34,15 +35,12 @@ int pthread_rwlock_trywrlock( return EINVAL; } - executing = _Thread_Executing; - _CORE_RWLock_Seize_for_writing( + status = _CORE_RWLock_Seize_for_writing( &the_rwlock->RWLock, - executing, + _Thread_Executing, false, /* we are not willing to wait */ 0, &queue_context ); - return _POSIX_RWLock_Translate_core_RWLock_return_code( - (CORE_RWLock_Status) executing->Wait.return_code - ); + return _POSIX_Get_error( status ); } diff --git a/cpukit/posix/src/prwlockunlock.c b/cpukit/posix/src/prwlockunlock.c index dd4337d7d0..05be366c23 100644 --- a/cpukit/posix/src/prwlockunlock.c +++ b/cpukit/posix/src/prwlockunlock.c @@ -21,6 +21,7 @@ #endif #include +#include int pthread_rwlock_unlock( pthread_rwlock_t *rwlock @@ -28,7 +29,7 @@ int pthread_rwlock_unlock( { POSIX_RWLock_Control *the_rwlock; Thread_queue_Context queue_context; - CORE_RWLock_Status status; + Status_Control status; the_rwlock = _POSIX_RWLock_Get( rwlock, &queue_context ); @@ -37,5 +38,5 @@ int pthread_rwlock_unlock( } status = _CORE_RWLock_Surrender( &the_rwlock->RWLock, &queue_context ); - return _POSIX_RWLock_Translate_core_RWLock_return_code( status ); + return _POSIX_Get_error( status ); } diff --git a/cpukit/posix/src/prwlockwrlock.c b/cpukit/posix/src/prwlockwrlock.c index 84a4e0f04b..4592aaa04e 100644 --- a/cpukit/posix/src/prwlockwrlock.c +++ b/cpukit/posix/src/prwlockwrlock.c @@ -20,10 +20,8 @@ #include "config.h" #endif -#include -#include - #include +#include THREAD_QUEUE_OBJECT_ASSERT( POSIX_RWLock_Control, RWLock.Wait_queue ); @@ -33,7 +31,7 @@ int pthread_rwlock_wrlock( { POSIX_RWLock_Control *the_rwlock; Thread_queue_Context queue_context; - Thread_Control *executing; + Status_Control status; the_rwlock = _POSIX_RWLock_Get( rwlock, &queue_context ); @@ -41,15 +39,12 @@ int pthread_rwlock_wrlock( return EINVAL; } - executing = _Thread_Executing; - _CORE_RWLock_Seize_for_writing( + status = _CORE_RWLock_Seize_for_writing( &the_rwlock->RWLock, - executing, + _Thread_Executing, true, /* do not timeout -- wait forever */ 0, &queue_context ); - return _POSIX_RWLock_Translate_core_RWLock_return_code( - (CORE_RWLock_Status) executing->Wait.return_code - ); + return _POSIX_Get_error( status ); } diff --git a/cpukit/posix/src/psignalunblockthread.c b/cpukit/posix/src/psignalunblockthread.c index 5635afaa4e..b4475b268d 100644 --- a/cpukit/posix/src/psignalunblockthread.c +++ b/cpukit/posix/src/psignalunblockthread.c @@ -98,7 +98,7 @@ static void _POSIX_signals_Action_handler( { POSIX_API_Control *api; int signo; - int hold_errno; + uint32_t hold_errno; (void) action; _Thread_State_release( executing, lock_context ); @@ -198,7 +198,7 @@ bool _POSIX_signals_Unblock_thread( if ( _States_Is_interruptible_signal( the_thread->current_state ) ) { if ( (the_thread->Wait.option & mask) || (api->signals_unblocked & mask) ) { - the_thread->Wait.return_code = EINTR; + the_thread->Wait.return_code = STATUS_INTERRUPTED; the_info = (siginfo_t *) the_thread->Wait.return_argument; @@ -240,7 +240,7 @@ bool _POSIX_signals_Unblock_thread( */ if ( _States_Is_interruptible_by_signal( the_thread->current_state ) ) { - the_thread->Wait.return_code = EINTR; + the_thread->Wait.return_code = STATUS_INTERRUPTED; _Thread_queue_Extract_with_proxy( the_thread ); } } diff --git a/cpukit/posix/src/pspinlock.c b/cpukit/posix/src/pspinlock.c index 502177c50e..a2db911698 100644 --- a/cpukit/posix/src/pspinlock.c +++ b/cpukit/posix/src/pspinlock.c @@ -19,14 +19,13 @@ #endif #include - -#include +#include int pthread_spin_lock( pthread_spinlock_t *spinlock ) { POSIX_Spinlock_Control *the_spinlock; ISR_lock_Context lock_context; - CORE_spinlock_Status status; + Status_Control status; the_spinlock = _POSIX_Spinlock_Get( spinlock, &lock_context ); if ( the_spinlock == NULL ) { @@ -39,5 +38,5 @@ int pthread_spin_lock( pthread_spinlock_t *spinlock ) 0, &lock_context ); - return _POSIX_Spinlock_Translate_core_spinlock_return_code( status ); + return _POSIX_Get_error( status ); } diff --git a/cpukit/posix/src/pspinlocktranslatereturncode.c b/cpukit/posix/src/pspinlocktranslatereturncode.c deleted file mode 100644 index 6d3e9b05d8..0000000000 --- a/cpukit/posix/src/pspinlocktranslatereturncode.c +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file - * - * @brief POSIX Spinlock Translate Core Spinlock Return Code - * @ingroup POSIX_SPINLOCK - */ - -/* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include -#include -#include - -static int _POSIX_Spinlock_Return_codes[CORE_SPINLOCK_STATUS_LAST + 1] = { - 0, /* CORE_SPINLOCK_SUCCESSFUL */ - EDEADLK, /* CORE_SPINLOCK_HOLDER_RELOCKING */ - EPERM, /* CORE_SPINLOCK_NOT_HOLDER */ - -1, /* CORE_SPINLOCK_TIMEOUT */ - EBUSY, /* CORE_SPINLOCK_IS_BUSY */ - EBUSY /* CORE_SPINLOCK_UNAVAILABLE */ -}; - - -int _POSIX_Spinlock_Translate_core_spinlock_return_code( - CORE_spinlock_Status the_spinlock_status -) -{ - /* - * Internal consistency check for bad status from SuperCore - */ - #if defined(RTEMS_DEBUG) - if ( the_spinlock_status > CORE_SPINLOCK_STATUS_LAST ) - return EINVAL; - #endif - return _POSIX_Spinlock_Return_codes[the_spinlock_status]; -} diff --git a/cpukit/posix/src/pspintrylock.c b/cpukit/posix/src/pspintrylock.c index 5f132a3193..a8264aba97 100644 --- a/cpukit/posix/src/pspintrylock.c +++ b/cpukit/posix/src/pspintrylock.c @@ -19,14 +19,13 @@ #endif #include - -#include +#include int pthread_spin_trylock( pthread_spinlock_t *spinlock ) { POSIX_Spinlock_Control *the_spinlock; ISR_lock_Context lock_context; - CORE_spinlock_Status status; + Status_Control status; the_spinlock = _POSIX_Spinlock_Get( spinlock, &lock_context ); if ( the_spinlock == NULL ) { @@ -39,5 +38,5 @@ int pthread_spin_trylock( pthread_spinlock_t *spinlock ) 0, &lock_context ); - return _POSIX_Spinlock_Translate_core_spinlock_return_code( status ); + return _POSIX_Get_error( status ); } diff --git a/cpukit/posix/src/pspinunlock.c b/cpukit/posix/src/pspinunlock.c index 35dbcb977f..b92473d7c1 100644 --- a/cpukit/posix/src/pspinunlock.c +++ b/cpukit/posix/src/pspinunlock.c @@ -21,14 +21,13 @@ #endif #include - -#include +#include int pthread_spin_unlock( pthread_spinlock_t *spinlock ) { POSIX_Spinlock_Control *the_spinlock; ISR_lock_Context lock_context; - CORE_spinlock_Status status; + Status_Control status; the_spinlock = _POSIX_Spinlock_Get( spinlock, &lock_context ); if ( the_spinlock == NULL ) { @@ -36,5 +35,5 @@ int pthread_spin_unlock( pthread_spinlock_t *spinlock ) } status = _CORE_spinlock_Surrender( &the_spinlock->Spinlock, &lock_context ); - return _POSIX_Spinlock_Translate_core_spinlock_return_code( status ); + return _POSIX_Get_error( status ); } diff --git a/cpukit/posix/src/pthreadjoin.c b/cpukit/posix/src/pthreadjoin.c index db83a1f3bf..f4a0676d6b 100644 --- a/cpukit/posix/src/pthreadjoin.c +++ b/cpukit/posix/src/pthreadjoin.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -72,8 +73,8 @@ static int _POSIX_Threads_Join( pthread_t thread, void **value_ptr ) &lock_context ); - if ( executing->Wait.return_code != 0 ) { - _Assert( executing->Wait.return_code == EINTR ); + if ( _POSIX_Get_error_after_wait( executing ) != 0 ) { + _Assert( _POSIX_Get_error_after_wait( executing ) == EINTR ); return EINTR; } diff --git a/cpukit/posix/src/semaphoretranslatereturncode.c b/cpukit/posix/src/semaphoretranslatereturncode.c deleted file mode 100644 index 04b293d349..0000000000 --- a/cpukit/posix/src/semaphoretranslatereturncode.c +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @file - * - * @brief POSIX Semaphore Code Translation Error - * @ingroup POSIXAPI - */ - -/* - * POSIX Semaphore Error Translation - * - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -const int _POSIX_Semaphore_Return_codes[CORE_SEMAPHORE_STATUS_LAST + 1] = { - 0, /* CORE_SEMAPHORE_STATUS_SUCCESSFUL */ - EAGAIN, /* CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT */ - EINVAL, /* CORE_SEMAPHORE_WAS_DELETED */ - ETIMEDOUT, /* CORE_SEMAPHORE_TIMEOUT */ - EOVERFLOW /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */ -}; diff --git a/cpukit/posix/src/semaphorewaitsupp.c b/cpukit/posix/src/semaphorewaitsupp.c index 9382107d90..d8e0d69654 100644 --- a/cpukit/posix/src/semaphorewaitsupp.c +++ b/cpukit/posix/src/semaphorewaitsupp.c @@ -21,6 +21,7 @@ #include #include +#include THREAD_QUEUE_OBJECT_ASSERT( POSIX_Semaphore_Control, Semaphore.Wait_queue ); @@ -31,8 +32,8 @@ int _POSIX_Semaphore_Wait_support( ) { POSIX_Semaphore_Control *the_semaphore; - Thread_Control *executing; Thread_queue_Context queue_context; + Status_Control status; the_semaphore = _POSIX_Semaphore_Get( sem, &queue_context ); @@ -40,23 +41,12 @@ int _POSIX_Semaphore_Wait_support( rtems_set_errno_and_return_minus_one( EINVAL ); } - executing = _Thread_Executing; - - _CORE_semaphore_Seize( + status = _CORE_semaphore_Seize( &the_semaphore->Semaphore, - executing, + _Thread_Executing, blocking, timeout, &queue_context ); - - if ( executing->Wait.return_code == CORE_SEMAPHORE_STATUS_SUCCESSFUL ) { - return 0; - } - - rtems_set_errno_and_return_minus_one( - _POSIX_Semaphore_Translate_core_semaphore_return_code( - executing->Wait.return_code - ) - ); + return _POSIX_Zero_or_minus_one_plus_errno( status ); } diff --git a/cpukit/posix/src/sempost.c b/cpukit/posix/src/sempost.c index f4633dcf70..322663b5ad 100644 --- a/cpukit/posix/src/sempost.c +++ b/cpukit/posix/src/sempost.c @@ -22,6 +22,7 @@ #include #include +#include int sem_post( sem_t *sem @@ -29,7 +30,7 @@ int sem_post( { POSIX_Semaphore_Control *the_semaphore; Thread_queue_Context queue_context; - CORE_semaphore_Status status; + Status_Control status; the_semaphore = _POSIX_Semaphore_Get( sem, &queue_context ); @@ -42,12 +43,5 @@ int sem_post( SEM_VALUE_MAX, &queue_context ); - - if ( status == CORE_SEMAPHORE_STATUS_SUCCESSFUL ) { - return 0; - } - - rtems_set_errno_and_return_minus_one( - _POSIX_Semaphore_Translate_core_semaphore_return_code( status ) - ); + return _POSIX_Zero_or_minus_one_plus_errno( status ); } diff --git a/cpukit/posix/src/sigtimedwait.c b/cpukit/posix/src/sigtimedwait.c index 77dbe533ca..ddc2884d68 100644 --- a/cpukit/posix/src/sigtimedwait.c +++ b/cpukit/posix/src/sigtimedwait.c @@ -18,14 +18,12 @@ #include "config.h" #endif -#include #include -#include #include #include +#include #include -#include #include static int _POSIX_signals_Get_lowest( @@ -78,6 +76,7 @@ int sigtimedwait( siginfo_t *the_info; int signo; ISR_lock_Context lock_context; + int error; /* * Error check parameters before disabling interrupts. @@ -150,7 +149,6 @@ int sigtimedwait( the_info->si_signo = -1; - executing->Wait.return_code = EINTR; executing->Wait.option = *set; executing->Wait.return_argument = the_info; _Thread_queue_Enqueue_critical( @@ -159,7 +157,6 @@ int sigtimedwait( executing, STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL, interval, - EAGAIN, &lock_context ); @@ -182,10 +179,17 @@ int sigtimedwait( * was not in our set. */ - if ( (executing->Wait.return_code != EINTR) - || !(*set & signo_to_mask( the_info->si_signo )) ) { - errno = executing->Wait.return_code; - return -1; + error = _POSIX_Get_error_after_wait( executing ); + + if ( + error != EINTR + || ( *set & signo_to_mask( the_info->si_signo ) ) == 0 + ) { + if ( error == ETIMEDOUT ) { + error = EAGAIN; + } + + rtems_set_errno_and_return_minus_one( error ); } return the_info->si_signo; diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am index 368dcdce12..0a452c8121 100644 --- a/cpukit/rtems/Makefile.am +++ b/cpukit/rtems/Makefile.am @@ -129,7 +129,6 @@ librtems_a_SOURCES += src/barrier.c librtems_a_SOURCES += src/barriercreate.c librtems_a_SOURCES += src/barrierdelete.c librtems_a_SOURCES += src/barrierident.c -librtems_a_SOURCES += src/barriertranslatereturncode.c librtems_a_SOURCES += src/barrierrelease.c librtems_a_SOURCES += src/barrierwait.c @@ -170,7 +169,6 @@ librtems_a_SOURCES += src/msgqgetnumberpending.c librtems_a_SOURCES += src/msgqident.c librtems_a_SOURCES += src/msgqreceive.c librtems_a_SOURCES += src/msgqsend.c -librtems_a_SOURCES += src/msgqtranslatereturncode.c librtems_a_SOURCES += src/msgqurgent.c ## SEMAPHORE_C_FILES @@ -181,7 +179,6 @@ librtems_a_SOURCES += src/semident.c librtems_a_SOURCES += src/semobtain.c librtems_a_SOURCES += src/semrelease.c librtems_a_SOURCES += src/semflush.c -librtems_a_SOURCES += src/semtranslatereturncode.c librtems_a_SOURCES += src/semsetpriority.c ## EVENT_C_FILES diff --git a/cpukit/rtems/include/rtems/rtems/barrierimpl.h b/cpukit/rtems/include/rtems/rtems/barrierimpl.h index 0eaadfc046..6a98917012 100644 --- a/cpukit/rtems/include/rtems/rtems/barrierimpl.h +++ b/cpukit/rtems/include/rtems/rtems/barrierimpl.h @@ -79,20 +79,6 @@ RTEMS_INLINE_ROUTINE Barrier_Control *_Barrier_Get( _Objects_Get( id, &queue_context->Lock_context, &_Barrier_Information ); } -/** - * @brief Translate SuperCore Barrier Status Code to RTEMS Status Code - * - * This function returns a RTEMS status code based on the barrier - * status code specified. - * - * @param[in] the_status is the SuperCore Barrier status to translate. - * - * @retval a status code indicating success or the reason for failure. - */ -rtems_status_code _Barrier_Translate_core_barrier_return_code ( - CORE_barrier_Status the_status -); - /**@}*/ #ifdef __cplusplus diff --git a/cpukit/rtems/include/rtems/rtems/eventimpl.h b/cpukit/rtems/include/rtems/rtems/eventimpl.h index df488e1f36..933ea0fe2b 100644 --- a/cpukit/rtems/include/rtems/rtems/eventimpl.h +++ b/cpukit/rtems/include/rtems/rtems/eventimpl.h @@ -44,7 +44,7 @@ extern "C" { */ #define EVENT_SETS_NONE_PENDING 0 -void _Event_Seize( +rtems_status_code _Event_Seize( rtems_event_set event_in, rtems_option option_set, rtems_interval ticks, diff --git a/cpukit/rtems/include/rtems/rtems/messageimpl.h b/cpukit/rtems/include/rtems/rtems/messageimpl.h index d6217f171e..c561ff9a4b 100644 --- a/cpukit/rtems/include/rtems/rtems/messageimpl.h +++ b/cpukit/rtems/include/rtems/rtems/messageimpl.h @@ -73,20 +73,6 @@ rtems_status_code _Message_queue_Submit( Message_queue_Submit_types submit_type ); -/** - * @brief Message queue Translate Core Message Queue Return Code - * - * This function returns a RTEMS status code based on - * @a the_message_queue_status. - * - * @param[in] the_message_queue_status is the status code to translate - * - * @retval translated RTEMS status code - */ -rtems_status_code _Message_queue_Translate_core_message_queue_return_code ( - uint32_t the_message_queue_status -); - /** * @brief Deallocates a message queue control block into * the inactive chain of free message queue control blocks. diff --git a/cpukit/rtems/include/rtems/rtems/semimpl.h b/cpukit/rtems/include/rtems/rtems/semimpl.h index c23bef905a..21e16e99d0 100644 --- a/cpukit/rtems/include/rtems/rtems/semimpl.h +++ b/cpukit/rtems/include/rtems/rtems/semimpl.h @@ -32,82 +32,6 @@ extern "C" { */ extern Objects_Information _Semaphore_Information; -extern const rtems_status_code - _Semaphore_Translate_core_mutex_return_code_[]; - -extern const rtems_status_code - _Semaphore_Translate_core_semaphore_return_code_[]; - -/** - * @brief Semaphore Translate Core Mutex Return Code - * - * This function returns a RTEMS status code based on the mutex - * status code specified. - * - * @param[in] status is the mutex status code to translate - * - * @retval translated RTEMS status code - */ -RTEMS_INLINE_ROUTINE rtems_status_code -_Semaphore_Translate_core_mutex_return_code( - uint32_t status -) -{ - /* - * If this thread is blocking waiting for a result on a remote operation. - */ - #if defined(RTEMS_MULTIPROCESSING) - if ( _Thread_Is_proxy_blocking(status) ) - return RTEMS_PROXY_BLOCKING; - #endif - - /* - * Internal consistency check for bad status from SuperCore - */ - #if defined(RTEMS_DEBUG) - if ( status > CORE_MUTEX_STATUS_LAST ) - return RTEMS_INTERNAL_ERROR; - #endif - return _Semaphore_Translate_core_mutex_return_code_[status]; -} - -#if defined(RTEMS_SMP) -RTEMS_INLINE_ROUTINE rtems_status_code -_Semaphore_Translate_MRSP_status_code( MRSP_Status mrsp_status ) -{ - return (rtems_status_code) mrsp_status; -} -#endif - -/** - * @brief Semaphore Translate Core Semaphore Return Code - * - * This function returns a RTEMS status code based on the semaphore - * status code specified. - * - * @param[in] status is the semaphore status code to translate - * - * @retval translated RTEMS status code - */ -RTEMS_INLINE_ROUTINE rtems_status_code -_Semaphore_Translate_core_semaphore_return_code( - uint32_t status -) -{ - #if defined(RTEMS_MULTIPROCESSING) - if ( _Thread_Is_proxy_blocking(status) ) - return RTEMS_PROXY_BLOCKING; - #endif - /* - * Internal consistency check for bad status from SuperCore - */ - #if defined(RTEMS_DEBUG) - if ( status > CORE_SEMAPHORE_STATUS_LAST ) - return RTEMS_INTERNAL_ERROR; - #endif - return _Semaphore_Translate_core_semaphore_return_code_[status]; -} - /** * @brief Allocates a semaphore control block from * the inactive chain of free semaphore control blocks. diff --git a/cpukit/rtems/include/rtems/rtems/statusimpl.h b/cpukit/rtems/include/rtems/rtems/statusimpl.h index 8aff36a96a..8a51bb8b19 100644 --- a/cpukit/rtems/include/rtems/rtems/statusimpl.h +++ b/cpukit/rtems/include/rtems/rtems/statusimpl.h @@ -18,6 +18,7 @@ #define _RTEMS_RTEMS_STATUSIMPL_H #include +#include #ifdef __cplusplus extern "C" { @@ -39,6 +40,20 @@ extern "C" { */ extern const rtems_status_code _Status_Object_name_errors_to_status[]; +RTEMS_INLINE_ROUTINE rtems_status_code _Status_Get( + Status_Control status +) +{ + return (rtems_status_code) STATUS_GET_CLASSIC( status ); +} + +RTEMS_INLINE_ROUTINE rtems_status_code _Status_Get_after_wait( + const Thread_Control *executing +) +{ + return _Status_Get( _Thread_Wait_get_status( executing ) ); +} + /**@}*/ #ifdef __cplusplus diff --git a/cpukit/rtems/src/barriertranslatereturncode.c b/cpukit/rtems/src/barriertranslatereturncode.c deleted file mode 100644 index 2402701aa4..0000000000 --- a/cpukit/rtems/src/barriertranslatereturncode.c +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @file - * - * @brief Translate SuperCore Barrier Status Code to RTEMS Status Code - * @ingroup ClassicBarrier - */ - -/* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include - -rtems_status_code _Barrier_Translate_core_barrier_return_code_[] = { - RTEMS_SUCCESSFUL, /* CORE_BARRIER_STATUS_SUCCESSFUL */ - RTEMS_SUCCESSFUL, /* CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED */ - RTEMS_OBJECT_WAS_DELETED, /* CORE_BARRIER_WAS_DELETED */ - RTEMS_TIMEOUT /* CORE_BARRIER_TIMEOUT */ -}; - -rtems_status_code _Barrier_Translate_core_barrier_return_code ( - CORE_barrier_Status the_barrier_status -) -{ - /* - * Internal consistency check for bad status from SuperCore - */ - #if defined(RTEMS_DEBUG) - if ( the_barrier_status > CORE_BARRIER_STATUS_LAST ) - return RTEMS_INTERNAL_ERROR; - #endif - return _Barrier_Translate_core_barrier_return_code_[the_barrier_status]; -} diff --git a/cpukit/rtems/src/barrierwait.c b/cpukit/rtems/src/barrierwait.c index 6e133751aa..5f1f023f50 100644 --- a/cpukit/rtems/src/barrierwait.c +++ b/cpukit/rtems/src/barrierwait.c @@ -19,6 +19,7 @@ #endif #include +#include THREAD_QUEUE_OBJECT_ASSERT( Barrier_Control, Barrier.Wait_queue ); @@ -29,7 +30,7 @@ rtems_status_code rtems_barrier_wait( { Barrier_Control *the_barrier; Thread_queue_Context queue_context; - Thread_Control *executing; + Status_Control status; the_barrier = _Barrier_Get( id, &queue_context ); @@ -37,15 +38,12 @@ rtems_status_code rtems_barrier_wait( return RTEMS_INVALID_ID; } - executing = _Thread_Executing; - _CORE_barrier_Seize( + status = _CORE_barrier_Seize( &the_barrier->Barrier, - executing, + _Thread_Executing, true, timeout, &queue_context ); - return _Barrier_Translate_core_barrier_return_code( - executing->Wait.return_code - ); + return _Status_Get( status ); } diff --git a/cpukit/rtems/src/eventmp.c b/cpukit/rtems/src/eventmp.c index 83e1384f84..ac9ab69f08 100644 --- a/cpukit/rtems/src/eventmp.c +++ b/cpukit/rtems/src/eventmp.c @@ -19,6 +19,7 @@ #endif #include +#include #include #include @@ -61,6 +62,7 @@ rtems_status_code _Event_MP_Send( ) { Event_MP_Packet *the_packet; + Status_Control status; the_packet = _Event_MP_Get_packet( id ); if ( the_packet == NULL ) { @@ -74,12 +76,12 @@ rtems_status_code _Event_MP_Send( the_packet->Prefix.id = id; the_packet->event_in = event_in; - return (rtems_status_code) _MPCI_Send_request_packet( + status = _MPCI_Send_request_packet( _Objects_Get_node( id ), &the_packet->Prefix, - STATES_READY, - RTEMS_TIMEOUT + STATES_READY ); + return _Status_Get( status ); } static void _Event_MP_Send_response_packet ( diff --git a/cpukit/rtems/src/eventreceive.c b/cpukit/rtems/src/eventreceive.c index 14f93db4e6..e03ff279eb 100644 --- a/cpukit/rtems/src/eventreceive.c +++ b/cpukit/rtems/src/eventreceive.c @@ -43,7 +43,7 @@ rtems_status_code rtems_event_receive( event = &api->Event; if ( !_Event_sets_Is_empty( event_in ) ) { - _Event_Seize( + sc = _Event_Seize( event_in, option_set, ticks, @@ -54,8 +54,6 @@ rtems_status_code rtems_event_receive( STATES_WAITING_FOR_EVENT, &lock_context ); - - sc = executing->Wait.return_code; } else { *event_out = event->pending_events; _Thread_Lock_release_default( executing, &lock_context ); diff --git a/cpukit/rtems/src/eventseize.c b/cpukit/rtems/src/eventseize.c index 0be6bd6f45..c91d308438 100644 --- a/cpukit/rtems/src/eventseize.c +++ b/cpukit/rtems/src/eventseize.c @@ -21,17 +21,11 @@ #include #include #include +#include #include #include -/* - * INTERRUPT LATENCY: - * available - * wait - * check sync - */ - -void _Event_Seize( +rtems_status_code _Event_Seize( rtems_event_set event_in, rtems_option option_set, rtems_interval ticks, @@ -49,8 +43,6 @@ void _Event_Seize( Thread_Wait_flags intend_to_block; Per_CPU_Control *cpu_self; - executing->Wait.return_code = RTEMS_SUCCESSFUL; - pending_events = event->pending_events; seized_events = _Event_sets_Get( pending_events, event_in ); @@ -60,14 +52,13 @@ void _Event_Seize( _Event_sets_Clear( pending_events, seized_events ); _Thread_Lock_release_default( executing, lock_context ); *event_out = seized_events; - return; + return RTEMS_SUCCESSFUL; } if ( _Options_Is_no_wait( option_set ) ) { _Thread_Lock_release_default( executing, lock_context ); - executing->Wait.return_code = RTEMS_UNSATISFIED; *event_out = seized_events; - return; + return RTEMS_UNSATISFIED; } intend_to_block = wait_class | THREAD_WAIT_STATE_INTEND_TO_BLOCK; @@ -80,6 +71,7 @@ void _Event_Seize( * NOTE: Since interrupts are disabled, this isn't that much of an * issue but better safe than sorry. */ + executing->Wait.return_code = STATUS_SUCCESSFUL; executing->Wait.option = option_set; executing->Wait.count = event_in; executing->Wait.return_argument = event_out; @@ -89,7 +81,6 @@ void _Event_Seize( _Thread_Lock_release_default( executing, lock_context ); if ( ticks ) { - _Thread_Wait_set_timeout_code( executing, RTEMS_TIMEOUT ); _Thread_Timer_insert_relative( executing, cpu_self, @@ -117,6 +108,7 @@ void _Event_Seize( } _Thread_Dispatch_enable( cpu_self ); + return _Status_Get_after_wait( executing ); } #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/rtems/src/msgmp.c b/cpukit/rtems/src/msgmp.c index d8077a71ec..6ec6982fcb 100644 --- a/cpukit/rtems/src/msgmp.c +++ b/cpukit/rtems/src/msgmp.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -105,6 +106,7 @@ static rtems_status_code _Message_queue_MP_Send_request_packet ( ) { Message_queue_MP_Packet *the_packet; + Status_Control status; if ( !_Message_queue_MP_Is_remote( message_queue_id ) ) { return RTEMS_INVALID_ID; @@ -155,13 +157,12 @@ static rtems_status_code _Message_queue_MP_Send_request_packet ( ); } - return (rtems_status_code) _MPCI_Send_request_packet( + status = _MPCI_Send_request_packet( _Objects_Get_node(message_queue_id), &the_packet->Prefix, - STATES_WAITING_FOR_MESSAGE, - RTEMS_TIMEOUT + STATES_WAITING_FOR_MESSAGE ); - break; + return _Status_Get( status ); case MESSAGE_QUEUE_MP_RECEIVE_REQUEST: @@ -181,13 +182,12 @@ static rtems_status_code _Message_queue_MP_Send_request_packet ( _Thread_Executing->Wait.return_argument_second.immutable_object = buffer; _Thread_Executing->Wait.return_argument = size_p; - return (rtems_status_code) _MPCI_Send_request_packet( + status = _MPCI_Send_request_packet( _Objects_Get_node(message_queue_id), &the_packet->Prefix, - STATES_WAITING_FOR_MESSAGE, - RTEMS_TIMEOUT + STATES_WAITING_FOR_MESSAGE ); - break; + return _Status_Get( status ); case MESSAGE_QUEUE_MP_ANNOUNCE_CREATE: case MESSAGE_QUEUE_MP_ANNOUNCE_DELETE: diff --git a/cpukit/rtems/src/msgqbroadcast.c b/cpukit/rtems/src/msgqbroadcast.c index 75f9d60e1b..cc38be96f8 100644 --- a/cpukit/rtems/src/msgqbroadcast.c +++ b/cpukit/rtems/src/msgqbroadcast.c @@ -19,6 +19,7 @@ #endif #include +#include rtems_status_code rtems_message_queue_broadcast( rtems_id id, @@ -27,9 +28,9 @@ rtems_status_code rtems_message_queue_broadcast( uint32_t *count ) { - Message_queue_Control *the_message_queue; - Thread_queue_Context queue_context; - CORE_message_queue_Status status; + Message_queue_Control *the_message_queue; + Thread_queue_Context queue_context; + Status_Control status; if ( buffer == NULL ) { return RTEMS_INVALID_ADDRESS; @@ -60,5 +61,5 @@ rtems_status_code rtems_message_queue_broadcast( count, &queue_context ); - return _Message_queue_Translate_core_message_queue_return_code( status ); + return _Status_Get( status ); } diff --git a/cpukit/rtems/src/msgqreceive.c b/cpukit/rtems/src/msgqreceive.c index 6ed3d25674..66e38f7cae 100644 --- a/cpukit/rtems/src/msgqreceive.c +++ b/cpukit/rtems/src/msgqreceive.c @@ -20,6 +20,7 @@ #include #include +#include THREAD_QUEUE_OBJECT_ASSERT( Message_queue_Control, message_queue.Wait_queue ); @@ -34,6 +35,7 @@ rtems_status_code rtems_message_queue_receive( Message_queue_Control *the_message_queue; Thread_queue_Context queue_context; Thread_Control *executing; + Status_Control status; if ( buffer == NULL ) { return RTEMS_INVALID_ADDRESS; @@ -59,7 +61,7 @@ rtems_status_code rtems_message_queue_receive( ); executing = _Thread_Executing; - _CORE_message_queue_Seize( + status = _CORE_message_queue_Seize( &the_message_queue->message_queue, executing, buffer, @@ -68,7 +70,5 @@ rtems_status_code rtems_message_queue_receive( timeout, &queue_context ); - return _Message_queue_Translate_core_message_queue_return_code( - executing->Wait.return_code - ); + return _Status_Get( status ); } diff --git a/cpukit/rtems/src/msgqsend.c b/cpukit/rtems/src/msgqsend.c index c5bde9d348..9489081a79 100644 --- a/cpukit/rtems/src/msgqsend.c +++ b/cpukit/rtems/src/msgqsend.c @@ -19,6 +19,7 @@ #endif #include +#include rtems_status_code rtems_message_queue_send( rtems_id id, @@ -26,9 +27,9 @@ rtems_status_code rtems_message_queue_send( size_t size ) { - Message_queue_Control *the_message_queue; - Thread_queue_Context queue_context; - CORE_message_queue_Status status; + Message_queue_Control *the_message_queue; + Thread_queue_Context queue_context; + Status_Control status; if ( buffer == NULL ) { return RTEMS_INVALID_ADDRESS; @@ -60,11 +61,5 @@ rtems_status_code rtems_message_queue_send( 0, /* no timeout */ &queue_context ); - - /* - * Since this API does not allow for blocking sends, we can directly - * return the returned status. - */ - - return _Message_queue_Translate_core_message_queue_return_code( status ); + return _Status_Get( status ); } diff --git a/cpukit/rtems/src/msgqtranslatereturncode.c b/cpukit/rtems/src/msgqtranslatereturncode.c deleted file mode 100644 index acd5ba84bb..0000000000 --- a/cpukit/rtems/src/msgqtranslatereturncode.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file - * - * @brief Message queue Translate Core Message Queue Return Code - * @ingroup ClassicMessageQueue - */ - -/* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -rtems_status_code _Message_queue_Translate_core_return_code_[] = { - RTEMS_SUCCESSFUL, /* CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL */ - RTEMS_INVALID_SIZE, /* CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE */ - RTEMS_TOO_MANY, /* CORE_MESSAGE_QUEUE_STATUS_TOO_MANY */ - RTEMS_UNSATISFIED, /* CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED */ - RTEMS_UNSATISFIED, /* CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT */ - RTEMS_OBJECT_WAS_DELETED, /* CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED */ - RTEMS_TIMEOUT /* CORE_MESSAGE_QUEUE_STATUS_TIMEOUT */ -}; - -rtems_status_code _Message_queue_Translate_core_message_queue_return_code ( - uint32_t status -) -{ - /* - * Check for proxy blocking first since it is out of range - * from the external status codes. - */ - #if defined(RTEMS_MULTIPROCESSING) - if ( _Thread_Is_proxy_blocking(status) ) - return RTEMS_PROXY_BLOCKING; - #endif - - /* - * Internal consistency check for bad status from SuperCore - */ - #if defined(RTEMS_DEBUG) - if ( status > CORE_MESSAGE_QUEUE_STATUS_TIMEOUT ) - return RTEMS_INTERNAL_ERROR; - #endif - - return _Message_queue_Translate_core_return_code_[status]; -} diff --git a/cpukit/rtems/src/msgqurgent.c b/cpukit/rtems/src/msgqurgent.c index add5f09bb2..6522d8fb1a 100644 --- a/cpukit/rtems/src/msgqurgent.c +++ b/cpukit/rtems/src/msgqurgent.c @@ -19,6 +19,7 @@ #endif #include +#include rtems_status_code rtems_message_queue_urgent( rtems_id id, @@ -26,9 +27,9 @@ rtems_status_code rtems_message_queue_urgent( size_t size ) { - Message_queue_Control *the_message_queue; - Thread_queue_Context queue_context; - CORE_message_queue_Status status; + Message_queue_Control *the_message_queue; + Thread_queue_Context queue_context; + Status_Control status; if ( buffer == NULL ) { return RTEMS_INVALID_ADDRESS; @@ -60,11 +61,5 @@ rtems_status_code rtems_message_queue_urgent( 0, /* no timeout */ &queue_context ); - - /* - * Since this API does not allow for blocking sends, we can directly - * return the returned status. - */ - - return _Message_queue_Translate_core_message_queue_return_code( status ); + return _Status_Get( status ); } diff --git a/cpukit/rtems/src/partmp.c b/cpukit/rtems/src/partmp.c index f094d619eb..c613ce2c18 100644 --- a/cpukit/rtems/src/partmp.c +++ b/cpukit/rtems/src/partmp.c @@ -19,6 +19,7 @@ #endif #include +#include #include #include #include @@ -100,6 +101,7 @@ static rtems_status_code _Partition_MP_Send_request_packet ( ) { Partition_MP_Packet *the_packet; + Status_Control status; if ( !_Partition_MP_Is_remote( partition_id ) ) { return RTEMS_INVALID_ID; @@ -114,15 +116,12 @@ static rtems_status_code _Partition_MP_Send_request_packet ( _Partition_MP_Initialize_packet( the_packet, partition_id, operation ); the_packet->buffer = buffer; - return - _MPCI_Send_request_packet( - _Objects_Get_node( partition_id ), - &the_packet->Prefix, - STATES_READY, /* Not used */ - RTEMS_TIMEOUT - ); - - break; + status = _MPCI_Send_request_packet( + _Objects_Get_node( partition_id ), + &the_packet->Prefix, + STATES_READY /* Not used */ + ); + return _Status_Get( status ); case PARTITION_MP_ANNOUNCE_CREATE: case PARTITION_MP_ANNOUNCE_DELETE: diff --git a/cpukit/rtems/src/regiongetsegment.c b/cpukit/rtems/src/regiongetsegment.c index d59de38e4a..fe2b9e78ea 100644 --- a/cpukit/rtems/src/regiongetsegment.c +++ b/cpukit/rtems/src/regiongetsegment.c @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -85,13 +86,12 @@ rtems_status_code rtems_region_get_segment( the_region->wait_operations, executing, STATES_WAITING_FOR_SEGMENT, - timeout, - RTEMS_TIMEOUT + timeout ); _Thread_Dispatch_enable( cpu_self ); - return (rtems_status_code) executing->Wait.return_code; + return _Status_Get_after_wait( executing ); } } diff --git a/cpukit/rtems/src/regionprocessqueue.c b/cpukit/rtems/src/regionprocessqueue.c index db5759a8d0..845454b6c7 100644 --- a/cpukit/rtems/src/regionprocessqueue.c +++ b/cpukit/rtems/src/regionprocessqueue.c @@ -19,6 +19,7 @@ #endif #include +#include #include void _Region_Process_queue( @@ -65,7 +66,7 @@ void _Region_Process_queue( *(void **)the_thread->Wait.return_argument = the_segment; _Thread_queue_Extract( the_thread ); - the_thread->Wait.return_code = RTEMS_SUCCESSFUL; + the_thread->Wait.return_code = STATUS_SUCCESSFUL; } _Thread_Dispatch_enable( cpu_self ); diff --git a/cpukit/rtems/src/semcreate.c b/cpukit/rtems/src/semcreate.c index d2895465b7..83d46b607e 100644 --- a/cpukit/rtems/src/semcreate.c +++ b/cpukit/rtems/src/semcreate.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,7 @@ rtems_status_code rtems_semaphore_create( Semaphore_Control *the_semaphore; CORE_mutex_Attributes the_mutex_attr; CORE_semaphore_Disciplines semaphore_discipline; - CORE_mutex_Status mutex_status; + Status_Control status; if ( !rtems_is_name_valid( name ) ) return RTEMS_INVALID_NAME; @@ -155,21 +156,15 @@ rtems_status_code rtems_semaphore_create( semaphore_discipline, count ); + status = STATUS_SUCCESSFUL; #if defined(RTEMS_SMP) } else if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) { - MRSP_Status mrsp_status = _MRSP_Initialize( + status = _MRSP_Initialize( &the_semaphore->Core_control.mrsp, priority_ceiling, _Thread_Get_executing(), count != 1 ); - - if ( mrsp_status != MRSP_SUCCESSFUL ) { - _Semaphore_Free( the_semaphore ); - _Objects_Allocator_unlock(); - - return _Semaphore_Translate_MRSP_status_code( mrsp_status ); - } #endif } else { /* @@ -202,18 +197,18 @@ rtems_status_code rtems_semaphore_create( the_mutex_attr.only_owner_release = false; } - mutex_status = _CORE_mutex_Initialize( + status = _CORE_mutex_Initialize( &the_semaphore->Core_control.mutex, _Thread_Get_executing(), &the_mutex_attr, count != 1 ); + } - if ( mutex_status == CORE_MUTEX_STATUS_CEILING_VIOLATED ) { - _Semaphore_Free( the_semaphore ); - _Objects_Allocator_unlock(); - return RTEMS_INVALID_PRIORITY; - } + if ( status != STATUS_SUCCESSFUL ) { + _Semaphore_Free( the_semaphore ); + _Objects_Allocator_unlock(); + return _Status_Get( status ); } /* diff --git a/cpukit/rtems/src/semdelete.c b/cpukit/rtems/src/semdelete.c index 023a57cf23..405c8055c3 100644 --- a/cpukit/rtems/src/semdelete.c +++ b/cpukit/rtems/src/semdelete.c @@ -20,6 +20,7 @@ #include #include +#include rtems_status_code rtems_semaphore_delete( rtems_id id @@ -52,20 +53,20 @@ rtems_status_code rtems_semaphore_delete( #if defined(RTEMS_SMP) if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) { - MRSP_Status mrsp_status; + Status_Control status; _MRSP_Acquire_critical( &the_semaphore->Core_control.mrsp, &queue_context ); - mrsp_status = _MRSP_Can_destroy( &the_semaphore->Core_control.mrsp ); - if ( mrsp_status != MRSP_SUCCESSFUL ) { + status = _MRSP_Can_destroy( &the_semaphore->Core_control.mrsp ); + if ( status != STATUS_SUCCESSFUL ) { _MRSP_Release( &the_semaphore->Core_control.mrsp, &queue_context ); _Objects_Allocator_unlock(); - return _Semaphore_Translate_MRSP_status_code( mrsp_status ); + return _Status_Get( status ); } } else #endif @@ -103,7 +104,7 @@ rtems_status_code rtems_semaphore_delete( if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) { _CORE_mutex_Flush( &the_semaphore->Core_control.mutex, - _CORE_mutex_Was_deleted, + _Thread_queue_Flush_status_object_was_deleted, &queue_context ); _CORE_mutex_Destroy( &the_semaphore->Core_control.mutex ); diff --git a/cpukit/rtems/src/semflush.c b/cpukit/rtems/src/semflush.c index b18de6d4a7..73305354ec 100644 --- a/cpukit/rtems/src/semflush.c +++ b/cpukit/rtems/src/semflush.c @@ -58,7 +58,7 @@ rtems_status_code rtems_semaphore_flush( rtems_id id ) ); _CORE_mutex_Flush( &the_semaphore->Core_control.mutex, - _CORE_mutex_Unsatisfied_nowait, + _Thread_queue_Flush_status_unavailable, &queue_context ); } else { diff --git a/cpukit/rtems/src/semmp.c b/cpukit/rtems/src/semmp.c index 7f7506cd5f..2b14763694 100644 --- a/cpukit/rtems/src/semmp.c +++ b/cpukit/rtems/src/semmp.c @@ -20,6 +20,7 @@ #include #include +#include RTEMS_STATIC_ASSERT( sizeof(Semaphore_MP_Packet) <= MP_PACKET_MINIMUM_PACKET_SIZE, @@ -80,6 +81,7 @@ static rtems_status_code _Semaphore_MP_Send_request_packet( ) { Semaphore_MP_Packet *the_packet; + Status_Control status; switch ( operation ) { @@ -97,13 +99,12 @@ static rtems_status_code _Semaphore_MP_Send_request_packet( the_packet->Prefix.id = semaphore_id; the_packet->option_set = option_set; - return _MPCI_Send_request_packet( - _Objects_Get_node( semaphore_id ), - &the_packet->Prefix, - STATES_WAITING_FOR_SEMAPHORE, - RTEMS_TIMEOUT - ); - break; + status = _MPCI_Send_request_packet( + _Objects_Get_node( semaphore_id ), + &the_packet->Prefix, + STATES_WAITING_FOR_SEMAPHORE + ); + return _Status_Get( status ); case SEMAPHORE_MP_ANNOUNCE_CREATE: case SEMAPHORE_MP_ANNOUNCE_DELETE: diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c index 6d994f4707..527f7ea03f 100644 --- a/cpukit/rtems/src/semobtain.c +++ b/cpukit/rtems/src/semobtain.c @@ -21,6 +21,7 @@ #include #include #include +#include THREAD_QUEUE_OBJECT_ASSERT( Semaphore_Control, @@ -43,6 +44,7 @@ rtems_status_code rtems_semaphore_obtain( Thread_Control *executing; rtems_attribute attribute_set; bool wait; + Status_Control status; the_semaphore = _Semaphore_Get( id, &queue_context, NULL ); @@ -59,40 +61,33 @@ rtems_status_code rtems_semaphore_obtain( wait = !_Options_Is_no_wait( option_set ); #if defined(RTEMS_SMP) if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) { - MRSP_Status mrsp_status; - - mrsp_status = _MRSP_Seize( + status = _MRSP_Seize( &the_semaphore->Core_control.mrsp, executing, wait, timeout, &queue_context ); - return _Semaphore_Translate_MRSP_status_code( mrsp_status ); } else #endif if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) { - _CORE_mutex_Seize( + status = _CORE_mutex_Seize( &the_semaphore->Core_control.mutex, executing, wait, timeout, &queue_context ); - return _Semaphore_Translate_core_mutex_return_code( - executing->Wait.return_code + } else { + /* must be a counting semaphore */ + status = _CORE_semaphore_Seize( + &the_semaphore->Core_control.semaphore, + executing, + wait, + timeout, + &queue_context ); } - /* must be a counting semaphore */ - _CORE_semaphore_Seize( - &the_semaphore->Core_control.semaphore, - executing, - wait, - timeout, - &queue_context - ); - return _Semaphore_Translate_core_semaphore_return_code( - executing->Wait.return_code - ); + return _Status_Get( status ); } diff --git a/cpukit/rtems/src/semrelease.c b/cpukit/rtems/src/semrelease.c index aa80e8385f..007914c09a 100644 --- a/cpukit/rtems/src/semrelease.c +++ b/cpukit/rtems/src/semrelease.c @@ -23,14 +23,14 @@ #include #include +#include rtems_status_code rtems_semaphore_release( rtems_id id ) { - Semaphore_Control *the_semaphore; - CORE_mutex_Status mutex_status; - CORE_semaphore_Status semaphore_status; - rtems_attribute attribute_set; - Thread_queue_Context queue_context; + Semaphore_Control *the_semaphore; + Thread_queue_Context queue_context; + rtems_attribute attribute_set; + Status_Control status; the_semaphore = _Semaphore_Get( id, @@ -49,28 +49,25 @@ rtems_status_code rtems_semaphore_release( rtems_id id ) attribute_set = the_semaphore->attribute_set; #if defined(RTEMS_SMP) if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) { - MRSP_Status mrsp_status; - - mrsp_status = _MRSP_Surrender( + status = _MRSP_Surrender( &the_semaphore->Core_control.mrsp, _Thread_Executing, &queue_context ); - return _Semaphore_Translate_MRSP_status_code( mrsp_status ); } else #endif if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) { - mutex_status = _CORE_mutex_Surrender( + status = _CORE_mutex_Surrender( &the_semaphore->Core_control.mutex, &queue_context ); - return _Semaphore_Translate_core_mutex_return_code( mutex_status ); } else { - semaphore_status = _CORE_semaphore_Surrender( + status = _CORE_semaphore_Surrender( &the_semaphore->Core_control.semaphore, UINT32_MAX, &queue_context ); - return _Semaphore_Translate_core_semaphore_return_code( semaphore_status ); } + + return _Status_Get( status ); } diff --git a/cpukit/rtems/src/semtranslatereturncode.c b/cpukit/rtems/src/semtranslatereturncode.c deleted file mode 100644 index ea7e8bcb6b..0000000000 --- a/cpukit/rtems/src/semtranslatereturncode.c +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file - * - * @brief Semaphore Translate Core Mutex and Semaphore Return Code - * @ingroup ClassicSem - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -const rtems_status_code _Semaphore_Translate_core_mutex_return_code_[] = { - RTEMS_SUCCESSFUL, /* CORE_MUTEX_STATUS_SUCCESSFUL */ - RTEMS_UNSATISFIED, /* CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT */ -#if defined(RTEMS_POSIX_API) - RTEMS_UNSATISFIED, /* CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED */ -#endif - RTEMS_NOT_OWNER_OF_RESOURCE, /* CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE */ - RTEMS_OBJECT_WAS_DELETED, /* CORE_MUTEX_WAS_DELETED */ - RTEMS_TIMEOUT, /* CORE_MUTEX_TIMEOUT */ - RTEMS_INVALID_PRIORITY /* CORE_MUTEX_STATUS_CEILING_VIOLATED */ -}; - -const rtems_status_code _Semaphore_Translate_core_semaphore_return_code_[] = { - RTEMS_SUCCESSFUL, /* CORE_SEMAPHORE_STATUS_SUCCESSFUL */ - RTEMS_UNSATISFIED, /* CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT */ - RTEMS_OBJECT_WAS_DELETED, /* CORE_SEMAPHORE_WAS_DELETED */ - RTEMS_TIMEOUT, /* CORE_SEMAPHORE_TIMEOUT */ - RTEMS_UNSATISFIED /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */ -}; diff --git a/cpukit/rtems/src/signalmp.c b/cpukit/rtems/src/signalmp.c index cd89e9f0dd..119fe5ace0 100644 --- a/cpukit/rtems/src/signalmp.c +++ b/cpukit/rtems/src/signalmp.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -71,6 +72,7 @@ rtems_status_code _Signal_MP_Send( ) { Signal_MP_Packet *the_packet; + Status_Control status; the_packet = _Signal_MP_Get_packet( id ); if ( the_packet == NULL ) { @@ -84,12 +86,12 @@ rtems_status_code _Signal_MP_Send( the_packet->Prefix.id = id; the_packet->signal_set = signal_set; - return (rtems_status_code) _MPCI_Send_request_packet( + status = _MPCI_Send_request_packet( _Objects_Get_node( id ), &the_packet->Prefix, - STATES_READY, - RTEMS_TIMEOUT + STATES_READY ); + return _Status_Get( status ); } static void _Signal_MP_Send_response_packet ( diff --git a/cpukit/rtems/src/systemeventreceive.c b/cpukit/rtems/src/systemeventreceive.c index c33f468790..a2215fa7ec 100644 --- a/cpukit/rtems/src/systemeventreceive.c +++ b/cpukit/rtems/src/systemeventreceive.c @@ -49,7 +49,7 @@ rtems_status_code rtems_event_system_receive( event = &api->System_event; if ( !_Event_sets_Is_empty( event_in ) ) { - _Event_Seize( + sc = _Event_Seize( event_in, option_set, ticks, @@ -60,8 +60,6 @@ rtems_status_code rtems_event_system_receive( STATES_WAITING_FOR_SYSTEM_EVENT, &lock_context ); - - sc = executing->Wait.return_code; } else { *event_out = event->pending_events; _Thread_Lock_release_default( executing, &lock_context ); diff --git a/cpukit/rtems/src/taskmp.c b/cpukit/rtems/src/taskmp.c index d59db2e313..e3742c528d 100644 --- a/cpukit/rtems/src/taskmp.c +++ b/cpukit/rtems/src/taskmp.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -101,18 +102,20 @@ static rtems_status_code _RTEMS_tasks_MP_Send_request_packet( RTEMS_tasks_MP_Remote_operations operation ) { + Status_Control status; + the_packet->Prefix.the_class = MP_PACKET_TASKS; the_packet->Prefix.length = sizeof( *the_packet ); the_packet->Prefix.to_convert = sizeof( *the_packet ); the_packet->Prefix.id = id; the_packet->operation = operation; - return _MPCI_Send_request_packet( + status = _MPCI_Send_request_packet( _Objects_Get_node( id ), &the_packet->Prefix, - STATES_READY, /* Not used */ - RTEMS_TIMEOUT + STATES_READY /* Not used */ ); + return _Status_Get( status ); } rtems_status_code _RTEMS_tasks_MP_Set_priority( diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index a3f3dfc92d..b178e8e328 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -87,6 +87,7 @@ include_rtems_score_HEADERS += include/rtems/score/stack.h include_rtems_score_HEADERS += include/rtems/score/stackimpl.h include_rtems_score_HEADERS += include/rtems/score/states.h include_rtems_score_HEADERS += include/rtems/score/statesimpl.h +include_rtems_score_HEADERS += include/rtems/score/status.h include_rtems_score_HEADERS += include/rtems/score/sysstate.h include_rtems_score_HEADERS += include/rtems/score/thread.h include_rtems_score_HEADERS += include/rtems/score/threadimpl.h diff --git a/cpukit/score/include/rtems/score/corebarrierimpl.h b/cpukit/score/include/rtems/score/corebarrierimpl.h index 051990e818..d2d9997d95 100644 --- a/cpukit/score/include/rtems/score/corebarrierimpl.h +++ b/cpukit/score/include/rtems/score/corebarrierimpl.h @@ -20,6 +20,7 @@ #define _RTEMS_SCORE_COREBARRIERIMPL_H #include +#include #include #ifdef __cplusplus @@ -31,35 +32,6 @@ extern "C" { */ /**@{**/ -/** - * Core Barrier handler return statuses. - */ -typedef enum { - /** This status indicates that the operation completed successfully. */ - CORE_BARRIER_STATUS_SUCCESSFUL, - /** This status indicates that the barrier is configured for automatic - * release and the caller tripped the automatic release. The caller - * thus did not block. - */ - CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED, - /** This status indicates that the thread was blocked waiting for an - * operation to complete and the barrier was deleted. - */ - CORE_BARRIER_WAS_DELETED, - /** This status indicates that the calling task was willing to block - * but the operation was unable to complete within the time allotted - * because the resource never became available. - */ - CORE_BARRIER_TIMEOUT -} CORE_barrier_Status; - -/** - * @brief Core barrier last status value. - * - * This is the last status value. - */ -#define CORE_BARRIER_STATUS_LAST CORE_BARRIER_TIMEOUT - #define CORE_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO /** @@ -120,9 +92,9 @@ RTEMS_INLINE_ROUTINE void _CORE_barrier_Release( * @param[in] mp_callout is the routine to invoke if the * thread unblocked is remote * - * @note Status is returned via the thread control block. + * @return The method status. */ -void _CORE_barrier_Seize( +Status_Control _CORE_barrier_Seize( CORE_barrier_Control *the_barrier, Thread_Control *executing, bool wait, @@ -160,12 +132,6 @@ RTEMS_INLINE_ROUTINE uint32_t _CORE_barrier_Surrender( ); } -Thread_Control *_CORE_barrier_Was_deleted( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -); - RTEMS_INLINE_ROUTINE void _CORE_barrier_Flush( CORE_barrier_Control *the_barrier, Thread_queue_Context *queue_context @@ -173,7 +139,7 @@ RTEMS_INLINE_ROUTINE void _CORE_barrier_Flush( { _CORE_barrier_Do_flush( the_barrier, - _CORE_barrier_Was_deleted, + _Thread_queue_Flush_status_object_was_deleted, queue_context ); } diff --git a/cpukit/score/include/rtems/score/coremsgimpl.h b/cpukit/score/include/rtems/score/coremsgimpl.h index 30abe0470e..d240c4a405 100644 --- a/cpukit/score/include/rtems/score/coremsgimpl.h +++ b/cpukit/score/include/rtems/score/coremsgimpl.h @@ -20,6 +20,7 @@ #define _RTEMS_SCORE_COREMSGIMPL_H #include +#include #include #include #include @@ -64,40 +65,6 @@ extern "C" { */ typedef int CORE_message_queue_Submit_types; -/** - * @brief The possible set of Core Message Queue handler return statuses. - * - * This enumerated type defines the possible set of Core Message - * Queue handler return statuses. - */ -typedef enum { - /** This value indicates the operation completed sucessfully. */ - CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL, - /** This value indicates that the message was too large for this queue. */ - CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE, - /** This value indicates that there are too many messages pending. */ - CORE_MESSAGE_QUEUE_STATUS_TOO_MANY, - /** This value indicates that a receive was unsuccessful. */ - CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED, - /** This value indicates that a blocking send was unsuccessful. */ - CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT, - /** This value indicates that the message queue being blocked upon - * was deleted while the thread was waiting. - */ - CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED, - /** This value indicates that the thread had to timeout while waiting - * to receive a message because one did not become available. - */ - CORE_MESSAGE_QUEUE_STATUS_TIMEOUT, -} CORE_message_queue_Status; - -/** - * @brief Core message queue last status value. - * - * This is the last status value. - */ -#define CORE_MESSAGE_QUEUE_STATUS_LAST CORE_MESSAGE_QUEUE_STATUS_TIMEOUT - /** * @brief Initialize a message queue. * @@ -202,7 +169,7 @@ uint32_t _CORE_message_queue_Flush( * @retval @a *count will contain the number of messages sent * @retval indication of the successful completion or reason for failure */ -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, @@ -233,7 +200,7 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast( * _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical(). * @retval indication of the successful completion or reason for failure */ -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, @@ -278,7 +245,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit( * + available * + wait */ -void _CORE_message_queue_Seize( +Status_Control _CORE_message_queue_Seize( CORE_message_queue_Control *the_message_queue, Thread_Control *executing, void *buffer, @@ -309,7 +276,7 @@ void _CORE_message_queue_Insert_message( CORE_message_queue_Submit_types submit_type ); -RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send( +RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Send( CORE_message_queue_Control *the_message_queue, const void *buffer, size_t size, @@ -330,7 +297,7 @@ RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send( ); } -RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Urgent( +RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Urgent( CORE_message_queue_Control *the_message_queue, const void *buffer, size_t size, diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h index a32022aa23..f5faf9517a 100644 --- a/cpukit/score/include/rtems/score/coremuteximpl.h +++ b/cpukit/score/include/rtems/score/coremuteximpl.h @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -33,53 +34,6 @@ extern "C" { */ /**@{**/ -/** - * @brief The possible Mutex handler return statuses. - * - * This enumerated type defines the possible Mutex handler return statuses. - */ -typedef enum { - /** This status indicates that the operation completed successfully. */ - CORE_MUTEX_STATUS_SUCCESSFUL, - /** This status indicates that the calling task did not want to block - * and the operation was unable to complete immediately because the - * resource was unavailable. - */ - CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT, -#if defined(RTEMS_POSIX_API) - /** This status indicates that an attempt was made to relock a mutex - * for which nesting is not configured. - */ - CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED, -#endif - /** This status indicates that an attempt was made to release a mutex - * by a thread other than the thread which locked it. - */ - CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE, - /** This status indicates that the thread was blocked waiting for an - * operation to complete and the mutex was deleted. - */ - CORE_MUTEX_WAS_DELETED, - /** This status indicates that the calling task was willing to block - * but the operation was unable to complete within the time allotted - * because the resource never became available. - */ - CORE_MUTEX_TIMEOUT, - - /** This status indicates that a thread of logically greater importance - * than the ceiling priority attempted to lock this mutex. - */ - CORE_MUTEX_STATUS_CEILING_VIOLATED - -} CORE_mutex_Status; - -/** - * @brief The last status value. - * - * This is the last status value. - */ -#define CORE_MUTEX_STATUS_LAST CORE_MUTEX_STATUS_CEILING_VIOLATED - /** * @brief Initializes the mutex based on the parameters passed. * @@ -92,9 +46,9 @@ typedef enum { * @param[in] initially_locked If true, then the mutex is initially locked by * the executing thread. * - * @retval This method returns CORE_MUTEX_STATUS_SUCCESSFUL if successful. + * @retval This method returns STATUS_SUCCESSFUL if successful. */ -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, @@ -140,7 +94,7 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Release( * @param[in] timeout is the maximum number of ticks to block * @param[in] lock_context is the interrupt level */ -void _CORE_mutex_Seize_interrupt_blocking( +Status_Control _CORE_mutex_Seize_interrupt_blocking( CORE_mutex_Control *the_mutex, Thread_Control *executing, Watchdog_Interval timeout, @@ -227,12 +181,10 @@ RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_priority_ceiling( * @param[in,out] the_mutex is the mutex to attempt to lock * @param[in] queue_context is the interrupt level * - * @retval This routine returns 0 if "trylock" can resolve whether or not - * the mutex is immediately obtained or there was an error attempting to - * get it. It returns 1 to indicate that the caller cannot obtain - * the mutex and will have to block to do so. + * @retval STATUS_UNAVAILABLE The mutex is already locked. + * @retval other Otherwise. */ -RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock( +RTEMS_INLINE_ROUTINE Status_Control _CORE_mutex_Seize_interrupt_trylock( CORE_mutex_Control *the_mutex, Thread_Control *executing, Thread_queue_Context *queue_context @@ -240,7 +192,6 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock( { /* disabled when you get here */ - executing->Wait.return_code = CORE_MUTEX_STATUS_SUCCESSFUL; if ( !_CORE_mutex_Is_locked( the_mutex ) ) { the_mutex->holder = executing; the_mutex->nest_count = 1; @@ -251,13 +202,13 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock( if ( !_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) { _CORE_mutex_Release( the_mutex, queue_context ); - return 0; - } /* else must be CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING + } else { + /* + * must be CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING * * we possibly bump the priority of the current holder -- which * happens to be _Thread_Executing. */ - { Priority_Control ceiling; Priority_Control current; @@ -265,10 +216,7 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock( current = executing->current_priority; if ( current == ceiling ) { _CORE_mutex_Release( the_mutex, queue_context ); - return 0; - } - - if ( current > ceiling ) { + } else if ( current > ceiling ) { Per_CPU_Control *cpu_self; cpu_self = _Thread_Dispatch_disable_critical( @@ -277,18 +225,16 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock( _CORE_mutex_Release( the_mutex, queue_context ); _Thread_Raise_priority( executing, ceiling ); _Thread_Dispatch_enable( cpu_self ); - return 0; - } - /* if ( current < ceiling ) */ { - executing->Wait.return_code = CORE_MUTEX_STATUS_CEILING_VIOLATED; + } else /* if ( current < ceiling ) */ { the_mutex->holder = NULL; the_mutex->nest_count = 0; /* undo locking above */ executing->resource_count--; /* undo locking above */ _CORE_mutex_Release( the_mutex, queue_context ); - return 0; + return STATUS_MUTEX_CEILING_VIOLATED; } } - return 0; + + return STATUS_SUCCESSFUL; } /* @@ -301,12 +247,11 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock( case CORE_MUTEX_NESTING_ACQUIRES: the_mutex->nest_count++; _CORE_mutex_Release( the_mutex, queue_context ); - return 0; + return STATUS_SUCCESSFUL; #if defined(RTEMS_POSIX_API) case CORE_MUTEX_NESTING_IS_ERROR: - executing->Wait.return_code = CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED; _CORE_mutex_Release( the_mutex, queue_context ); - return 0; + return STATUS_NESTING_NOT_ALLOWED; #endif case CORE_MUTEX_NESTING_BLOCKS: break; @@ -317,7 +262,7 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock( * The mutex is not available and the caller must deal with the possibility * of blocking. */ - return 1; + return STATUS_UNAVAILABLE; } /** @@ -346,7 +291,7 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock( * * If the caller is willing to wait * then they are blocked. */ -RTEMS_INLINE_ROUTINE void _CORE_mutex_Seize( +RTEMS_INLINE_ROUTINE Status_Control _CORE_mutex_Seize( CORE_mutex_Control *the_mutex, Thread_Control *executing, bool wait, @@ -354,6 +299,8 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Seize( Thread_queue_Context *queue_context ) { + Status_Control status; + if ( _CORE_mutex_Check_dispatch_for_seize( wait ) ) { _Terminate( INTERNAL_ERROR_CORE, @@ -361,39 +308,34 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Seize( INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE ); } + _CORE_mutex_Acquire_critical( the_mutex, queue_context ); - if ( - _CORE_mutex_Seize_interrupt_trylock( the_mutex, executing, queue_context ) - ) { - if ( !wait ) { - _CORE_mutex_Release( the_mutex, queue_context ); - executing->Wait.return_code = - CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT; - } else { - _CORE_mutex_Seize_interrupt_blocking( - the_mutex, - executing, - timeout, - &queue_context->Lock_context - ); - } + + status = _CORE_mutex_Seize_interrupt_trylock( + the_mutex, + executing, + queue_context + ); + + if ( status != STATUS_UNAVAILABLE ) { + return status; } -} -CORE_mutex_Status _CORE_mutex_Surrender( - CORE_mutex_Control *the_mutex, - Thread_queue_Context *queue_context -); + if ( !wait ) { + _CORE_mutex_Release( the_mutex, queue_context ); + return status; + } -Thread_Control *_CORE_mutex_Was_deleted( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -); + return _CORE_mutex_Seize_interrupt_blocking( + the_mutex, + executing, + timeout, + &queue_context->Lock_context + ); +} -Thread_Control *_CORE_mutex_Unsatisfied_nowait( - Thread_Control *the_thread, - Thread_queue_Queue *queue, +Status_Control _CORE_mutex_Surrender( + CORE_mutex_Control *the_mutex, Thread_queue_Context *queue_context ); diff --git a/cpukit/score/include/rtems/score/corerwlockimpl.h b/cpukit/score/include/rtems/score/corerwlockimpl.h index 67084c136a..e80ab0ef0c 100644 --- a/cpukit/score/include/rtems/score/corerwlockimpl.h +++ b/cpukit/score/include/rtems/score/corerwlockimpl.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #ifdef __cplusplus @@ -35,27 +36,6 @@ extern "C" { #define CORE_RWLOCK_TQ_OPERATIONS &_Thread_queue_Operations_FIFO -/** - * Core RWLock handler return statuses. - */ -typedef enum { - /** This status indicates that the operation completed successfully. */ - CORE_RWLOCK_SUCCESSFUL, - /** This status indicates that the thread was blocked waiting for an */ - CORE_RWLOCK_WAS_DELETED, - /** This status indicates that the rwlock was not immediately available. */ - CORE_RWLOCK_UNAVAILABLE, - /** This status indicates that the calling task was willing to block - * but the operation was unable to complete within the time allotted - * because the resource never became available. - */ - CORE_RWLOCK_TIMEOUT -} CORE_RWLock_Status; - -/** This is the last status value. - */ -#define CORE_RWLOCK_STATUS_LAST CORE_RWLOCK_TIMEOUT - /** * This is used to denote that a thread is blocking waiting for * read-only access to the RWLock. @@ -117,11 +97,9 @@ RTEMS_INLINE_ROUTINE void _CORE_RWLock_Release( * @param[in] wait is true if the calling thread is willing to wait * @param[in] timeout is the number of ticks the calling thread is willing * to wait if @a wait is true. - * - * @note Status is returned via the thread control block. */ -void _CORE_RWLock_Seize_for_reading( +Status_Control _CORE_RWLock_Seize_for_reading( CORE_RWLock_Control *the_rwlock, Thread_Control *executing, bool wait, @@ -138,10 +116,8 @@ void _CORE_RWLock_Seize_for_reading( * @param[in] wait is true if the calling thread is willing to wait * @param[in] timeout is the number of ticks the calling thread is willing * to wait if @a wait is true. - * - * @note Status is returned via the thread control block. */ -void _CORE_RWLock_Seize_for_writing( +Status_Control _CORE_RWLock_Seize_for_writing( CORE_RWLock_Control *the_rwlock, Thread_Control *executing, bool wait, @@ -159,7 +135,7 @@ void _CORE_RWLock_Seize_for_writing( * * @retval Status is returned to indicate successful or failure. */ -CORE_RWLock_Status _CORE_RWLock_Surrender( +Status_Control _CORE_RWLock_Surrender( CORE_RWLock_Control *the_rwlock, Thread_queue_Context *queue_context ); diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h index 5dad11bc46..ac90f20b7d 100644 --- a/cpukit/score/include/rtems/score/coresemimpl.h +++ b/cpukit/score/include/rtems/score/coresemimpl.h @@ -22,8 +22,10 @@ #include #include #include +#include #include #include +#include #ifdef __cplusplus extern "C" { @@ -34,39 +36,6 @@ extern "C" { */ /**@{**/ -/** - * Core Semaphore handler return statuses. - */ -typedef enum { - /** This status indicates that the operation completed successfully. */ - CORE_SEMAPHORE_STATUS_SUCCESSFUL, - /** This status indicates that the calling task did not want to block - * and the operation was unable to complete immediately because the - * resource was unavailable. - */ - CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT, - /** This status indicates that the thread was blocked waiting for an - * operation to complete and the semaphore was deleted. - */ - CORE_SEMAPHORE_WAS_DELETED, - /** This status indicates that the calling task was willing to block - * but the operation was unable to complete within the time allotted - * because the resource never became available. - */ - CORE_SEMAPHORE_TIMEOUT, - /** This status indicates that an attempt was made to unlock the semaphore - * and this would have made its count greater than that allowed. - */ - CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED -} CORE_semaphore_Status; - -/** - * @brief Core semaphore last status value. - * - * This is the last status value. - */ -#define CORE_SEMAPHORE_STATUS_LAST CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED - /** * @brief Initialize the semaphore based on the parameters passed. * @@ -108,18 +77,6 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Release( ); } -Thread_Control *_CORE_semaphore_Was_deleted( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -); - -Thread_Control *_CORE_semaphore_Unsatisfied_nowait( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -); - RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy( CORE_semaphore_Control *the_semaphore, Thread_queue_Context *queue_context @@ -128,7 +85,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy( _Thread_queue_Flush_critical( &the_semaphore->Wait_queue.Queue, the_semaphore->operations, - _CORE_semaphore_Was_deleted, + _Thread_queue_Flush_status_object_was_deleted, queue_context ); _Thread_queue_Destroy( &the_semaphore->Wait_queue ); @@ -147,16 +104,16 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy( * * @retval an indication of whether the routine succeeded or failed */ -RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender( +RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Surrender( CORE_semaphore_Control *the_semaphore, uint32_t maximum_count, Thread_queue_Context *queue_context ) { Thread_Control *the_thread; - CORE_semaphore_Status status; + Status_Control status; - status = CORE_SEMAPHORE_STATUS_SUCCESSFUL; + status = STATUS_SUCCESSFUL; _CORE_semaphore_Acquire_critical( the_semaphore, queue_context ); @@ -175,7 +132,7 @@ RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender( if ( the_semaphore->count < maximum_count ) the_semaphore->count += 1; else - status = CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED; + status = STATUS_MAXIMUM_COUNT_EXCEEDED; _CORE_semaphore_Release( the_semaphore, queue_context ); } @@ -191,7 +148,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Flush( _Thread_queue_Flush_critical( &the_semaphore->Wait_queue.Queue, the_semaphore->operations, - _CORE_semaphore_Unsatisfied_nowait, + _Thread_queue_Flush_status_unavailable, queue_context ); } @@ -225,7 +182,7 @@ RTEMS_INLINE_ROUTINE uint32_t _CORE_semaphore_Get_count( * * @note There is currently no MACRO version of this routine. */ -RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize( +RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize( CORE_semaphore_Control *the_semaphore, Thread_Control *executing, bool wait, @@ -235,18 +192,16 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize( { /* disabled when you get here */ - executing->Wait.return_code = CORE_SEMAPHORE_STATUS_SUCCESSFUL; _CORE_semaphore_Acquire_critical( the_semaphore, queue_context ); if ( the_semaphore->count != 0 ) { the_semaphore->count -= 1; _CORE_semaphore_Release( the_semaphore, queue_context ); - return; + return STATUS_SUCCESSFUL; } if ( !wait ) { _CORE_semaphore_Release( the_semaphore, queue_context ); - executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT; - return; + return STATUS_UNSATISFIED; } _Thread_queue_Enqueue_critical( @@ -255,9 +210,9 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize( executing, STATES_WAITING_FOR_SEMAPHORE, timeout, - CORE_SEMAPHORE_TIMEOUT, &queue_context->Lock_context ); + return _Thread_Wait_get_status( executing ); } /** @} */ diff --git a/cpukit/score/include/rtems/score/corespinlockimpl.h b/cpukit/score/include/rtems/score/corespinlockimpl.h index fd4fcf29db..140529b573 100644 --- a/cpukit/score/include/rtems/score/corespinlockimpl.h +++ b/cpukit/score/include/rtems/score/corespinlockimpl.h @@ -20,6 +20,7 @@ #define _RTEMS_SCORE_CORESPINLOCKIMPL_H #include +#include #include #include @@ -33,37 +34,6 @@ extern "C" { */ /**@{**/ -/** - * Core Spinlock handler return statuses. - */ -typedef enum { - /** This status indicates that the operation completed successfully. */ - CORE_SPINLOCK_SUCCESSFUL, - /** This status indicates that the current thread already holds the spinlock. - * An attempt to relock it will result in deadlock. - */ - CORE_SPINLOCK_HOLDER_RELOCKING, - /** This status indicates that the current thread is attempting to unlock a - * spinlock that is held by another thread. - */ - CORE_SPINLOCK_NOT_HOLDER, - /** This status indicates that a thread reached the limit of time it - * was willing to wait on the spin lock. - */ - CORE_SPINLOCK_TIMEOUT, - /** This status indicates that a thread is currently waiting for this - * spin lock. - */ - CORE_SPINLOCK_IS_BUSY, - /** This status indicates that the spinlock is currently locked and thus - * unavailable. - */ - CORE_SPINLOCK_UNAVAILABLE -} CORE_spinlock_Status; - -/** This is a shorthand for the last status code. */ -#define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_UNAVAILABLE - /** This indicates the lock is available. */ #define CORE_SPINLOCK_UNLOCKED 0 @@ -115,7 +85,7 @@ RTEMS_INLINE_ROUTINE void _CORE_spinlock_Release( * @retval A status is returned which indicates the success or failure of * this operation. */ -CORE_spinlock_Status _CORE_spinlock_Seize( +Status_Control _CORE_spinlock_Seize( CORE_spinlock_Control *the_spinlock, bool wait, Watchdog_Interval timeout, @@ -130,7 +100,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize( * * @param[in] the_spinlock is the spinlock to surrender */ -CORE_spinlock_Status _CORE_spinlock_Surrender( +Status_Control _CORE_spinlock_Surrender( CORE_spinlock_Control *the_spinlock, ISR_lock_Context *lock_context ); diff --git a/cpukit/score/include/rtems/score/mpciimpl.h b/cpukit/score/include/rtems/score/mpciimpl.h index 8d19956fbc..eb03a1d7b3 100644 --- a/cpukit/score/include/rtems/score/mpciimpl.h +++ b/cpukit/score/include/rtems/score/mpciimpl.h @@ -19,6 +19,7 @@ #define _RTEMS_SCORE_MPCIIMPL_H #include +#include #ifdef __cplusplus extern "C" { @@ -162,15 +163,13 @@ void _MPCI_Send_process_packet ( * set in addition to the remote operation pending state. It * may indicate the caller is blocking on a message queue * operation. - * @param[in] timeout_code is the timeout code * * @retval This method returns the operation status from the remote node. */ -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 ); /** diff --git a/cpukit/score/include/rtems/score/mrsp.h b/cpukit/score/include/rtems/score/mrsp.h index cb3de67e26..595884864f 100644 --- a/cpukit/score/include/rtems/score/mrsp.h +++ b/cpukit/score/include/rtems/score/mrsp.h @@ -51,31 +51,6 @@ extern "C" { * @{ */ -/** - * @brief MrsP status code. - * - * The values are chosen to directly map to RTEMS status codes. In case this - * implementation is used for other APIs, then for example the errno values can - * be added with a bit shift. - */ -typedef enum { - MRSP_SUCCESSFUL = 0, - MRSP_TIMEOUT = 6, - MRSP_INVALID_NUMBER = 10, - MRSP_RESOUCE_IN_USE = 12, - MRSP_UNSATISFIED = 13, - MRSP_INCORRECT_STATE = 14, - MRSP_INVALID_PRIORITY = 19, - MRSP_NOT_OWNER_OF_RESOURCE = 23, - MRSP_NO_MEMORY = 26, - - /** - * @brief Internal state used for MRSP_Rival::status to indicate that this - * rival waits for resource ownership. - */ - MRSP_WAIT_FOR_OWNERSHIP = 255 -} MRSP_Status; - typedef struct MRSP_Control MRSP_Control; /** @@ -124,10 +99,10 @@ typedef struct { * @brief The rival status. * * Initially the status is set to MRSP_WAIT_FOR_OWNERSHIP. The rival will - * busy wait until a status change happens. This can be MRSP_SUCCESSFUL or - * MRSP_TIMEOUT. State changes are protected by the MrsP control lock. + * busy wait until a status change happens. This can be STATUS_SUCCESSFUL or + * STATUS_TIMEOUT. State changes are protected by the MrsP control lock. */ - volatile MRSP_Status status; + volatile int status; /** * @brief Watchdog for timeouts. diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h index 5173343293..ffdc802f6f 100644 --- a/cpukit/score/include/rtems/score/mrspimpl.h +++ b/cpukit/score/include/rtems/score/mrspimpl.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -36,6 +37,12 @@ extern "C" { * @{ */ +/** + * @brief Internal state used for MRSP_Rival::status to indicate that this + * rival waits for resource ownership. + */ +#define MRSP_WAIT_FOR_OWNERSHIP STATUS_MINUS_ONE + /* * FIXME: Operations with the resource dependency tree are protected by the * global scheduler lock. Since the scheduler lock should be scheduler @@ -126,7 +133,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Claim_ownership( _Thread_Dispatch_enable( cpu_self ); } -RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Initialize( +RTEMS_INLINE_ROUTINE Status_Control _MRSP_Initialize( MRSP_Control *mrsp, Priority_Control ceiling_priority, Thread_Control *executing, @@ -137,14 +144,14 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Initialize( uint32_t i; if ( initially_locked ) { - return MRSP_INVALID_NUMBER; + return STATUS_INVALID_NUMBER; } mrsp->ceiling_priorities = _Workspace_Allocate( sizeof( *mrsp->ceiling_priorities ) * scheduler_count ); if ( mrsp->ceiling_priorities == NULL ) { - return MRSP_NO_MEMORY; + return STATUS_NO_MEMORY; } for ( i = 0 ; i < scheduler_count ; ++i ) { @@ -155,7 +162,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Initialize( _Chain_Initialize_empty( &mrsp->Rivals ); _ISR_lock_Initialize( &mrsp->Lock, "MrsP" ); - return MRSP_SUCCESSFUL; + return STATUS_SUCCESSFUL; } RTEMS_INLINE_ROUTINE Priority_Control _MRSP_Get_ceiling_priority( @@ -199,7 +206,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Timeout( Watchdog_Control *watchdog ) _MRSP_Giant_release( &giant_lock_context ); - rival->status = MRSP_TIMEOUT; + rival->status = STATUS_TIMEOUT; _MRSP_Release( mrsp, &queue_context ); } else { @@ -207,7 +214,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Timeout( Watchdog_Control *watchdog ) } } -RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Wait_for_ownership( +RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership( MRSP_Control *mrsp, Resource_Node *owner, Thread_Control *executing, @@ -217,7 +224,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Wait_for_ownership( Thread_queue_Context *queue_context ) { - MRSP_Status status; + Status_Control status; MRSP_Rival rival; Thread_Life_state life_state; Per_CPU_Control *cpu_self; @@ -278,7 +285,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Wait_for_ownership( ); _ISR_Local_enable( level ); - if ( status == MRSP_TIMEOUT ) { + if ( status == STATUS_TIMEOUT ) { _MRSP_Restore_priority( executing, initial_priority ); } } @@ -286,7 +293,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Wait_for_ownership( return status; } -RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Seize( +RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize( MRSP_Control *mrsp, Thread_Control *executing, bool wait, @@ -294,7 +301,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Seize( Thread_queue_Context *queue_context ) { - MRSP_Status status; + Status_Control status; const Scheduler_Control *scheduler = _Scheduler_Get_own( executing ); uint32_t scheduler_index = _Scheduler_Get_index( scheduler ); Priority_Control initial_priority = executing->current_priority; @@ -308,7 +315,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Seize( if ( !priority_ok) { _ISR_lock_ISR_enable( &queue_context->Lock_context ); - return MRSP_INVALID_PRIORITY; + return STATUS_MUTEX_CEILING_VIOLATED; } _MRSP_Acquire_critical( mrsp, queue_context ); @@ -321,7 +328,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Seize( ceiling_priority, queue_context ); - status = MRSP_SUCCESSFUL; + status = STATUS_SUCCESSFUL; } else if ( wait && _Resource_Node_get_root( owner ) != &executing->Resource_node @@ -338,13 +345,13 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Seize( } else { _MRSP_Release( mrsp, queue_context ); /* Not available, nested access or deadlock */ - status = MRSP_UNSATISFIED; + status = STATUS_UNAVAILABLE; } return status; } -RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Surrender( +RTEMS_INLINE_ROUTINE Status_Control _MRSP_Surrender( MRSP_Control *mrsp, Thread_Control *executing, Thread_queue_Context *queue_context @@ -356,7 +363,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Surrender( if ( _Resource_Get_owner( &mrsp->Resource ) != &executing->Resource_node ) { _ISR_lock_ISR_enable( &queue_context->Lock_context ); - return MRSP_NOT_OWNER_OF_RESOURCE; + return STATUS_NOT_OWNER; } if ( @@ -366,7 +373,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Surrender( ) ) { _ISR_lock_ISR_enable( &queue_context->Lock_context ); - return MRSP_INCORRECT_STATE; + return STATUS_RELEASE_ORDER_VIOLATION; } initial_priority = mrsp->initial_priority_of_owner; @@ -388,7 +395,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Surrender( * This must be inside the critical section since the status prevents a * potential double extraction in _MRSP_Timeout(). */ - rival->status = MRSP_SUCCESSFUL; + rival->status = STATUS_SUCCESSFUL; new_owner = rival->thread; mrsp->initial_priority_of_owner = rival->initial_priority; @@ -413,16 +420,16 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Surrender( _Thread_Dispatch_enable( cpu_self ); - return MRSP_SUCCESSFUL; + return STATUS_SUCCESSFUL; } -RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Can_destroy( MRSP_Control *mrsp ) +RTEMS_INLINE_ROUTINE Status_Control _MRSP_Can_destroy( MRSP_Control *mrsp ) { if ( _Resource_Get_owner( &mrsp->Resource ) != NULL ) { - return MRSP_RESOUCE_IN_USE; + return STATUS_RESOURCE_IN_USE; } - return MRSP_SUCCESSFUL; + return STATUS_SUCCESSFUL; } RTEMS_INLINE_ROUTINE void _MRSP_Destroy( diff --git a/cpukit/score/include/rtems/score/status.h b/cpukit/score/include/rtems/score/status.h new file mode 100644 index 0000000000..eaf69c1597 --- /dev/null +++ b/cpukit/score/include/rtems/score/status.h @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_STATUS_H +#define _RTEMS_SCORE_STATUS_H + +#include + +#if defined(RTEMS_POSIX_API) +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @brief Status code parts for the Classic API. + * + * Must be in synchronization with rtems_status_code. + */ +typedef enum { + STATUS_CLASSIC_INCORRECT_STATE = 14, + STATUS_CLASSIC_INTERNAL_ERROR = 13, + STATUS_CLASSIC_INVALID_NUMBER = 10, + STATUS_CLASSIC_INVALID_PRIORITY = 19, + STATUS_CLASSIC_INVALID_SIZE = 8, + STATUS_CLASSIC_NO_MEMORY = 26, + STATUS_CLASSIC_NOT_OWNER_OF_RESOURCE = 23, + STATUS_CLASSIC_OBJECT_WAS_DELETED = 7, + STATUS_CLASSIC_RESOURCE_IN_USE = 12, + STATUS_CLASSIC_SUCCESSFUL = 0, + STATUS_CLASSIC_TIMEOUT = 6, + STATUS_CLASSIC_TOO_MANY = 5, + STATUS_CLASSIC_UNSATISFIED = 13 +} Status_Classic; + +/** + * @brief Macro to build a status code from Classic and POSIX API parts. + */ +#if defined(RTEMS_POSIX_API) + #define STATUS_BUILD( classic_status, posix_status ) \ + ( ( ( posix_status ) << 8 ) | ( classic_status ) ) +#else + #define STATUS_BUILD( classic_status, posix_status ) \ + ( classic_status ) +#endif + +/** + * @brief Macro to get the Classic API status code. + */ +#define STATUS_GET_CLASSIC( status ) \ + ( ( status ) & 0xff ) + +/** + * @brief Macro to get the POSIX API status code. + * + * Performs an arithmetic shift to reconstruct a negative POSIX status. + */ +#define STATUS_GET_POSIX( status ) \ + ( ( ( (int) ( status ) ) | 0xff ) >> 8 ) + +/** + * @brief Status codes. + */ +typedef enum { + STATUS_BARRIER_AUTOMATICALLY_RELEASED = + STATUS_BUILD( STATUS_CLASSIC_SUCCESSFUL, PTHREAD_BARRIER_SERIAL_THREAD ), + STATUS_DEADLOCK = + STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EDEADLK ), + STATUS_FLUSHED = + STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EAGAIN ), + STATUS_INTERRUPTED = + STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EINTR ), + STATUS_INVALID_NUMBER = + STATUS_BUILD( STATUS_CLASSIC_INVALID_NUMBER, EINVAL ), + STATUS_MAXIMUM_COUNT_EXCEEDED = + STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EOVERFLOW ), + STATUS_MESSAGE_INVALID_SIZE = + STATUS_BUILD( STATUS_CLASSIC_INVALID_SIZE, EMSGSIZE ), + STATUS_MESSAGE_QUEUE_WAIT_IN_ISR = + STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, ENOMEM ), + STATUS_MESSAGE_QUEUE_WAS_DELETED = + STATUS_BUILD( STATUS_CLASSIC_OBJECT_WAS_DELETED, EBADF ), + STATUS_MINUS_ONE = + -1, + STATUS_MUTEX_CEILING_VIOLATED = + STATUS_BUILD( STATUS_CLASSIC_INVALID_PRIORITY, EINVAL ), + STATUS_NESTING_NOT_ALLOWED = + STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EDEADLK ), + STATUS_NO_MEMORY = + STATUS_BUILD( STATUS_CLASSIC_NO_MEMORY, EINVAL ), + STATUS_NOT_OWNER = + STATUS_BUILD( STATUS_CLASSIC_NOT_OWNER_OF_RESOURCE, EPERM ), + STATUS_OBJECT_WAS_DELETED = + STATUS_BUILD( STATUS_CLASSIC_OBJECT_WAS_DELETED, EINVAL ), + STATUS_RELEASE_ORDER_VIOLATION = + STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EPERM ), + STATUS_RESOURCE_IN_USE = + STATUS_BUILD( STATUS_CLASSIC_RESOURCE_IN_USE, EBUSY ), + STATUS_SUCCESSFUL = + STATUS_BUILD( STATUS_CLASSIC_SUCCESSFUL, 0 ), + STATUS_TIMEOUT = + STATUS_BUILD( STATUS_CLASSIC_TIMEOUT, ETIMEDOUT ), + STATUS_TOO_MANY = + STATUS_BUILD( STATUS_CLASSIC_TOO_MANY, EAGAIN ), + STATUS_UNAVAILABLE = + STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EBUSY ), + STATUS_UNSATISFIED = + STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EAGAIN ) +} Status_Control; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_STATUS_H */ diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h index ee19c0430f..4618a409eb 100644 --- a/cpukit/score/include/rtems/score/thread.h +++ b/cpukit/score/include/rtems/score/thread.h @@ -287,11 +287,6 @@ typedef struct { */ uint32_t return_code; - /** - * @brief Code to set the timeout return code in _Thread_Timeout(). - */ - uint32_t timeout_code; - /** * @brief The current thread queue. * diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index cef2786ae4..10811088c9 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -1449,20 +1450,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_restore_default_operations( the_thread->Wait.operations = &_Thread_queue_Operations_default; } -/** - * @brief Sets the thread wait timeout code. - * - * @param[in] the_thread The thread. - * @param[in] timeout_code The new thread wait timeout code. - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_set_timeout_code( - Thread_Control *the_thread, - uint32_t timeout_code -) -{ - the_thread->Wait.timeout_code = timeout_code; -} - /** * @brief Returns the object identifier of the object containing the current * thread wait queue. @@ -1479,6 +1466,13 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_set_timeout_code( */ Objects_Id _Thread_Wait_get_id( const Thread_Control *the_thread ); +RTEMS_INLINE_ROUTINE Status_Control _Thread_Wait_get_status( + const Thread_Control *the_thread +) +{ + return (Status_Control) the_thread->Wait.return_code; +} + /** * @brief General purpose thread wait timeout. * diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h index 752e13e76e..7489d5466b 100644 --- a/cpukit/score/include/rtems/score/threadqimpl.h +++ b/cpukit/score/include/rtems/score/threadqimpl.h @@ -341,7 +341,6 @@ Thread_Control *_Thread_queue_Do_dequeue( * @param[in] state The new state of the thread. * @param[in] timeout Interval to wait. Use WATCHDOG_NO_TIMEOUT to block * potentially forever. - * @param[in] timeout_code The return code in case a timeout occurs. * @param[in] lock_context The lock context of the lock acquire. */ void _Thread_queue_Enqueue_critical( @@ -350,7 +349,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 ); @@ -363,8 +361,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue( const Thread_queue_Operations *operations, Thread_Control *the_thread, States_Control state, - Watchdog_Interval timeout, - uint32_t timeout_code + Watchdog_Interval timeout ) { ISR_lock_Context lock_context; @@ -376,7 +373,6 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue( the_thread, state, timeout, - timeout_code, &lock_context ); } @@ -627,6 +623,40 @@ Thread_Control *_Thread_queue_Flush_default_filter( Thread_queue_Context *queue_context ); +/** + * @brief Status unavailable thread queue flush filter function. + * + * Sets the thread wait return code of the thread to STATUS_UNAVAILABLE. + * + * @param the_thread The thread to extract. + * @param queue Unused. + * @param queue_context Unused. + * + * @retval the_thread Extract this thread. + */ +Thread_Control *_Thread_queue_Flush_status_unavailable( + Thread_Control *the_thread, + Thread_queue_Queue *queue, + Thread_queue_Context *queue_context +); + +/** + * @brief Status object was deleted thread queue flush filter function. + * + * Sets the thread wait return code of the thread to STATUS_OBJECT_WAS_DELETED + * + * @param the_thread The thread to extract. + * @param queue Unused. + * @param queue_context Unused. + * + * @retval the_thread Extract this thread. + */ +Thread_Control *_Thread_queue_Flush_status_object_was_deleted( + Thread_Control *the_thread, + Thread_queue_Queue *queue, + Thread_queue_Context *queue_context +); + /** * @brief Unblocks all threads enqueued on the thread queue. * diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am index 94851407d4..2ed07b91e8 100644 --- a/cpukit/score/preinstall.am +++ b/cpukit/score/preinstall.am @@ -316,6 +316,10 @@ $(PROJECT_INCLUDE)/rtems/score/statesimpl.h: include/rtems/score/statesimpl.h $( $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/statesimpl.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/statesimpl.h +$(PROJECT_INCLUDE)/rtems/score/status.h: include/rtems/score/status.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/status.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/status.h + $(PROJECT_INCLUDE)/rtems/score/sysstate.h: include/rtems/score/sysstate.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/sysstate.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/sysstate.h 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 #include +#include -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 #include -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 #include #include -#include +#include #include -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 #include #include +#include #include #include -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 #include -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 #include -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 #include -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 +#include #include #include #include -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 +#include #include #include #include -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 #include -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 #include -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 #include #include +#include #include #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 +#include 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 +#include 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 -- cgit v1.2.3