diff options
Diffstat (limited to 'cpukit/posix')
36 files changed, 156 insertions, 607 deletions
diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am index a7632a04cc..9f73501cb0 100644 --- a/cpukit/posix/Makefile.am +++ b/cpukit/posix/Makefile.am @@ -74,7 +74,7 @@ libposix_a_SOURCES += src/pthreadatfork.c libposix_a_SOURCES += src/barrierattrdestroy.c src/barrierattrgetpshared.c \ src/barrierattrinit.c src/barrierattrsetpshared.c src/pbarrier.c \ src/pbarrierdestroy.c src/pbarrierinit.c \ - src/pbarriertranslatereturncode.c src/pbarrierwait.c + src/pbarrierwait.c ## CANCEL_C_FILES libposix_a_SOURCES += src/cancel.c \ @@ -99,7 +99,7 @@ libposix_a_SOURCES += src/mqueue.c src/mqueueclose.c \ src/mqueuenotify.c src/mqueueopen.c \ src/mqueuereceive.c src/mqueuerecvsupp.c src/mqueuesend.c \ src/mqueuesendsupp.c src/mqueuesetattr.c src/mqueuetimedreceive.c \ - src/mqueuetimedsend.c src/mqueuetranslatereturncode.c \ + src/mqueuetimedsend.c \ src/mqueueunlink.c ## MUTEX_C_FILES @@ -110,7 +110,7 @@ libposix_a_SOURCES += src/mutexattrdestroy.c src/mutexattrgetprioceiling.c \ src/mutexattrsettype.c src/mutex.c src/mutexdestroy.c src/mutexget.c \ src/mutexgetprioceiling.c src/mutexinit.c src/mutexlock.c \ src/mutexlocksupp.c src/mutexsetprioceiling.c src/mutextimedlock.c \ - src/mutextranslatereturncode.c src/mutextrylock.c src/mutexunlock.c + src/mutextrylock.c src/mutexunlock.c ## PTHREAD_C_FILES libposix_a_SOURCES += src/pthreadatfork.c src/pthreadattrdestroy.c \ @@ -175,20 +175,19 @@ libposix_a_SOURCES += src/prwlock.c src/prwlockdestroy.c src/prwlockinit.c \ src/prwlockrdlock.c src/prwlocktimedrdlock.c src/prwlocktimedwrlock.c \ src/prwlocktryrdlock.c src/prwlocktrywrlock.c src/prwlockunlock.c \ src/prwlockwrlock.c src/rwlockattrdestroy.c src/rwlockattrgetpshared.c \ - src/rwlockattrinit.c src/rwlockattrsetpshared.c \ - src/prwlocktranslatereturncode.c + src/rwlockattrinit.c src/rwlockattrsetpshared.c ## SEMAPHORE_C_FILES libposix_a_SOURCES += src/semaphore.c src/semaphorecreatesupp.c \ src/semaphoredeletesupp.c \ - src/semaphoretranslatereturncode.c src/semaphorewaitsupp.c \ + src/semaphorewaitsupp.c \ src/semclose.c src/semdestroy.c src/semgetvalue.c src/seminit.c \ src/semopen.c src/sempost.c src/semtimedwait.c src/semtrywait.c \ src/semunlink.c src/semwait.c ## SPINLOCK_C_FILES libposix_a_SOURCES += src/pspin.c src/pspindestroy.c src/pspininit.c \ - src/pspinlock.c src/pspinlocktranslatereturncode.c src/pspintrylock.c \ + src/pspinlock.c src/pspintrylock.c \ src/pspinunlock.c ## TIME_C_FILES diff --git a/cpukit/posix/include/rtems/posix/barrierimpl.h b/cpukit/posix/include/rtems/posix/barrierimpl.h index e04f1354ae..984868e7e1 100644 --- a/cpukit/posix/include/rtems/posix/barrierimpl.h +++ b/cpukit/posix/include/rtems/posix/barrierimpl.h @@ -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 2317358f64..480584b823 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 4c7852b2c5..30cc19da7e 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 a5afe92872..fabde4d6f9 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 4ab9395489..c355f7dc19 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 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 @@ -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 4e89ef0b50..9270c36393 100644 --- a/cpukit/posix/src/condwaitsupp.c +++ b/cpukit/posix/src/condwaitsupp.c @@ -20,8 +20,10 @@ #include <rtems/posix/condimpl.h> #include <rtems/posix/muteximpl.h> +#include <rtems/posix/posixapi.h> #include <rtems/score/assert.h> #include <rtems/score/statesimpl.h> +#include <rtems/score/status.h> #include <rtems/score/threaddispatch.h> THREAD_QUEUE_OBJECT_ASSERT( POSIX_Condition_variables_Control, Wait_queue ); @@ -36,9 +38,9 @@ int _POSIX_Condition_variables_Wait_support( POSIX_Condition_variables_Control *the_cond; POSIX_Mutex_Control *the_mutex; Thread_queue_Context queue_context; - int status; - int mutex_status; - CORE_mutex_Status core_mutex_status; + int error; + int mutex_error; + Status_Control status; Per_CPU_Control *cpu_self; Thread_Control *executing; @@ -84,28 +86,23 @@ int _POSIX_Condition_variables_Wait_support( } if ( !already_timedout ) { - executing->Wait.return_code = 0; _Thread_queue_Enqueue_critical( &the_cond->Wait_queue.Queue, POSIX_CONDITION_VARIABLES_TQ_OPERATIONS, executing, STATES_WAITING_FOR_CONDITION_VARIABLE, timeout, - ETIMEDOUT, &queue_context.Lock_context ); } else { _POSIX_Condition_variables_Release( the_cond, &queue_context ); - executing->Wait.return_code = ETIMEDOUT; + executing->Wait.return_code = STATUS_TIMEOUT; } _ISR_lock_ISR_disable( &queue_context.Lock_context ); - core_mutex_status = _CORE_mutex_Surrender( - &the_mutex->Mutex, - &queue_context - ); - _Assert( core_mutex_status == CORE_MUTEX_STATUS_SUCCESSFUL ); - (void) core_mutex_status; + status = _CORE_mutex_Surrender( &the_mutex->Mutex, &queue_context ); + _Assert( status == STATUS_SUCCESSFUL ); + (void) status; /* * Switch ourself out because we blocked as a result of the @@ -114,7 +111,7 @@ int _POSIX_Condition_variables_Wait_support( _Thread_Dispatch_enable( cpu_self ); - status = (int) executing->Wait.return_code; + error = _POSIX_Get_error_after_wait( executing ); /* * If the thread is interrupted, while in the thread queue, by @@ -124,18 +121,18 @@ int _POSIX_Condition_variables_Wait_support( * woken up a pthread_cond_signal() or a pthread_cond_broadcast(). */ - if ( status == EINTR ) { - status = 0; + if ( error == EINTR ) { + error = 0; } /* * When we get here the dispatch disable level is 0. */ - mutex_status = pthread_mutex_lock( mutex ); - if ( mutex_status != 0 ) { + mutex_error = pthread_mutex_lock( mutex ); + if ( mutex_error != 0 ) { return EINVAL; } - return status; + return error; } diff --git a/cpukit/posix/src/mqueuerecvsupp.c b/cpukit/posix/src/mqueuerecvsupp.c index 541786a850..cbb0dc08b8 100644 --- a/cpukit/posix/src/mqueuerecvsupp.c +++ b/cpukit/posix/src/mqueuerecvsupp.c @@ -19,6 +19,7 @@ #endif #include <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 2d88eec7a8..9785fb2086 100644 --- a/cpukit/posix/src/mqueuesendsupp.c +++ b/cpukit/posix/src/mqueuesendsupp.c @@ -45,7 +45,7 @@ int _POSIX_Message_queue_Send_support( { POSIX_Message_queue_Control *the_mq; Thread_queue_Context queue_context; - CORE_message_queue_Status msg_status; + Status_Control status; bool do_wait; Thread_Control *executing; @@ -92,7 +92,7 @@ int _POSIX_Message_queue_Send_support( * Now perform the actual message receive */ executing = _Thread_Executing; - msg_status = _CORE_message_queue_Submit( + status = _CORE_message_queue_Submit( &the_mq->Message_queue, executing, msg_ptr, @@ -102,14 +102,5 @@ int _POSIX_Message_queue_Send_support( timeout, &queue_context ); - - if ( msg_status != CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL ) { - rtems_set_errno_and_return_minus_one( - _POSIX_Message_queue_Translate_core_message_queue_return_code( - msg_status - ) - ); - } - - return 0; + return _POSIX_Zero_or_minus_one_plus_errno( status ); } diff --git a/cpukit/posix/src/mqueuetranslatereturncode.c b/cpukit/posix/src/mqueuetranslatereturncode.c deleted file mode 100644 index 901d5aaa3a..0000000000 --- a/cpukit/posix/src/mqueuetranslatereturncode.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file - * - * @brief POSIX Error Translation in Message Queue - * @ingroup POSIXAPI - */ - -/* - * POSIX Message Queue Error Translation - * - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <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 f17269bf21..6ecf87cb46 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 1cc0b5c98c..0000000000 --- a/cpukit/posix/src/mutextranslatereturncode.c +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @file - * - * @brief POSIX Mutex Translate Core Mutex Return Code - * @ingroup POSIX_MUTEX - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <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 ff7fc1c789..1c3f2d83f4 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 b24b74d00b..21b0d15a2a 100644 --- a/cpukit/posix/src/nanosleep.c +++ b/cpukit/posix/src/nanosleep.c @@ -92,8 +92,7 @@ int nanosleep( &_Thread_queue_Operations_FIFO, executing, STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL, - ticks, - 0 + ticks ); /* diff --git a/cpukit/posix/src/pbarriertranslatereturncode.c b/cpukit/posix/src/pbarriertranslatereturncode.c deleted file mode 100644 index e3dd7bf06d..0000000000 --- a/cpukit/posix/src/pbarriertranslatereturncode.c +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @file - * - * @brief Function Translates POSIX Barrier Status Code - * @ingroup POSIXAPI - */ - -/* - * Barrier Manager -- Translate SuperCore Status - * - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <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 522c18ec84..0197e46702 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 e59aaf9adb..295148e4bf 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 9e849438dd..1c1059051b 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 6be8397ef7..8080a8a920 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 dceb5f7ee4..0000000000 --- a/cpukit/posix/src/prwlocktranslatereturncode.c +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @file - * - * @brief POSIX RWLock Translate Core RWLock Return Code - * @ingroup POSIX_RWLOCK - */ - -/* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <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 1a7cf9efe1..5c6931ec0d 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 b6031f9b42..1181382fca 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 dd4337d7d0..05be366c23 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 84a4e0f04b..4592aaa04e 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 5635afaa4e..b4475b268d 100644 --- a/cpukit/posix/src/psignalunblockthread.c +++ b/cpukit/posix/src/psignalunblockthread.c @@ -98,7 +98,7 @@ static void _POSIX_signals_Action_handler( { POSIX_API_Control *api; int signo; - int hold_errno; + uint32_t hold_errno; (void) action; _Thread_State_release( executing, lock_context ); @@ -198,7 +198,7 @@ bool _POSIX_signals_Unblock_thread( if ( _States_Is_interruptible_signal( the_thread->current_state ) ) { if ( (the_thread->Wait.option & mask) || (api->signals_unblocked & mask) ) { - the_thread->Wait.return_code = EINTR; + the_thread->Wait.return_code = STATUS_INTERRUPTED; the_info = (siginfo_t *) the_thread->Wait.return_argument; @@ -240,7 +240,7 @@ bool _POSIX_signals_Unblock_thread( */ if ( _States_Is_interruptible_by_signal( the_thread->current_state ) ) { - the_thread->Wait.return_code = EINTR; + the_thread->Wait.return_code = STATUS_INTERRUPTED; _Thread_queue_Extract_with_proxy( the_thread ); } } diff --git a/cpukit/posix/src/pspinlock.c b/cpukit/posix/src/pspinlock.c index 502177c50e..a2db911698 100644 --- a/cpukit/posix/src/pspinlock.c +++ b/cpukit/posix/src/pspinlock.c @@ -19,14 +19,13 @@ #endif #include <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 6d3e9b05d8..0000000000 --- a/cpukit/posix/src/pspinlocktranslatereturncode.c +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file - * - * @brief POSIX Spinlock Translate Core Spinlock Return Code - * @ingroup POSIX_SPINLOCK - */ - -/* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <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 5f132a3193..a8264aba97 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 35dbcb977f..b92473d7c1 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 db83a1f3bf..f4a0676d6b 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 04b293d349..0000000000 --- a/cpukit/posix/src/semaphoretranslatereturncode.c +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @file - * - * @brief POSIX Semaphore Code Translation Error - * @ingroup POSIXAPI - */ - -/* - * POSIX Semaphore Error Translation - * - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <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 9382107d90..d8e0d69654 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 f4633dcf70..322663b5ad 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 77dbe533ca..ddc2884d68 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; |