Changeset 3ef54dc in rtems


Ignore:
Timestamp:
Jul 6, 2000, 7:33:52 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
1b7e8c51
Parents:
21e2b2b
Message:

Added support for converting a mutex id to a pointer and returning
with interrupts disabled.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/posix/inline/rtems/posix/mutex.inl

    r21e2b2b r3ef54dc  
    4242 *
    4343 *  _POSIX_Mutex_Get
     44 *
     45 *  NOTE: The support macro makes it possible for both to use exactly
     46 *        the same code to check for NULL id pointer and
     47 *        PTHREAD_MUTEX_INITIALIZER without adding overhead.
    4448 */
     49
     50#define ___POSIX_Mutex_Get_support( _id, _location ) \
     51  do { \
     52    int _status; \
     53    \
     54    if ( !_id ) { \
     55      *_location = OBJECTS_ERROR; \
     56      return (POSIX_Mutex_Control *) 0; \
     57    }  \
     58    \
     59    if ( *_id == PTHREAD_MUTEX_INITIALIZER ) { \
     60      /* \
     61       *  Do an "auto-create" here. \
     62       */ \
     63    \
     64      _status = pthread_mutex_init( _id, 0 ); \
     65      if ( _status ) { \
     66        *_location = OBJECTS_ERROR;  \
     67        return (POSIX_Mutex_Control *) 0; \
     68      } \
     69    } \
     70  } while (0)
    4571 
    4672RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get (
     
    4975)
    5076{
    51   int status;
    52 
    53   if ( !id ) {
    54     *location = OBJECTS_ERROR;
    55     return (POSIX_Mutex_Control *) 0;
    56   }
    57 
    58   if ( *id == PTHREAD_MUTEX_INITIALIZER ) {
    59     /*
    60      *  Do an "auto-create" here.
    61      */
    62 
    63     status = pthread_mutex_init( id, 0 );
    64     if ( status ) {
    65       *location = OBJECTS_ERROR;
    66       return (POSIX_Mutex_Control *) 0;
    67     }
    68   }
    69 
    70   /*
    71    *  Now call Objects_Get()
    72    */
     77  ___POSIX_Mutex_Get_support( id, location );
    7378
    7479  return (POSIX_Mutex_Control *)
    7580    _Objects_Get( &_POSIX_Mutex_Information, *id, location );
    7681}
     82
     83RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
     84  Objects_Id        *id,
     85  Objects_Locations *location,
     86  ISR_Level         *level
     87)
     88{
     89  ___POSIX_Mutex_Get_support( id, location );
     90
     91  return (POSIX_Mutex_Control *)
     92    _Objects_Get_isr_disable( &_POSIX_Mutex_Information, *id, location, level );
     93}
     94
    7795 
    7896/*PAGE
  • cpukit/posix/inline/rtems/posix/mutex.inl

    r21e2b2b r3ef54dc  
    4242 *
    4343 *  _POSIX_Mutex_Get
     44 *
     45 *  NOTE: The support macro makes it possible for both to use exactly
     46 *        the same code to check for NULL id pointer and
     47 *        PTHREAD_MUTEX_INITIALIZER without adding overhead.
    4448 */
     49
     50#define ___POSIX_Mutex_Get_support( _id, _location ) \
     51  do { \
     52    int _status; \
     53    \
     54    if ( !_id ) { \
     55      *_location = OBJECTS_ERROR; \
     56      return (POSIX_Mutex_Control *) 0; \
     57    }  \
     58    \
     59    if ( *_id == PTHREAD_MUTEX_INITIALIZER ) { \
     60      /* \
     61       *  Do an "auto-create" here. \
     62       */ \
     63    \
     64      _status = pthread_mutex_init( _id, 0 ); \
     65      if ( _status ) { \
     66        *_location = OBJECTS_ERROR;  \
     67        return (POSIX_Mutex_Control *) 0; \
     68      } \
     69    } \
     70  } while (0)
    4571 
    4672RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get (
     
    4975)
    5076{
    51   int status;
    52 
    53   if ( !id ) {
    54     *location = OBJECTS_ERROR;
    55     return (POSIX_Mutex_Control *) 0;
    56   }
    57 
    58   if ( *id == PTHREAD_MUTEX_INITIALIZER ) {
    59     /*
    60      *  Do an "auto-create" here.
    61      */
    62 
    63     status = pthread_mutex_init( id, 0 );
    64     if ( status ) {
    65       *location = OBJECTS_ERROR;
    66       return (POSIX_Mutex_Control *) 0;
    67     }
    68   }
    69 
    70   /*
    71    *  Now call Objects_Get()
    72    */
     77  ___POSIX_Mutex_Get_support( id, location );
    7378
    7479  return (POSIX_Mutex_Control *)
    7580    _Objects_Get( &_POSIX_Mutex_Information, *id, location );
    7681}
     82
     83RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
     84  Objects_Id        *id,
     85  Objects_Locations *location,
     86  ISR_Level         *level
     87)
     88{
     89  ___POSIX_Mutex_Get_support( id, location );
     90
     91  return (POSIX_Mutex_Control *)
     92    _Objects_Get_isr_disable( &_POSIX_Mutex_Information, *id, location, level );
     93}
     94
    7795 
    7896/*PAGE
Note: See TracChangeset for help on using the changeset viewer.