From dce487912d98835b8168e755b60514f5a8592b27 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 23 May 2016 13:37:59 +0200 Subject: score: Add Status_Control for all APIs Unify the status codes of the Classic and POSIX API to use the new enum Status_Control. This eliminates the Thread_Control::Wait::timeout_code field and the timeout parameter of _Thread_queue_Enqueue_critical() and _MPCI_Send_request_packet(). It gets rid of the status code translation tables and instead uses simple bit operations to get the status for a particular API. This enables translation of status code constants at compile time. Add _Thread_Wait_get_status() to avoid direct access of thread internal data structures. --- cpukit/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 -------- 7 files changed, 25 insertions(+), 128 deletions(-) (limited to 'cpukit/posix/include') diff --git a/cpukit/posix/include/rtems/posix/barrierimpl.h b/cpukit/posix/include/rtems/posix/barrierimpl.h index e04f1354ae..984868e7e1 100644 --- a/cpukit/posix/include/rtems/posix/barrierimpl.h +++ b/cpukit/posix/include/rtems/posix/barrierimpl.h @@ -37,20 +37,6 @@ extern "C" { extern Objects_Information _POSIX_Barrier_Information; -/** - * @brief POSIX translate barrier return code. - * - * This routine translates SuperCore Barrier status codes into the - * corresponding POSIX ones. - * - * @param[in] the_barrier_status is the SuperCore status. - * - * @return the corresponding POSIX status - */ -int _POSIX_Barrier_Translate_core_barrier_return_code( - CORE_barrier_Status the_barrier_status -); - /** * @brief Allocate a barrier control block. * diff --git a/cpukit/posix/include/rtems/posix/mqueueimpl.h b/cpukit/posix/include/rtems/posix/mqueueimpl.h index 2317358f64..480584b823 100644 --- a/cpukit/posix/include/rtems/posix/mqueueimpl.h +++ b/cpukit/posix/include/rtems/posix/mqueueimpl.h @@ -148,14 +148,6 @@ RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core( return (unsigned int) ((priority >= 0) ? priority : -priority); } -/** - * @brief POSIX Message Queue Translate Score Return Code - * - */ -int _POSIX_Message_queue_Translate_core_message_queue_return_code( - uint32_t the_message_queue_status -); - /** * @brief POSIX Message Queue Remove from Namespace */ diff --git a/cpukit/posix/include/rtems/posix/muteximpl.h b/cpukit/posix/include/rtems/posix/muteximpl.h index 4c7852b2c5..30cc19da7e 100644 --- a/cpukit/posix/include/rtems/posix/muteximpl.h +++ b/cpukit/posix/include/rtems/posix/muteximpl.h @@ -39,12 +39,6 @@ extern Objects_Information _POSIX_Mutex_Information; */ extern pthread_mutexattr_t _POSIX_Mutex_Default_attributes; -/** - * This array contains a mapping from Score Mutex return codes to - * POSIX return codes. - */ -extern const int _POSIX_Mutex_Return_codes[CORE_MUTEX_STATUS_LAST + 1]; - /** * @brief POSIX Mutex Allocate * @@ -82,42 +76,6 @@ int _POSIX_Mutex_Lock_support( Watchdog_Interval timeout ); -/** - * @brief Convert Score mutex status codes into POSIX status values - * - * A support routine which converts core mutex status codes into the - * appropriate POSIX status values. - * - * @param[in] the_mutex_status is the mutex status code to translate - * - * @retval 0 Mutex status code indicates the operation completed successfully. - * @retval EBUSY Mutex status code indicates that the operation unable to - * complete immediately because the resource was unavailable. - * @retval EDEADLK Mutex status code indicates that an attempt was made to - * relock a mutex for which nesting is not configured. - * @retval EPERM Mutex status code indicates that an attempt was made to - * release a mutex by a thread other than the thread which locked it. - * @retval EINVAL Mutex status code indicates that the thread was blocked - * waiting for an operation to complete and the mutex was deleted. - * @retval ETIMEDOUT Mutex status code indicates that the calling task was - * willing to block but the operation was unable to complete - * within the time allotted because the resource never became - * available. - */ -RTEMS_INLINE_ROUTINE int _POSIX_Mutex_Translate_core_mutex_return_code( - CORE_mutex_Status the_mutex_status -) -{ - /* - * Internal consistency check for bad status from SuperCore - */ - #if defined(RTEMS_DEBUG) - if ( the_mutex_status > CORE_MUTEX_STATUS_LAST ) - return EINVAL; - #endif - return _POSIX_Mutex_Return_codes[the_mutex_status]; -} - /** * @brief POSIX Mutex Get (Interrupt Disable) * diff --git a/cpukit/posix/include/rtems/posix/posixapi.h b/cpukit/posix/include/rtems/posix/posixapi.h index a5afe92872..fabde4d6f9 100644 --- a/cpukit/posix/include/rtems/posix/posixapi.h +++ b/cpukit/posix/include/rtems/posix/posixapi.h @@ -23,6 +23,8 @@ #include #include #include +#include +#include /** * @defgroup POSIXAPI RTEMS POSIX API @@ -60,6 +62,29 @@ RTEMS_INLINE_ROUTINE int _POSIX_Get_by_name_error( return _POSIX_Get_by_name_error_table[ error ]; } +RTEMS_INLINE_ROUTINE int _POSIX_Get_error( Status_Control status ) +{ + return STATUS_GET_POSIX( status ); +} + +RTEMS_INLINE_ROUTINE int _POSIX_Get_error_after_wait( + const Thread_Control *executing +) +{ + return _POSIX_Get_error( _Thread_Wait_get_status( executing ) ); +} + +RTEMS_INLINE_ROUTINE int _POSIX_Zero_or_minus_one_plus_errno( + Status_Control status +) +{ + if ( status == STATUS_SUCCESSFUL ) { + return 0; + } + + rtems_set_errno_and_return_minus_one( _POSIX_Get_error( status ) ); +} + /** * @brief Macro to generate a function body to get a POSIX object by * identifier. diff --git a/cpukit/posix/include/rtems/posix/rwlockimpl.h b/cpukit/posix/include/rtems/posix/rwlockimpl.h index 4ab9395489..c355f7dc19 100644 --- a/cpukit/posix/include/rtems/posix/rwlockimpl.h +++ b/cpukit/posix/include/rtems/posix/rwlockimpl.h @@ -37,29 +37,6 @@ extern "C" { extern Objects_Information _POSIX_RWLock_Information; -/** - * @brief POSIX translate core RWLock return code. - * - * This routine translates SuperCore RWLock status codes into the - * corresponding POSIX ones. - * - * - * @param[in] the_RWLock_status is the SuperCore status. - * - * @return the corresponding POSIX status - * @retval 0 The status indicates that the operation completed successfully. - * @retval EINVAL The status indicates that the thread was blocked waiting for - * an operation to complete and the RWLock was deleted. - * @retval EBUSY This status indicates that the RWLock was not - * immediately available. - * @retval ETIMEDOUT This status indicates that the calling task was - * willing to block but the operation was unable to complete within - * the time allotted because the resource never became available. - */ -int _POSIX_RWLock_Translate_core_RWLock_return_code( - CORE_RWLock_Status the_RWLock_status -); - /** * @brief Allocate a RWLock control block. * diff --git a/cpukit/posix/include/rtems/posix/semaphoreimpl.h b/cpukit/posix/include/rtems/posix/semaphoreimpl.h index 10d7cee28b..90019d7ed0 100644 --- a/cpukit/posix/include/rtems/posix/semaphoreimpl.h +++ b/cpukit/posix/include/rtems/posix/semaphoreimpl.h @@ -34,12 +34,6 @@ extern "C" { */ extern Objects_Information _POSIX_Semaphore_Information; -/** - * This defines the mapping from Score status codes to POSIX return codes. - */ -extern const int - _POSIX_Semaphore_Return_codes[CORE_SEMAPHORE_STATUS_LAST + 1]; - RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control * _POSIX_Semaphore_Allocate_unprotected( void ) { @@ -108,27 +102,6 @@ int _POSIX_Semaphore_Wait_support( bool blocking, Watchdog_Interval timeout ); - -/** - * @brief POSIX Semaphore Translate Score to POSIX Return Codes - * - * A support routine which converts core semaphore status codes into the - * appropriate POSIX status values. - */ -RTEMS_INLINE_ROUTINE int -_POSIX_Semaphore_Translate_core_semaphore_return_code( - CORE_semaphore_Status the_semaphore_status -) -{ - /* - * Internal consistency check for bad status from SuperCore - */ - #if defined(RTEMS_DEBUG) - if ( the_semaphore_status > CORE_SEMAPHORE_STATUS_LAST ) - return EINVAL; - #endif - return _POSIX_Semaphore_Return_codes[the_semaphore_status]; -} /** * @brief POSIX Semaphore Namespace Remove diff --git a/cpukit/posix/include/rtems/posix/spinlockimpl.h b/cpukit/posix/include/rtems/posix/spinlockimpl.h index e0217a0889..f1b5639bd1 100644 --- a/cpukit/posix/include/rtems/posix/spinlockimpl.h +++ b/cpukit/posix/include/rtems/posix/spinlockimpl.h @@ -36,20 +36,6 @@ extern "C" { extern Objects_Information _POSIX_Spinlock_Information; -/** - * @brief Translate core spinlock status code. - * - * This routine translates SuperCore Spinlock status codes into the - * corresponding POSIX ones. - * - * @param[in] the_spinlock_status is the SuperCore status. - * - * @return the corresponding POSIX status - */ -int _POSIX_Spinlock_Translate_core_spinlock_return_code( - CORE_spinlock_Status the_spinlock_status -); - /** * @brief Allocate a spinlock control block. * -- cgit v1.2.3