From 02f041e40b0992288045c08897ef4ea21b7a763f Mon Sep 17 00:00:00 2001 From: Mark Johannes Date: Mon, 19 Aug 1996 15:27:37 +0000 Subject: pthread_mutex_init: added error messages for NULL mutex and EBUSY --- cpukit/posix/src/mutex.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'cpukit/posix/src/mutex.c') diff --git a/cpukit/posix/src/mutex.c b/cpukit/posix/src/mutex.c index 9306d24d0b..eaa946fcfd 100644 --- a/cpukit/posix/src/mutex.c +++ b/cpukit/posix/src/mutex.c @@ -215,17 +215,33 @@ int pthread_mutex_init( const pthread_mutexattr_t *attr ) { - POSIX_Mutex_Control *the_mutex; - CORE_mutex_Attributes *the_mutex_attr; - const pthread_mutexattr_t *the_attr; - CORE_mutex_Disciplines the_discipline; + POSIX_Mutex_Control *the_mutex; + CORE_mutex_Attributes *the_mutex_attr; + const pthread_mutexattr_t *the_attr; + CORE_mutex_Disciplines the_discipline; + register POSIX_Mutex_Control *mutex_in_use; + Objects_Locations location; if ( attr ) the_attr = attr; else the_attr = &_POSIX_Mutex_Default_attributes; - /* XXX need to check for NULL mutex */ - /* XXX EBUSY if *mutex is a valid id */ + /* Check for NULL mutex */ + + if ( !mutex ) + return EINVAL; + + /* EBUSY if *mutex is a valid id */ + mutex_in_use = _POSIX_Mutex_Get( mutex, &location ); + switch ( location ) { + case OBJECTS_ERROR: + break; + case OBJECTS_REMOTE: + case OBJECTS_LOCAL: + _Thread_Enable_dispatch(); + return EBUSY; + }; + if ( !the_attr->is_initialized ) return EINVAL; -- cgit v1.2.3