Changeset 02f041e in rtems


Ignore:
Timestamp:
08/19/96 15:27:37 (26 years ago)
Author:
Mark Johannes <Mark.Johannes@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
c5c5f8c
Parents:
cd3868cd
Message:

pthread_mutex_init: added error messages for NULL mutex and EBUSY

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/posix/src/mutex.c

    rcd3868cd r02f041e  
    216216)
    217217{
    218   POSIX_Mutex_Control        *the_mutex;
    219   CORE_mutex_Attributes      *the_mutex_attr;
    220   const pthread_mutexattr_t  *the_attr;
    221   CORE_mutex_Disciplines      the_discipline;
     218  POSIX_Mutex_Control          *the_mutex;
     219  CORE_mutex_Attributes        *the_mutex_attr;
     220  const pthread_mutexattr_t    *the_attr;
     221  CORE_mutex_Disciplines        the_discipline;
     222  register POSIX_Mutex_Control *mutex_in_use;
     223  Objects_Locations             location;
    222224
    223225  if ( attr ) the_attr = attr;
    224226  else        the_attr = &_POSIX_Mutex_Default_attributes;
    225227
    226   /* XXX need to check for NULL mutex */
    227   /* XXX EBUSY if *mutex is a valid id */
    228 
     228  /* Check for NULL mutex */
     229
     230  if ( !mutex )
     231    return EINVAL;
     232
     233  /* EBUSY if *mutex is a valid id */
     234
     235  mutex_in_use = _POSIX_Mutex_Get( mutex, &location );
     236  switch ( location ) {
     237    case OBJECTS_ERROR:
     238      break;
     239    case OBJECTS_REMOTE:
     240    case OBJECTS_LOCAL:
     241      _Thread_Enable_dispatch();
     242      return EBUSY;
     243  };
     244 
    229245  if ( !the_attr->is_initialized )
    230246    return EINVAL;
  • cpukit/posix/src/mutex.c

    rcd3868cd r02f041e  
    216216)
    217217{
    218   POSIX_Mutex_Control        *the_mutex;
    219   CORE_mutex_Attributes      *the_mutex_attr;
    220   const pthread_mutexattr_t  *the_attr;
    221   CORE_mutex_Disciplines      the_discipline;
     218  POSIX_Mutex_Control          *the_mutex;
     219  CORE_mutex_Attributes        *the_mutex_attr;
     220  const pthread_mutexattr_t    *the_attr;
     221  CORE_mutex_Disciplines        the_discipline;
     222  register POSIX_Mutex_Control *mutex_in_use;
     223  Objects_Locations             location;
    222224
    223225  if ( attr ) the_attr = attr;
    224226  else        the_attr = &_POSIX_Mutex_Default_attributes;
    225227
    226   /* XXX need to check for NULL mutex */
    227   /* XXX EBUSY if *mutex is a valid id */
    228 
     228  /* Check for NULL mutex */
     229
     230  if ( !mutex )
     231    return EINVAL;
     232
     233  /* EBUSY if *mutex is a valid id */
     234
     235  mutex_in_use = _POSIX_Mutex_Get( mutex, &location );
     236  switch ( location ) {
     237    case OBJECTS_ERROR:
     238      break;
     239    case OBJECTS_REMOTE:
     240    case OBJECTS_LOCAL:
     241      _Thread_Enable_dispatch();
     242      return EBUSY;
     243  };
     244 
    229245  if ( !the_attr->is_initialized )
    230246    return EINVAL;
Note: See TracChangeset for help on using the changeset viewer.