[PATCH 3/3] score: Add Status_Control for all APIs
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed May 25 13:48:58 UTC 2016
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 +-
testsuites/sptests/spintrcritical10/init.c | 22 ++--
testsuites/sptests/spintrcritical20/init.c | 14 +-
109 files changed, 707 insertions(+), 1571 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
diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c
index edf551e..f517c22 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 a7632a0..9f73501 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 e04f135..984868e 100644
--- a/cpukit/posix/include/rtems/posix/barrierimpl.h
+++ b/cpukit/posix/include/rtems/posix/barrierimpl.h
@@ -38,20 +38,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.
*
* This function allocates a barrier control block from
diff --git a/cpukit/posix/include/rtems/posix/mqueueimpl.h b/cpukit/posix/include/rtems/posix/mqueueimpl.h
index 2317358..480584b 100644
--- a/cpukit/posix/include/rtems/posix/mqueueimpl.h
+++ b/cpukit/posix/include/rtems/posix/mqueueimpl.h
@@ -149,14 +149,6 @@ RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core(
}
/**
- * @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
*/
RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Namespace_remove (
diff --git a/cpukit/posix/include/rtems/posix/muteximpl.h b/cpukit/posix/include/rtems/posix/muteximpl.h
index 4c7852b..30cc19d 100644
--- a/cpukit/posix/include/rtems/posix/muteximpl.h
+++ b/cpukit/posix/include/rtems/posix/muteximpl.h
@@ -40,12 +40,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
*
* This function allocates a mutexes control block from
@@ -83,42 +77,6 @@ int _POSIX_Mutex_Lock_support(
);
/**
- * @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)
*
* A support routine which translates the mutex id into a local pointer.
diff --git a/cpukit/posix/include/rtems/posix/posixapi.h b/cpukit/posix/include/rtems/posix/posixapi.h
index a5afe92..fabde4d 100644
--- a/cpukit/posix/include/rtems/posix/posixapi.h
+++ b/cpukit/posix/include/rtems/posix/posixapi.h
@@ -23,6 +23,8 @@
#include <rtems/score/assert.h>
#include <rtems/score/apimutex.h>
#include <rtems/score/objectimpl.h>
+#include <rtems/score/threadimpl.h>
+#include <rtems/seterr.h>
/**
* @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 4ab9395..c355f7d 100644
--- a/cpukit/posix/include/rtems/posix/rwlockimpl.h
+++ b/cpukit/posix/include/rtems/posix/rwlockimpl.h
@@ -38,29 +38,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.
*
* This function allocates a RWLock control block from
diff --git a/cpukit/posix/include/rtems/posix/semaphoreimpl.h b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
index 10d7cee..90019d7 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 e0217a0..f1b5639 100644
--- a/cpukit/posix/include/rtems/posix/spinlockimpl.h
+++ b/cpukit/posix/include/rtems/posix/spinlockimpl.h
@@ -37,20 +37,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.
*
* This function allocates a spinlock control block from
diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c
index 4e89ef0..9270c36 100644
--- a/cpukit/posix/src/condwaitsupp.c
+++ b/cpukit/posix/src/condwaitsupp.c
@@ -20,8 +20,10 @@
#include <rtems/posix/condimpl.h>
#include <rtems/posix/muteximpl.h>
+#include <rtems/posix/posixapi.h>
#include <rtems/score/assert.h>
#include <rtems/score/statesimpl.h>
+#include <rtems/score/status.h>
#include <rtems/score/threaddispatch.h>
THREAD_QUEUE_OBJECT_ASSERT( POSIX_Condition_variables_Control, Wait_queue );
@@ -36,9 +38,9 @@ int _POSIX_Condition_variables_Wait_support(
POSIX_Condition_variables_Control *the_cond;
POSIX_Mutex_Control *the_mutex;
Thread_queue_Context queue_context;
- int status;
- int mutex_status;
- CORE_mutex_Status core_mutex_status;
+ int error;
+ int mutex_error;
+ Status_Control status;
Per_CPU_Control *cpu_self;
Thread_Control *executing;
@@ -84,28 +86,23 @@ int _POSIX_Condition_variables_Wait_support(
}
if ( !already_timedout ) {
- executing->Wait.return_code = 0;
_Thread_queue_Enqueue_critical(
&the_cond->Wait_queue.Queue,
POSIX_CONDITION_VARIABLES_TQ_OPERATIONS,
executing,
STATES_WAITING_FOR_CONDITION_VARIABLE,
timeout,
- ETIMEDOUT,
&queue_context.Lock_context
);
} else {
_POSIX_Condition_variables_Release( the_cond, &queue_context );
- executing->Wait.return_code = ETIMEDOUT;
+ executing->Wait.return_code = STATUS_TIMEOUT;
}
_ISR_lock_ISR_disable( &queue_context.Lock_context );
- core_mutex_status = _CORE_mutex_Surrender(
- &the_mutex->Mutex,
- &queue_context
- );
- _Assert( core_mutex_status == CORE_MUTEX_STATUS_SUCCESSFUL );
- (void) core_mutex_status;
+ status = _CORE_mutex_Surrender( &the_mutex->Mutex, &queue_context );
+ _Assert( status == STATUS_SUCCESSFUL );
+ (void) status;
/*
* Switch ourself out because we blocked as a result of the
@@ -114,7 +111,7 @@ int _POSIX_Condition_variables_Wait_support(
_Thread_Dispatch_enable( cpu_self );
- status = (int) executing->Wait.return_code;
+ error = _POSIX_Get_error_after_wait( executing );
/*
* If the thread is interrupted, while in the thread queue, by
@@ -124,18 +121,18 @@ int _POSIX_Condition_variables_Wait_support(
* woken up a pthread_cond_signal() or a pthread_cond_broadcast().
*/
- if ( status == EINTR ) {
- status = 0;
+ if ( error == EINTR ) {
+ error = 0;
}
/*
* When we get here the dispatch disable level is 0.
*/
- mutex_status = pthread_mutex_lock( mutex );
- if ( mutex_status != 0 ) {
+ mutex_error = pthread_mutex_lock( mutex );
+ if ( mutex_error != 0 ) {
return EINVAL;
}
- return status;
+ return error;
}
diff --git a/cpukit/posix/src/mqueuerecvsupp.c b/cpukit/posix/src/mqueuerecvsupp.c
index 541786a..cbb0dc0 100644
--- a/cpukit/posix/src/mqueuerecvsupp.c
+++ b/cpukit/posix/src/mqueuerecvsupp.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/posix/mqueueimpl.h>
+#include <rtems/posix/posixapi.h>
#include <fcntl.h>
@@ -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 2d88eec..9785fb2 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 901d5aa..0000000
--- 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 <pthread.h>
-#include <errno.h>
-
-#include <rtems/system.h>
-#include <rtems/score/coremsg.h>
-#include <rtems/posix/mqueueimpl.h>
-
-/*
- * _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 f17269b..6ecf87c 100644
--- a/cpukit/posix/src/mutexlocksupp.c
+++ b/cpukit/posix/src/mutexlocksupp.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/posix/muteximpl.h>
+#include <rtems/posix/posixapi.h>
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 1cc0b5c..0000000
--- 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 <rtems/posix/muteximpl.h>
-
-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 ff7fc1c..1c3f2d8 100644
--- a/cpukit/posix/src/mutexunlock.c
+++ b/cpukit/posix/src/mutexunlock.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/posix/muteximpl.h>
+#include <rtems/posix/posixapi.h>
/*
* 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 b24b74d..21b0d15 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 e3dd7bf..0000000
--- 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 <pthread.h>
-#include <errno.h>
-
-#include <rtems/system.h>
-#include <rtems/posix/barrierimpl.h>
-
-/*
- * _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 522c18e..0197e46 100644
--- a/cpukit/posix/src/pbarrierwait.c
+++ b/cpukit/posix/src/pbarrierwait.c
@@ -19,26 +19,17 @@
#endif
#include <rtems/posix/barrierimpl.h>
+#include <rtems/posix/posixapi.h>
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 e59aaf9..295148e 100644
--- a/cpukit/posix/src/prwlockrdlock.c
+++ b/cpukit/posix/src/prwlockrdlock.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/posix/rwlockimpl.h>
+#include <rtems/posix/posixapi.h>
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 9e84943..1c10590 100644
--- a/cpukit/posix/src/prwlocktimedrdlock.c
+++ b/cpukit/posix/src/prwlocktimedrdlock.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/posix/rwlockimpl.h>
+#include <rtems/posix/posixapi.h>
#include <rtems/score/todimpl.h>
int pthread_rwlock_timedrdlock(
@@ -30,8 +31,8 @@ int pthread_rwlock_timedrdlock(
Thread_queue_Context queue_context;
Watchdog_Interval ticks;
bool do_wait;
- TOD_Absolute_timeout_conversion_results status;
- Thread_Control *executing;
+ TOD_Absolute_timeout_conversion_results timeout_status;
+ Status_Control status;
/*
* POSIX requires that blocking calls with timeouts that take
@@ -39,15 +40,15 @@ int pthread_rwlock_timedrdlock(
* time provided if the operation would otherwise succeed.
* So we check the abstime provided, and hold on to whether it
* is valid or not. If it isn't correct and in the future,
- * then we do a polling operation and convert the UNSATISFIED
+ * then we do a polling operation and convert the STATUS_UNAVAILABLE
* status into the appropriate error.
*
- * If the status is TOD_ABSOLUTE_TIMEOUT_INVALID,
+ * If the timeout status is TOD_ABSOLUTE_TIMEOUT_INVALID,
* TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST, or TOD_ABSOLUTE_TIMEOUT_IS_NOW,
* then we should not wait.
*/
- status = _TOD_Absolute_timeout_to_ticks( abstime, &ticks );
- do_wait = ( status == TOD_ABSOLUTE_TIMEOUT_IS_IN_FUTURE );
+ timeout_status = _TOD_Absolute_timeout_to_ticks( abstime, &ticks );
+ do_wait = ( timeout_status == TOD_ABSOLUTE_TIMEOUT_IS_IN_FUTURE );
the_rwlock = _POSIX_RWLock_Get( rwlock, &queue_context );
@@ -55,32 +56,26 @@ int pthread_rwlock_timedrdlock(
return EINVAL;
}
- executing = _Thread_Executing;
- _CORE_RWLock_Seize_for_reading(
+ status = _CORE_RWLock_Seize_for_reading(
&the_rwlock->RWLock,
- executing,
+ _Thread_Executing,
do_wait,
ticks,
&queue_context
);
- if (
- !do_wait
- && ( executing->Wait.return_code == CORE_RWLOCK_UNAVAILABLE )
- ) {
- if ( status == TOD_ABSOLUTE_TIMEOUT_INVALID ) {
+ if ( !do_wait && status == STATUS_UNAVAILABLE ) {
+ if ( timeout_status == TOD_ABSOLUTE_TIMEOUT_INVALID ) {
return EINVAL;
}
if (
- status == TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST
- || status == TOD_ABSOLUTE_TIMEOUT_IS_NOW
+ timeout_status == TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST
+ || timeout_status == TOD_ABSOLUTE_TIMEOUT_IS_NOW
) {
return ETIMEDOUT;
}
}
- return _POSIX_RWLock_Translate_core_RWLock_return_code(
- (CORE_RWLock_Status) executing->Wait.return_code
- );
+ return _POSIX_Get_error( status );
}
diff --git a/cpukit/posix/src/prwlocktimedwrlock.c b/cpukit/posix/src/prwlocktimedwrlock.c
index 6be8397..8080a8a 100644
--- a/cpukit/posix/src/prwlocktimedwrlock.c
+++ b/cpukit/posix/src/prwlocktimedwrlock.c
@@ -21,6 +21,7 @@
#endif
#include <rtems/posix/rwlockimpl.h>
+#include <rtems/posix/posixapi.h>
#include <rtems/score/todimpl.h>
int pthread_rwlock_timedwrlock(
@@ -32,8 +33,8 @@ int pthread_rwlock_timedwrlock(
Thread_queue_Context queue_context;
Watchdog_Interval ticks;
bool do_wait;
- TOD_Absolute_timeout_conversion_results status;
- Thread_Control *executing;
+ TOD_Absolute_timeout_conversion_results timeout_status;
+ Status_Control status;
/*
* POSIX requires that blocking calls with timeouts that take
@@ -41,15 +42,15 @@ int pthread_rwlock_timedwrlock(
* time provided if the operation would otherwise succeed.
* So we check the abstime provided, and hold on to whether it
* is valid or not. If it isn't correct and in the future,
- * then we do a polling operation and convert the UNSATISFIED
+ * then we do a polling operation and convert the STATUS_UNAVAILABLE
* status into the appropriate error.
*
- * If the status is TOD_ABSOLUTE_TIMEOUT_INVALID,
+ * If the timeout status is TOD_ABSOLUTE_TIMEOUT_INVALID,
* TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST, or TOD_ABSOLUTE_TIMEOUT_IS_NOW,
* then we should not wait.
*/
- status = _TOD_Absolute_timeout_to_ticks( abstime, &ticks );
- do_wait = ( status == TOD_ABSOLUTE_TIMEOUT_IS_IN_FUTURE );
+ timeout_status = _TOD_Absolute_timeout_to_ticks( abstime, &ticks );
+ do_wait = ( timeout_status == TOD_ABSOLUTE_TIMEOUT_IS_IN_FUTURE );
the_rwlock = _POSIX_RWLock_Get( rwlock, &queue_context );
@@ -57,32 +58,26 @@ int pthread_rwlock_timedwrlock(
return EINVAL;
}
- executing = _Thread_Executing;
- _CORE_RWLock_Seize_for_writing(
+ status = _CORE_RWLock_Seize_for_writing(
&the_rwlock->RWLock,
- executing,
+ _Thread_Executing,
do_wait,
ticks,
&queue_context
);
- if (
- !do_wait
- && ( executing->Wait.return_code == CORE_RWLOCK_UNAVAILABLE )
- ) {
- if ( status == TOD_ABSOLUTE_TIMEOUT_INVALID ) {
+ if ( !do_wait && status == STATUS_UNAVAILABLE ) {
+ if ( timeout_status == TOD_ABSOLUTE_TIMEOUT_INVALID ) {
return EINVAL;
}
if (
- status == TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST
- || status == TOD_ABSOLUTE_TIMEOUT_IS_NOW
+ timeout_status == TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST
+ || timeout_status == TOD_ABSOLUTE_TIMEOUT_IS_NOW
) {
return ETIMEDOUT;
}
}
- return _POSIX_RWLock_Translate_core_RWLock_return_code(
- (CORE_RWLock_Status) executing->Wait.return_code
- );
+ return _POSIX_Get_error( status );
}
diff --git a/cpukit/posix/src/prwlocktranslatereturncode.c b/cpukit/posix/src/prwlocktranslatereturncode.c
deleted file mode 100644
index dceb5f7..0000000
--- 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 <pthread.h>
-#include <errno.h>
-
-#include <rtems/system.h>
-#include <rtems/posix/rwlockimpl.h>
-
-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 1a7cf9e..5c6931e 100644
--- a/cpukit/posix/src/prwlocktryrdlock.c
+++ b/cpukit/posix/src/prwlocktryrdlock.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/posix/rwlockimpl.h>
+#include <rtems/posix/posixapi.h>
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 b6031f9..1181382 100644
--- a/cpukit/posix/src/prwlocktrywrlock.c
+++ b/cpukit/posix/src/prwlocktrywrlock.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/posix/rwlockimpl.h>
+#include <rtems/posix/posixapi.h>
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 dd4337d..05be366 100644
--- a/cpukit/posix/src/prwlockunlock.c
+++ b/cpukit/posix/src/prwlockunlock.c
@@ -21,6 +21,7 @@
#endif
#include <rtems/posix/rwlockimpl.h>
+#include <rtems/posix/posixapi.h>
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 84a4e0f..4592aaa 100644
--- a/cpukit/posix/src/prwlockwrlock.c
+++ b/cpukit/posix/src/prwlockwrlock.c
@@ -20,10 +20,8 @@
#include "config.h"
#endif
-#include <pthread.h>
-#include <errno.h>
-
#include <rtems/posix/rwlockimpl.h>
+#include <rtems/posix/posixapi.h>
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 5635afa..b4475b2 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 502177c..a2db911 100644
--- a/cpukit/posix/src/pspinlock.c
+++ b/cpukit/posix/src/pspinlock.c
@@ -19,14 +19,13 @@
#endif
#include <rtems/posix/spinlockimpl.h>
-
-#include <errno.h>
+#include <rtems/posix/posixapi.h>
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 6d3e9b0..0000000
--- 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 <pthread.h>
-#include <errno.h>
-
-#include <rtems/system.h>
-#include <rtems/score/corespinlock.h>
-#include <rtems/posix/spinlockimpl.h>
-
-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 5f132a3..a8264ab 100644
--- a/cpukit/posix/src/pspintrylock.c
+++ b/cpukit/posix/src/pspintrylock.c
@@ -19,14 +19,13 @@
#endif
#include <rtems/posix/spinlockimpl.h>
-
-#include <errno.h>
+#include <rtems/posix/posixapi.h>
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 35dbcb9..b92473d 100644
--- a/cpukit/posix/src/pspinunlock.c
+++ b/cpukit/posix/src/pspinunlock.c
@@ -21,14 +21,13 @@
#endif
#include <rtems/posix/spinlockimpl.h>
-
-#include <errno.h>
+#include <rtems/posix/posixapi.h>
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 db83a1f..f4a0676 100644
--- a/cpukit/posix/src/pthreadjoin.c
+++ b/cpukit/posix/src/pthreadjoin.c
@@ -26,6 +26,7 @@
#include <errno.h>
#include <rtems/posix/threadsup.h>
+#include <rtems/posix/posixapi.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/statesimpl.h>
@@ -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 04b293d..0000000
--- 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 <rtems/posix/semaphoreimpl.h>
-
-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 9382107..d8e0d69 100644
--- a/cpukit/posix/src/semaphorewaitsupp.c
+++ b/cpukit/posix/src/semaphorewaitsupp.c
@@ -21,6 +21,7 @@
#include <semaphore.h>
#include <rtems/posix/semaphoreimpl.h>
+#include <rtems/posix/posixapi.h>
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 f4633dc..322663b 100644
--- a/cpukit/posix/src/sempost.c
+++ b/cpukit/posix/src/sempost.c
@@ -22,6 +22,7 @@
#include <limits.h>
#include <rtems/posix/semaphoreimpl.h>
+#include <rtems/posix/posixapi.h>
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 77dbe53..ddc2884 100644
--- a/cpukit/posix/src/sigtimedwait.c
+++ b/cpukit/posix/src/sigtimedwait.c
@@ -18,14 +18,12 @@
#include "config.h"
#endif
-#include <pthread.h>
#include <signal.h>
-#include <errno.h>
#include <rtems/posix/pthreadimpl.h>
#include <rtems/posix/psignalimpl.h>
+#include <rtems/posix/posixapi.h>
#include <rtems/score/threadqimpl.h>
-#include <rtems/seterr.h>
#include <rtems/score/isr.h>
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 368dcdc..0a452c8 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 0eaadfc..6a98917 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 df488e1..933ea0f 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 d6217f1..c561ff9 100644
--- a/cpukit/rtems/include/rtems/rtems/messageimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/messageimpl.h
@@ -74,20 +74,6 @@ rtems_status_code _Message_queue_Submit(
);
/**
- * @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 c23bef9..21e16e9 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 8aff36a..8a51bb8 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 <rtems/rtems/status.h>
+#include <rtems/score/threadimpl.h>
#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 2402701..0000000
--- 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 <rtems/system.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/support.h>
-#include <rtems/rtems/barrierimpl.h>
-
-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 6e13375..5f1f023 100644
--- a/cpukit/rtems/src/barrierwait.c
+++ b/cpukit/rtems/src/barrierwait.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/rtems/barrierimpl.h>
+#include <rtems/rtems/statusimpl.h>
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 83e1384..ac9ab69 100644
--- a/cpukit/rtems/src/eventmp.c
+++ b/cpukit/rtems/src/eventmp.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/rtems/eventimpl.h>
+#include <rtems/rtems/statusimpl.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/statesimpl.h>
@@ -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 14f93db..e03ff27 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 0be6bd6..c91d308 100644
--- a/cpukit/rtems/src/eventseize.c
+++ b/cpukit/rtems/src/eventseize.c
@@ -21,17 +21,11 @@
#include <rtems/sysinit.h>
#include <rtems/rtems/eventimpl.h>
#include <rtems/rtems/optionsimpl.h>
+#include <rtems/rtems/statusimpl.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/watchdogimpl.h>
-/*
- * 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 d8077a7..6ec6982 100644
--- a/cpukit/rtems/src/msgmp.c
+++ b/cpukit/rtems/src/msgmp.c
@@ -20,6 +20,7 @@
#include <rtems/rtems/messageimpl.h>
#include <rtems/rtems/optionsimpl.h>
+#include <rtems/rtems/statusimpl.h>
#include <rtems/score/coremsgimpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/threadimpl.h>
@@ -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 75f9d60..cc38be9 100644
--- a/cpukit/rtems/src/msgqbroadcast.c
+++ b/cpukit/rtems/src/msgqbroadcast.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/rtems/messageimpl.h>
+#include <rtems/rtems/statusimpl.h>
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 6ed3d25..66e38f7 100644
--- a/cpukit/rtems/src/msgqreceive.c
+++ b/cpukit/rtems/src/msgqreceive.c
@@ -20,6 +20,7 @@
#include <rtems/rtems/messageimpl.h>
#include <rtems/rtems/optionsimpl.h>
+#include <rtems/rtems/statusimpl.h>
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 c5bde9d..9489081 100644
--- a/cpukit/rtems/src/msgqsend.c
+++ b/cpukit/rtems/src/msgqsend.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/rtems/messageimpl.h>
+#include <rtems/rtems/statusimpl.h>
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 acd5ba8..0000000
--- 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 <rtems/system.h>
-#include <rtems/score/chain.h>
-#include <rtems/score/isr.h>
-#include <rtems/score/coremsgimpl.h>
-#include <rtems/score/threadimpl.h>
-#include <rtems/score/wkspace.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/attrimpl.h>
-#include <rtems/rtems/messageimpl.h>
-#include <rtems/rtems/options.h>
-#include <rtems/rtems/support.h>
-
-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 add5f09..6522d8f 100644
--- a/cpukit/rtems/src/msgqurgent.c
+++ b/cpukit/rtems/src/msgqurgent.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/rtems/messageimpl.h>
+#include <rtems/rtems/statusimpl.h>
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 f094d61..c613ce2 100644
--- a/cpukit/rtems/src/partmp.c
+++ b/cpukit/rtems/src/partmp.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/rtems/partimpl.h>
+#include <rtems/rtems/statusimpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
@@ -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 d59de38..fe2b9e7 100644
--- a/cpukit/rtems/src/regiongetsegment.c
+++ b/cpukit/rtems/src/regiongetsegment.c
@@ -20,6 +20,7 @@
#include <rtems/rtems/regionimpl.h>
#include <rtems/rtems/optionsimpl.h>
+#include <rtems/rtems/statusimpl.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/score/statesimpl.h>
@@ -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 db5759a..845454b 100644
--- a/cpukit/rtems/src/regionprocessqueue.c
+++ b/cpukit/rtems/src/regionprocessqueue.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/rtems/regionimpl.h>
+#include <rtems/score/status.h>
#include <rtems/score/threadqimpl.h>
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 d289546..83d46b6 100644
--- a/cpukit/rtems/src/semcreate.c
+++ b/cpukit/rtems/src/semcreate.c
@@ -25,6 +25,7 @@
#include <rtems/score/isr.h>
#include <rtems/rtems/options.h>
#include <rtems/rtems/semimpl.h>
+#include <rtems/rtems/statusimpl.h>
#include <rtems/rtems/tasksimpl.h>
#include <rtems/score/coremuteximpl.h>
#include <rtems/score/coresemimpl.h>
@@ -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 023a57c..405c805 100644
--- a/cpukit/rtems/src/semdelete.c
+++ b/cpukit/rtems/src/semdelete.c
@@ -20,6 +20,7 @@
#include <rtems/rtems/semimpl.h>
#include <rtems/rtems/attrimpl.h>
+#include <rtems/rtems/statusimpl.h>
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 b18de6d..7330535 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 7f7506c..2b14763 100644
--- a/cpukit/rtems/src/semmp.c
+++ b/cpukit/rtems/src/semmp.c
@@ -20,6 +20,7 @@
#include <rtems/rtems/semimpl.h>
#include <rtems/rtems/optionsimpl.h>
+#include <rtems/rtems/statusimpl.h>
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 6d994f4..527f7ea 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -21,6 +21,7 @@
#include <rtems/rtems/semimpl.h>
#include <rtems/rtems/attrimpl.h>
#include <rtems/rtems/optionsimpl.h>
+#include <rtems/rtems/statusimpl.h>
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 aa80e83..007914c 100644
--- a/cpukit/rtems/src/semrelease.c
+++ b/cpukit/rtems/src/semrelease.c
@@ -23,14 +23,14 @@
#include <rtems/rtems/semimpl.h>
#include <rtems/rtems/attrimpl.h>
+#include <rtems/rtems/statusimpl.h>
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 ea7e8bc..0000000
--- 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 <rtems/rtems/semimpl.h>
-
-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 cd89e9f..119fe5a 100644
--- a/cpukit/rtems/src/signalmp.c
+++ b/cpukit/rtems/src/signalmp.c
@@ -20,6 +20,7 @@
#include <rtems/rtems/signalimpl.h>
#include <rtems/rtems/optionsimpl.h>
+#include <rtems/rtems/statusimpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
@@ -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 c33f468..a2215fa 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 d59db2e..e3742c5 100644
--- a/cpukit/rtems/src/taskmp.c
+++ b/cpukit/rtems/src/taskmp.c
@@ -20,6 +20,7 @@
#include <rtems/rtems/tasksimpl.h>
#include <rtems/rtems/optionsimpl.h>
+#include <rtems/rtems/statusimpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
@@ -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 a3f3dfc..b178e8e 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 051990e..d2d9997 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 <rtems/score/corebarrier.h>
+#include <rtems/score/status.h>
#include <rtems/score/threadqimpl.h>
#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 30abe04..d240c4a 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 <rtems/score/coremsg.h>
+#include <rtems/score/status.h>
#include <rtems/score/chainimpl.h>
#include <rtems/score/threaddispatch.h>
#include <rtems/score/threadqimpl.h>
@@ -65,40 +66,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.
*
* This package is the implementation of the CORE Message Queue Handler.
@@ -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 a32022a..f5faf95 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -20,6 +20,7 @@
#include <rtems/score/coremutex.h>
#include <rtems/score/chainimpl.h>
+#include <rtems/score/status.h>
#include <rtems/score/sysstate.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
@@ -34,53 +35,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.
*
* This routine 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 67084c1..e80ab0e 100644
--- a/cpukit/score/include/rtems/score/corerwlockimpl.h
+++ b/cpukit/score/include/rtems/score/corerwlockimpl.h
@@ -22,6 +22,7 @@
#include <rtems/score/corerwlock.h>
#include <rtems/score/thread.h>
#include <rtems/score/threadqimpl.h>
+#include <rtems/score/status.h>
#include <rtems/score/watchdog.h>
#ifdef __cplusplus
@@ -36,27 +37,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 5dad11b..ac90f20 100644
--- a/cpukit/score/include/rtems/score/coresemimpl.h
+++ b/cpukit/score/include/rtems/score/coresemimpl.h
@@ -22,8 +22,10 @@
#include <rtems/score/coresem.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/threaddispatch.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/score/statesimpl.h>
+#include <rtems/score/status.h>
#ifdef __cplusplus
extern "C" {
@@ -35,39 +37,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.
*
* This package is the implementation of the CORE Semaphore Handler.
@@ -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 fd4fcf2..140529b 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 <rtems/score/corespinlock.h>
+#include <rtems/score/status.h>
#include <rtems/score/watchdog.h>
#include <string.h>
@@ -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 8d19956..eb03a1d 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 <rtems/score/mpci.h>
+#include <rtems/score/status.h>
#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 cb3de67..5958848 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 5173343..ffdc802 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -23,6 +23,7 @@
#include <rtems/score/chainimpl.h>
#include <rtems/score/resourceimpl.h>
#include <rtems/score/schedulerimpl.h>
+#include <rtems/score/status.h>
#include <rtems/score/watchdogimpl.h>
#include <rtems/score/wkspace.h>
@@ -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 0000000..2ca03fe
--- /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
+ * <rtems at embedded-brains.de>
+ *
+ * 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 <rtems/score/basedefs.h>
+
+#if defined(RTEMS_POSIX_API)
+#include <errno.h>
+#include <pthread.h>
+#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, ENOSYS ),
+ 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 ee19c04..4618a40 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -288,11 +288,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.
*
* In case this field is @c NULL, then the thread is not blocked on a thread
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index cef2786..1081108 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -29,6 +29,7 @@
#include <rtems/score/objectimpl.h>
#include <rtems/score/resourceimpl.h>
#include <rtems/score/statesimpl.h>
+#include <rtems/score/status.h>
#include <rtems/score/sysstate.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/score/todimpl.h>
@@ -1450,20 +1451,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_restore_default_operations(
}
/**
- * @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 752e13e..7489d54 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
);
}
@@ -628,6 +624,40 @@ Thread_Control *_Thread_queue_Flush_default_filter(
);
/**
+ * @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.
*
* This function iteratively extracts the first enqueued thread of the thread
diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am
index 9485140..2ed07b9 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 c0320b2..39924e8 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 a32f88c..8da3ca1 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 33f1718..a1c862d 100644
--- a/cpukit/score/src/corebarrierwait.c
+++ b/cpukit/score/src/corebarrierwait.c
@@ -20,8 +20,9 @@
#include <rtems/score/corebarrierimpl.h>
#include <rtems/score/statesimpl.h>
+#include <rtems/score/threadimpl.h>
-void _CORE_barrier_Seize(
+Status_Control _CORE_barrier_Seize(
CORE_barrier_Control *the_barrier,
Thread_Control *executing,
bool wait,
@@ -31,8 +32,6 @@ void _CORE_barrier_Seize(
{
uint32_t number_of_waiting_threads;
- executing->Wait.return_code = CORE_BARRIER_STATUS_SUCCESSFUL;
-
_CORE_barrier_Acquire_critical( the_barrier, queue_context );
number_of_waiting_threads = the_barrier->number_of_waiting_threads;
@@ -42,8 +41,8 @@ void _CORE_barrier_Seize(
_CORE_barrier_Is_automatic( &the_barrier->Attributes )
&& number_of_waiting_threads == the_barrier->Attributes.maximum_count
) {
- executing->Wait.return_code = CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED;
_CORE_barrier_Surrender( the_barrier, queue_context );
+ return STATUS_BARRIER_AUTOMATICALLY_RELEASED;
} else {
the_barrier->number_of_waiting_threads = number_of_waiting_threads;
_Thread_queue_Enqueue_critical(
@@ -52,8 +51,8 @@ void _CORE_barrier_Seize(
executing,
STATES_WAITING_FOR_BARRIER,
timeout,
- CORE_BARRIER_TIMEOUT,
&queue_context->Lock_context
);
+ return _Thread_Wait_get_status( executing );
}
}
diff --git a/cpukit/score/src/coremsgbroadcast.c b/cpukit/score/src/coremsgbroadcast.c
index 23dd343..f7579c2 100644
--- a/cpukit/score/src/coremsgbroadcast.c
+++ b/cpukit/score/src/coremsgbroadcast.c
@@ -21,7 +21,7 @@
#include <rtems/score/coremsgimpl.h>
#include <rtems/score/objectimpl.h>
-CORE_message_queue_Status _CORE_message_queue_Broadcast(
+Status_Control _CORE_message_queue_Broadcast(
CORE_message_queue_Control *the_message_queue,
const void *buffer,
size_t size,
@@ -34,7 +34,7 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
if ( size > the_message_queue->maximum_message_size ) {
_ISR_lock_ISR_enable( &queue_context->Lock_context );
- return CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE;
+ return STATUS_MESSAGE_INVALID_SIZE;
}
number_broadcasted = 0;
@@ -60,5 +60,5 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
_CORE_message_queue_Release( the_message_queue, queue_context );
*count = number_broadcasted;
- return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
diff --git a/cpukit/score/src/coremsgclose.c b/cpukit/score/src/coremsgclose.c
index e24d756..f8a53a2 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 b05ddd6..00ff437 100644
--- a/cpukit/score/src/coremsgseize.c
+++ b/cpukit/score/src/coremsgseize.c
@@ -22,10 +22,10 @@
#include <rtems/score/chain.h>
#include <rtems/score/isr.h>
#include <rtems/score/coremsgimpl.h>
-#include <rtems/score/thread.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/statesimpl.h>
-void _CORE_message_queue_Seize(
+Status_Control _CORE_message_queue_Seize(
CORE_message_queue_Control *the_message_queue,
Thread_Control *executing,
void *buffer,
@@ -37,7 +37,6 @@ void _CORE_message_queue_Seize(
{
CORE_message_queue_Buffer_control *the_message;
- executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
the_message = _CORE_message_queue_Get_pending_message( the_message_queue );
if ( the_message != NULL ) {
the_message_queue->number_of_pending_messages -= 1;
@@ -58,7 +57,7 @@ void _CORE_message_queue_Seize(
*/
_CORE_message_queue_Free_message_buffer(the_message_queue, the_message);
_CORE_message_queue_Release( the_message_queue, queue_context );
- return;
+ return STATUS_SUCCESSFUL;
#else
{
Thread_Control *the_thread;
@@ -80,7 +79,7 @@ void _CORE_message_queue_Seize(
the_message
);
_CORE_message_queue_Release( the_message_queue, queue_context );
- return;
+ return STATUS_SUCCESSFUL;
}
/*
@@ -101,15 +100,14 @@ void _CORE_message_queue_Seize(
the_thread,
queue_context
);
- return;
+ return STATUS_SUCCESSFUL;
}
#endif
}
if ( !wait ) {
_CORE_message_queue_Release( the_message_queue, queue_context );
- executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT;
- return;
+ return STATUS_UNSATISFIED;
}
executing->Wait.return_argument_second.mutable_object = buffer;
@@ -122,7 +120,7 @@ void _CORE_message_queue_Seize(
executing,
STATES_WAITING_FOR_MESSAGE,
timeout,
- CORE_MESSAGE_QUEUE_STATUS_TIMEOUT,
&queue_context->Lock_context
);
+ return _Thread_Wait_get_status( executing );
}
diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c
index a867741..a623291 100644
--- a/cpukit/score/src/coremsgsubmit.c
+++ b/cpukit/score/src/coremsgsubmit.c
@@ -22,10 +22,11 @@
#include <rtems/score/coremsgimpl.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/isr.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/wkspace.h>
-CORE_message_queue_Status _CORE_message_queue_Submit(
+Status_Control _CORE_message_queue_Submit(
CORE_message_queue_Control *the_message_queue,
Thread_Control *executing,
const void *buffer,
@@ -41,7 +42,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
if ( size > the_message_queue->maximum_message_size ) {
_CORE_message_queue_Release( the_message_queue, queue_context );
- return CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE;
+ return STATUS_MESSAGE_INVALID_SIZE;
}
/*
@@ -56,7 +57,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
queue_context
);
if ( the_thread != NULL ) {
- return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
/*
@@ -95,12 +96,12 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
_CORE_message_queue_Release( the_message_queue, queue_context );
#endif
- return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND)
_CORE_message_queue_Release( the_message_queue, queue_context );
- return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY;
+ return STATUS_TOO_MANY;
#else
/*
* No message buffers were available so we may need to return an
@@ -109,7 +110,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
*/
if ( !wait ) {
_CORE_message_queue_Release( the_message_queue, queue_context );
- return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY;
+ return STATUS_TOO_MANY;
}
/*
@@ -118,7 +119,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
*/
if ( _ISR_Is_in_progress() ) {
_CORE_message_queue_Release( the_message_queue, queue_context );
- return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED;
+ return STATUS_MESSAGE_QUEUE_WAIT_IN_ISR;
}
/*
@@ -127,7 +128,6 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
* it as a variable. Doing this emphasizes how dangerous it
* would be to use this variable prior to here.
*/
- executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
executing->Wait.return_argument_second.immutable_object = buffer;
executing->Wait.option = (uint32_t) size;
executing->Wait.count = submit_type;
@@ -138,9 +138,8 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
executing,
STATES_WAITING_FOR_MESSAGE,
timeout,
- CORE_MESSAGE_QUEUE_STATUS_TIMEOUT,
&queue_context->Lock_context
);
- return executing->Wait.return_code;
+ return _Thread_Wait_get_status( executing );
#endif
}
diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c
index ecca244..ec073ff 100644
--- a/cpukit/score/src/coremutex.c
+++ b/cpukit/score/src/coremutex.c
@@ -23,7 +23,7 @@
#include <rtems/score/coremuteximpl.h>
#include <rtems/score/thread.h>
-CORE_mutex_Status _CORE_mutex_Initialize(
+Status_Control _CORE_mutex_Initialize(
CORE_mutex_Control *the_mutex,
Thread_Control *executing,
const CORE_mutex_Attributes *the_mutex_attributes,
@@ -64,7 +64,7 @@ CORE_mutex_Status _CORE_mutex_Initialize(
* the object creation.
*/
_Thread_Dispatch_enable( cpu_self );
- return CORE_MUTEX_STATUS_CEILING_VIOLATED;
+ return STATUS_MUTEX_CEILING_VIOLATED;
}
executing->resource_count++;
@@ -88,27 +88,5 @@ CORE_mutex_Status _CORE_mutex_Initialize(
the_mutex->operations = &_Thread_queue_Operations_priority;
}
- return CORE_MUTEX_STATUS_SUCCESSFUL;
-}
-
-Thread_Control *_CORE_mutex_Was_deleted(
- Thread_Control *the_thread,
- Thread_queue_Queue *queue,
- Thread_queue_Context *queue_context
-)
-{
- the_thread->Wait.return_code = CORE_MUTEX_WAS_DELETED;
-
- return the_thread;
-}
-
-Thread_Control *_CORE_mutex_Unsatisfied_nowait(
- Thread_Control *the_thread,
- Thread_queue_Queue *queue,
- Thread_queue_Context *queue_context
-)
-{
- the_thread->Wait.return_code = CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT;
-
- return the_thread;
+ return STATUS_SUCCESSFUL;
}
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index 168d697..0fc63f4 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -24,7 +24,7 @@
#include <rtems/score/statesimpl.h>
#include <rtems/score/thread.h>
-void _CORE_mutex_Seize_interrupt_blocking(
+Status_Control _CORE_mutex_Seize_interrupt_blocking(
CORE_mutex_Control *the_mutex,
Thread_Control *executing,
Watchdog_Interval timeout,
@@ -67,12 +67,13 @@ void _CORE_mutex_Seize_interrupt_blocking(
executing,
STATES_WAITING_FOR_MUTEX,
timeout,
- CORE_MUTEX_TIMEOUT,
lock_context
);
#if !defined(RTEMS_SMP)
_Thread_Dispatch_enable( _Per_CPU_Get() );
#endif
+
+ return _Thread_Wait_get_status( executing );
}
diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c
index 040a580..1da9827 100644
--- a/cpukit/score/src/coremutexsurrender.c
+++ b/cpukit/score/src/coremutexsurrender.c
@@ -23,7 +23,7 @@
#include <rtems/score/coremuteximpl.h>
#include <rtems/score/thread.h>
-CORE_mutex_Status _CORE_mutex_Surrender(
+Status_Control _CORE_mutex_Surrender(
CORE_mutex_Control *the_mutex,
Thread_queue_Context *queue_context
)
@@ -44,7 +44,7 @@ CORE_mutex_Status _CORE_mutex_Surrender(
if ( the_mutex->Attributes.only_owner_release ) {
if ( !_Thread_Is_executing( holder ) ) {
_ISR_lock_ISR_enable( &queue_context->Lock_context );
- return CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE;
+ return STATUS_NOT_OWNER;
}
}
@@ -54,7 +54,7 @@ CORE_mutex_Status _CORE_mutex_Surrender(
if ( !the_mutex->nest_count ) {
_CORE_mutex_Release( the_mutex, queue_context );
- return CORE_MUTEX_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
the_mutex->nest_count--;
@@ -69,12 +69,12 @@ CORE_mutex_Status _CORE_mutex_Surrender(
switch ( the_mutex->Attributes.lock_nesting_behavior ) {
case CORE_MUTEX_NESTING_ACQUIRES:
_CORE_mutex_Release( the_mutex, queue_context );
- return CORE_MUTEX_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
#if defined(RTEMS_POSIX_API)
case CORE_MUTEX_NESTING_IS_ERROR:
/* should never occur */
_CORE_mutex_Release( the_mutex, queue_context );
- return CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED;
+ return STATUS_NESTING_NOT_ALLOWED;
#endif
case CORE_MUTEX_NESTING_BLOCKS:
/* Currently no API exercises this behavior. */
@@ -83,7 +83,7 @@ CORE_mutex_Status _CORE_mutex_Surrender(
#else
_CORE_mutex_Release( the_mutex, queue_context );
/* must be CORE_MUTEX_NESTING_ACQUIRES or we wouldn't be here */
- return CORE_MUTEX_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
#endif
}
@@ -179,5 +179,5 @@ CORE_mutex_Status _CORE_mutex_Surrender(
}
}
- return CORE_MUTEX_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
diff --git a/cpukit/score/src/corerwlockobtainread.c b/cpukit/score/src/corerwlockobtainread.c
index 639ea70..5192eb1 100644
--- a/cpukit/score/src/corerwlockobtainread.c
+++ b/cpukit/score/src/corerwlockobtainread.c
@@ -19,11 +19,12 @@
#endif
#include <rtems/score/corerwlockimpl.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/watchdog.h>
-void _CORE_RWLock_Seize_for_reading(
+Status_Control _CORE_RWLock_Seize_for_reading(
CORE_RWLock_Control *the_rwlock,
Thread_Control *executing,
bool wait,
@@ -44,8 +45,7 @@ void _CORE_RWLock_Seize_for_reading(
the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_READING;
the_rwlock->number_of_readers += 1;
_CORE_RWLock_Release( the_rwlock, queue_context );
- executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
- return;
+ return STATUS_SUCCESSFUL;
case CORE_RWLOCK_LOCKED_FOR_READING: {
Thread_Control *waiter;
@@ -56,8 +56,7 @@ void _CORE_RWLock_Seize_for_reading(
if ( !waiter ) {
the_rwlock->number_of_readers += 1;
_CORE_RWLock_Release( the_rwlock, queue_context );
- executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
- return;
+ return STATUS_SUCCESSFUL;
}
break;
}
@@ -71,16 +70,14 @@ void _CORE_RWLock_Seize_for_reading(
if ( !wait ) {
_CORE_RWLock_Release( the_rwlock, queue_context );
- executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE;
- return;
+ return STATUS_UNAVAILABLE;
}
/*
* We need to wait to enter this critical section
*/
- executing->Wait.option = CORE_RWLOCK_THREAD_WAITING_FOR_READ;
- executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
+ executing->Wait.option = CORE_RWLOCK_THREAD_WAITING_FOR_READ;
_Thread_queue_Enqueue_critical(
&the_rwlock->Wait_queue.Queue,
@@ -88,7 +85,7 @@ void _CORE_RWLock_Seize_for_reading(
executing,
STATES_WAITING_FOR_RWLOCK,
timeout,
- CORE_RWLOCK_TIMEOUT,
&queue_context->Lock_context
);
+ return _Thread_Wait_get_status( executing );
}
diff --git a/cpukit/score/src/corerwlockobtainwrite.c b/cpukit/score/src/corerwlockobtainwrite.c
index a7d1bb1..0536b82 100644
--- a/cpukit/score/src/corerwlockobtainwrite.c
+++ b/cpukit/score/src/corerwlockobtainwrite.c
@@ -19,11 +19,12 @@
#endif
#include <rtems/score/corerwlockimpl.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/watchdog.h>
-void _CORE_RWLock_Seize_for_writing(
+Status_Control _CORE_RWLock_Seize_for_writing(
CORE_RWLock_Control *the_rwlock,
Thread_Control *executing,
bool wait,
@@ -44,8 +45,7 @@ void _CORE_RWLock_Seize_for_writing(
case CORE_RWLOCK_UNLOCKED:
the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING;
_CORE_RWLock_Release( the_rwlock, queue_context );
- executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
- return;
+ return STATUS_SUCCESSFUL;
case CORE_RWLOCK_LOCKED_FOR_READING:
case CORE_RWLOCK_LOCKED_FOR_WRITING:
@@ -58,16 +58,14 @@ void _CORE_RWLock_Seize_for_writing(
if ( !wait ) {
_CORE_RWLock_Release( the_rwlock, queue_context );
- executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE;
- return;
+ return STATUS_UNAVAILABLE;
}
/*
* We need to wait to enter this critical section
*/
- executing->Wait.option = CORE_RWLOCK_THREAD_WAITING_FOR_WRITE;
- executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
+ executing->Wait.option = CORE_RWLOCK_THREAD_WAITING_FOR_WRITE;
_Thread_queue_Enqueue_critical(
&the_rwlock->Wait_queue.Queue,
@@ -75,7 +73,7 @@ void _CORE_RWLock_Seize_for_writing(
executing,
STATES_WAITING_FOR_RWLOCK,
timeout,
- CORE_RWLOCK_TIMEOUT,
&queue_context->Lock_context
);
+ return _Thread_Wait_get_status( executing );
}
diff --git a/cpukit/score/src/corerwlockrelease.c b/cpukit/score/src/corerwlockrelease.c
index 81e01d1..71aa12a 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 c94f2b7..2bdd81c 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 6f2ea71..4a4f952 100644
--- a/cpukit/score/src/corespinlockrelease.c
+++ b/cpukit/score/src/corespinlockrelease.c
@@ -21,7 +21,7 @@
#include <rtems/score/corespinlockimpl.h>
#include <rtems/score/percpu.h>
-CORE_spinlock_Status _CORE_spinlock_Surrender(
+Status_Control _CORE_spinlock_Surrender(
CORE_spinlock_Control *the_spinlock,
ISR_lock_Context *lock_context
)
@@ -36,7 +36,7 @@ CORE_spinlock_Status _CORE_spinlock_Surrender(
|| the_spinlock->holder != _Thread_Executing
) {
_CORE_spinlock_Release( the_spinlock, lock_context );
- return CORE_SPINLOCK_NOT_HOLDER;
+ return STATUS_NOT_OWNER;
}
/*
@@ -47,5 +47,5 @@ CORE_spinlock_Status _CORE_spinlock_Surrender(
the_spinlock->holder = 0;
_CORE_spinlock_Release( the_spinlock, lock_context );
- return CORE_SPINLOCK_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
diff --git a/cpukit/score/src/corespinlockwait.c b/cpukit/score/src/corespinlockwait.c
index cc939c2..4aacb60 100644
--- a/cpukit/score/src/corespinlockwait.c
+++ b/cpukit/score/src/corespinlockwait.c
@@ -21,7 +21,7 @@
#include <rtems/score/corespinlockimpl.h>
#include <rtems/score/percpu.h>
-CORE_spinlock_Status _CORE_spinlock_Seize(
+Status_Control _CORE_spinlock_Seize(
CORE_spinlock_Control *the_spinlock,
bool wait,
Watchdog_Interval timeout,
@@ -40,7 +40,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize(
if ( the_spinlock->lock == CORE_SPINLOCK_LOCKED &&
the_spinlock->holder == executing ) {
_CORE_spinlock_Release( the_spinlock, lock_context );
- return CORE_SPINLOCK_HOLDER_RELOCKING;
+ return STATUS_NESTING_NOT_ALLOWED;
}
the_spinlock->users += 1;
for ( ;; ) {
@@ -48,7 +48,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize(
the_spinlock->lock = CORE_SPINLOCK_LOCKED;
the_spinlock->holder = executing;
_CORE_spinlock_Release( the_spinlock, lock_context );
- return CORE_SPINLOCK_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
/*
@@ -57,7 +57,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize(
if ( !wait ) {
the_spinlock->users -= 1;
_CORE_spinlock_Release( the_spinlock, lock_context );
- return CORE_SPINLOCK_UNAVAILABLE;
+ return STATUS_UNAVAILABLE;
}
#if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
@@ -67,7 +67,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize(
if ( timeout && (limit <= _Watchdog_Ticks_since_boot) ) {
the_spinlock->users -= 1;
_CORE_spinlock_Release( the_spinlock, lock_context );
- return CORE_SPINLOCK_TIMEOUT;
+ return STATUS_TIMEOUT;
}
#endif
diff --git a/cpukit/score/src/futex.c b/cpukit/score/src/futex.c
index d7945d1..980c7fb 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 3442bbd..78d8e65 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 0b12232..28936d6 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 3d0d5f5..ea0835d 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 177a608..a991d03 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 a1a37e1..948275b 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -22,6 +22,7 @@
#include <rtems/score/assert.h>
#include <rtems/score/threaddispatch.h>
#include <rtems/score/threadimpl.h>
+#include <rtems/score/status.h>
#include <rtems/score/watchdogimpl.h>
#define THREAD_QUEUE_INTEND_TO_BLOCK \
@@ -39,7 +40,6 @@ void _Thread_queue_Enqueue_critical(
Thread_Control *the_thread,
States_Control state,
Watchdog_Interval timeout,
- uint32_t timeout_code,
ISR_lock_Context *lock_context
)
{
@@ -54,6 +54,7 @@ void _Thread_queue_Enqueue_critical(
_Thread_Lock_set( the_thread, &queue->Lock );
+ the_thread->Wait.return_code = STATUS_SUCCESSFUL;
_Thread_Wait_set_queue( the_thread, queue );
_Thread_Wait_set_operations( the_thread, operations );
@@ -72,7 +73,6 @@ void _Thread_queue_Enqueue_critical(
* If the thread wants to timeout, then schedule its timer.
*/
if ( timeout != WATCHDOG_NO_TIMEOUT ) {
- _Thread_Wait_set_timeout_code( the_thread, timeout_code );
_Thread_Timer_insert_relative(
the_thread,
cpu_self,
diff --git a/cpukit/score/src/threadqflush.c b/cpukit/score/src/threadqflush.c
index 8b23194..df2859d 100644
--- a/cpukit/score/src/threadqflush.c
+++ b/cpukit/score/src/threadqflush.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/score/threadimpl.h>
+#include <rtems/score/status.h>
Thread_Control *_Thread_queue_Flush_default_filter(
Thread_Control *the_thread,
@@ -31,6 +32,32 @@ Thread_Control *_Thread_queue_Flush_default_filter(
return the_thread;
}
+Thread_Control *_Thread_queue_Flush_status_object_was_deleted(
+ Thread_Control *the_thread,
+ Thread_queue_Queue *queue,
+ Thread_queue_Context *queue_context
+)
+{
+ the_thread->Wait.return_code = STATUS_OBJECT_WAS_DELETED;
+
+ (void) queue;
+ (void) queue_context;
+ return the_thread;
+}
+
+Thread_Control *_Thread_queue_Flush_status_unavailable(
+ Thread_Control *the_thread,
+ Thread_queue_Queue *queue,
+ Thread_queue_Context *queue_context
+)
+{
+ the_thread->Wait.return_code = STATUS_UNAVAILABLE;
+
+ (void) queue;
+ (void) queue_context;
+ return the_thread;
+}
+
size_t _Thread_queue_Flush_critical(
Thread_queue_Queue *queue,
const Thread_queue_Operations *operations,
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 52d68de..f9636e6 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 59f6bd9..9b5cfa6 100644
--- a/cpukit/score/src/threadtimeout.c
+++ b/cpukit/score/src/threadtimeout.c
@@ -20,10 +20,11 @@
#endif
#include <rtems/score/threadimpl.h>
+#include <rtems/score/status.h>
static void _Thread_Do_timeout( Thread_Control *the_thread )
{
- the_thread->Wait.return_code = the_thread->Wait.timeout_code;
+ the_thread->Wait.return_code = STATUS_TIMEOUT;
( *the_thread->Wait.operations->extract )(
the_thread->Wait.queue,
the_thread
diff --git a/testsuites/sptests/spintrcritical10/init.c b/testsuites/sptests/spintrcritical10/init.c
index 25be23a..f7e372a 100644
--- a/testsuites/sptests/spintrcritical10/init.c
+++ b/testsuites/sptests/spintrcritical10/init.c
@@ -60,7 +60,7 @@ static void any_satisfy_before_timeout(rtems_id timer, void *arg)
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
);
- rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
+ rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL);
sc = rtems_event_send(thread->Object.id, GREEN);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -68,7 +68,7 @@ static void any_satisfy_before_timeout(rtems_id timer, void *arg)
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == GREEN
);
- rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
+ rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL);
sc = rtems_event_send(thread->Object.id, RED);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -76,14 +76,14 @@ static void any_satisfy_before_timeout(rtems_id timer, void *arg)
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == GREEN
);
- rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
+ rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL);
_Thread_Timeout(&thread->Timer.Watchdog);
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == GREEN
);
- rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
+ rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL);
if (ctx->hit) {
rtems_test_assert(
@@ -157,7 +157,7 @@ static void all_satisfy_before_timeout(rtems_id timer, void *arg)
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
);
- rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
+ rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL);
sc = rtems_event_send(thread->Object.id, GREEN);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -165,7 +165,7 @@ static void all_satisfy_before_timeout(rtems_id timer, void *arg)
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
);
- rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
+ rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL);
sc = rtems_event_send(thread->Object.id, RED);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -173,14 +173,14 @@ static void all_satisfy_before_timeout(rtems_id timer, void *arg)
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == EVENTS
);
- rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
+ rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL);
_Thread_Timeout(&thread->Timer.Watchdog);
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == EVENTS
);
- rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
+ rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL);
if (ctx->hit) {
rtems_test_assert(
@@ -249,14 +249,14 @@ static void timeout_before_satisfied(rtems_id timer, void *arg)
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
);
- rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
+ rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL);
_Thread_Timeout(&thread->Timer.Watchdog);
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
);
- rtems_test_assert(thread->Wait.return_code == RTEMS_TIMEOUT);
+ rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_TIMEOUT);
sc = rtems_event_send(thread->Object.id, EVENTS);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -264,7 +264,7 @@ static void timeout_before_satisfied(rtems_id timer, void *arg)
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
);
- rtems_test_assert(thread->Wait.return_code == RTEMS_TIMEOUT);
+ rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_TIMEOUT);
if (ctx->hit) {
rtems_test_assert(
diff --git a/testsuites/sptests/spintrcritical20/init.c b/testsuites/sptests/spintrcritical20/init.c
index 9c9b5f0..1697df4 100644
--- a/testsuites/sptests/spintrcritical20/init.c
+++ b/testsuites/sptests/spintrcritical20/init.c
@@ -18,6 +18,7 @@
#include <tmacros.h>
#include <intrcritical.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/rtems/semimpl.h>
@@ -44,10 +45,6 @@ static void semaphore_task(rtems_task_argument arg)
test_context *ctx = (test_context *) arg;
ctx->semaphore_task_tcb = _Thread_Get_executing();
- _Thread_Wait_set_timeout_code(
- ctx->semaphore_task_tcb,
- CORE_SEMAPHORE_TIMEOUT
- );
while (true) {
rtems_status_code sc = rtems_semaphore_obtain(
@@ -76,8 +73,7 @@ static bool test_body(void *arg)
cpu_self = _Thread_Dispatch_disable();
rtems_test_assert(
- ctx->semaphore_task_tcb->Wait.return_code
- == CORE_SEMAPHORE_STATUS_SUCCESSFUL
+ _Thread_Wait_get_status( ctx->semaphore_task_tcb ) == STATUS_SUCCESSFUL
);
/*
@@ -94,11 +90,11 @@ static bool test_body(void *arg)
_Thread_Timeout(&ctx->semaphore_task_tcb->Timer.Watchdog);
- switch (ctx->semaphore_task_tcb->Wait.return_code) {
- case CORE_SEMAPHORE_STATUS_SUCCESSFUL:
+ switch (_Thread_Wait_get_status(ctx->semaphore_task_tcb)) {
+ case STATUS_SUCCESSFUL:
ctx->status_was_successful = true;
break;
- case CORE_SEMAPHORE_TIMEOUT:
+ case STATUS_TIMEOUT:
ctx->status_was_timeout = true;
break;
default:
--
1.8.4.5
More information about the devel
mailing list