summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/mutex.c
diff options
context:
space:
mode:
authorMark Johannes <Mark.Johannes@OARcorp.com>1996-08-19 15:27:37 +0000
committerMark Johannes <Mark.Johannes@OARcorp.com>1996-08-19 15:27:37 +0000
commit02f041e40b0992288045c08897ef4ea21b7a763f (patch)
tree2465f00d0f26d40d2f4dcb8ff4fe789509840205 /cpukit/posix/src/mutex.c
parentupdates from Tony Bennett (tbennett@divnc.com) (diff)
downloadrtems-02f041e40b0992288045c08897ef4ea21b7a763f.tar.bz2
pthread_mutex_init: added error messages for NULL mutex and EBUSY
Diffstat (limited to 'cpukit/posix/src/mutex.c')
-rw-r--r--cpukit/posix/src/mutex.c28
1 files changed, 22 insertions, 6 deletions
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;