diff options
author | Chris Johns <chrisj@rtems.org> | 2013-08-23 14:56:36 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2013-08-23 14:56:36 +1000 |
commit | 6e4c01e3a2c07d3d42c510fbff70c14ccbafd2df (patch) | |
tree | ec6d62205983fabb345a6d84cd50804265fe3349 /cpukit/posix | |
parent | bsps/arm: Add more CP15 cache functions (diff) | |
download | rtems-6e4c01e3a2c07d3d42c510fbff70c14ccbafd2df.tar.bz2 |
posix: Update to the pthread_once changes.
Implement the reeview changes.
Add a POSIX Fatal error domain.
Fix confdefs.h to correctly handle the internal POSIX mutexes.
Diffstat (limited to 'cpukit/posix')
-rw-r--r-- | cpukit/posix/include/rtems/posix/posixapi.h | 20 | ||||
-rw-r--r-- | cpukit/posix/src/once.c | 25 | ||||
-rw-r--r-- | cpukit/posix/src/pthreadinitthreads.c | 19 | ||||
-rw-r--r-- | cpukit/posix/src/pthreadonce.c | 6 |
4 files changed, 44 insertions, 26 deletions
diff --git a/cpukit/posix/include/rtems/posix/posixapi.h b/cpukit/posix/include/rtems/posix/posixapi.h index bf1c1b7eb8..a7782a53de 100644 --- a/cpukit/posix/include/rtems/posix/posixapi.h +++ b/cpukit/posix/include/rtems/posix/posixapi.h @@ -1,6 +1,6 @@ /** * @file - * + * * @brief POSIX API Implementation * * This include file defines the top level interface to the POSIX API @@ -31,6 +31,24 @@ /**@{**/ /** + * @brief POSIX API Fatal domains. + */ +typedef enum { + POSIX_FD_PTHREAD, /**< A pthread thread error. */ + POSIX_FD_PTHREAD_ONCE /**< A pthread once error. */ +} POSIX_Fatal_domain; + +/** + * @brief POSIX API Fatal error. + * + * A common method of rasing a POSIX API fatal error. + * + * @param[in] domain The POSIX error domain. + * @param[in] eno The error number as defined in errno.h. + */ +void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno ); + +/** * @brief Initialize POSIX API. * * This method is responsible for initializing each of the POSIX diff --git a/cpukit/posix/src/once.c b/cpukit/posix/src/once.c index d77c3c12e3..e91daf2ca6 100644 --- a/cpukit/posix/src/once.c +++ b/cpukit/posix/src/once.c @@ -22,28 +22,25 @@ #include <errno.h> #include <rtems.h> +#include <rtems/posix/posixapi.h> #include <rtems/posix/onceimpl.h> -pthread_mutex_t _POSIX_Once_Lock; - void _POSIX_Once_Manager_initialization(void) { pthread_mutexattr_t mattr; - int r; + int eno; _POSIX_Once_Lock = PTHREAD_MUTEX_INITIALIZER; - r = pthread_mutexattr_init( &mattr ); - if ( r != 0 ) - rtems_fatal( RTEMS_FATAL_SOURCE_ASSERT, 0x80aa0000 | r ); - - r = pthread_mutexattr_settype( &mattr, PTHREAD_MUTEX_RECURSIVE ); - if ( r != 0 ) - rtems_fatal( RTEMS_FATAL_SOURCE_ASSERT, 0x80aa1000 | r ); + eno = pthread_mutexattr_init( &mattr ); + _Assert( eno == 0 ); + eno = pthread_mutexattr_settype( &mattr, PTHREAD_MUTEX_RECURSIVE ); + _Assert( eno == 0 ); - r = pthread_mutex_init( &_POSIX_Once_Lock, &mattr ); - if ( r != 0 ) - rtems_fatal( RTEMS_FATAL_SOURCE_ASSERT, 0x80aa2000 | r ); + eno = pthread_mutex_init( &_POSIX_Once_Lock, &mattr ); + if ( eno != 0 ) + _POSIX_Fatal_error( POSIX_FD_PTHREAD_ONCE, eno ); - pthread_mutexattr_destroy( &mattr ); + eno = pthread_mutexattr_destroy( &mattr ); + _Assert( eno == 0 ); } diff --git a/cpukit/posix/src/pthreadinitthreads.c b/cpukit/posix/src/pthreadinitthreads.c index 961105c669..1ec28ba6c3 100644 --- a/cpukit/posix/src/pthreadinitthreads.c +++ b/cpukit/posix/src/pthreadinitthreads.c @@ -29,6 +29,7 @@ #include <rtems/score/thread.h> #include <rtems/score/wkspace.h> #include <rtems/posix/cancel.h> +#include <rtems/posix/posixapi.h> #include <rtems/posix/pthreadimpl.h> #include <rtems/posix/priorityimpl.h> #include <rtems/posix/config.h> @@ -36,7 +37,7 @@ void _POSIX_Threads_Initialize_user_threads_body(void) { - int status; + int eno; uint32_t index; uint32_t maximum; posix_initialization_threads_table *user_threads; @@ -60,18 +61,20 @@ void _POSIX_Threads_Initialize_user_threads_body(void) /* * There is no way for these calls to fail in this situation. */ - (void) pthread_attr_init( &attr ); - (void) pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); - (void) pthread_attr_setstacksize(&attr, user_threads[ index ].stack_size); + eno = pthread_attr_init( &attr ); + _Assert( eno == 0 ); + eno = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + _Assert( eno == 0 ); + eno = pthread_attr_setstacksize(&attr, user_threads[ index ].stack_size); + _Assert( eno == 0 ); - status = pthread_create( + eno = pthread_create( &thread_id, &attr, user_threads[ index ].thread_entry, NULL ); - if ( status ) - _Internal_error_Occurred( INTERNAL_ERROR_POSIX_API, true, status ); + if ( eno ) + _POSIX_Fatal_error( POSIX_FD_PTHREAD, eno ); } } - diff --git a/cpukit/posix/src/pthreadonce.c b/cpukit/posix/src/pthreadonce.c index 2b02f1e53c..aa8afe7bf4 100644 --- a/cpukit/posix/src/pthreadonce.c +++ b/cpukit/posix/src/pthreadonce.c @@ -29,7 +29,7 @@ #define PTHREAD_ONCE_INIT_NOT_RUN 0 #define PTHREAD_ONCE_INIT_RUNNING 1 -#define PTHREAD_ONCE_INIT_RUN 2 +#define PTHREAD_ONCE_INIT_COMPLETE 2 int pthread_once( pthread_once_t *once_control, @@ -44,7 +44,7 @@ int pthread_once( if ( once_control->is_initialized != 1 ) return EINVAL; - if ( once_control->init_executed != PTHREAD_ONCE_INIT_RUN ) { + if ( once_control->init_executed != PTHREAD_ONCE_INIT_COMPLETE ) { r = pthread_mutex_lock( &_POSIX_Once_Lock ); if ( r == 0 ) { int rr; @@ -61,7 +61,7 @@ int pthread_once( case PTHREAD_ONCE_INIT_NOT_RUN: once_control->init_executed = PTHREAD_ONCE_INIT_RUNNING; (*init_routine)(); - once_control->init_executed = PTHREAD_ONCE_INIT_RUN; + once_control->init_executed = PTHREAD_ONCE_INIT_COMPLETE; break; case PTHREAD_ONCE_INIT_RUNNING: r = EINVAL; |