Changeset 2837a5e in rtems


Ignore:
Timestamp:
Dec 6, 2002, 1:48:27 PM (18 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
83333e9
Parents:
baa8dd7c
Message:

2002-12-06 Vladimir Nesic <vnesic@…>

  • inline/rtems/posix/cond.inl, macros/rtems/posix/cond.inl: Implemented PTHREAD_COND_INITIALIZER support. Vladimir implemented the inline version and Joel adapted it to the macro version.
Location:
cpukit/posix
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/ChangeLog

    rbaa8dd7c r2837a5e  
     12002-12-06      Vladimir Nesic <vnesic@dkts.co.yu>
     2
     3        * inline/rtems/posix/cond.inl, macros/rtems/posix/cond.inl:
     4        Implemented PTHREAD_COND_INITIALIZER support.  Vladimir implemented
     5        the inline version and Joel adapted it to the macro version.
     6
    172002-12-02      Joel Sherrill <joel@OARcorp.com>
    28
  • cpukit/posix/inline/rtems/posix/cond.inl

    rbaa8dd7c r2837a5e  
    44 *  inlined routines for POSIX condition variables.
    55 *
    6  *  COPYRIGHT (c) 1989-1999.
     6 *  COPYRIGHT (c) 1989-2002.
    77 *  On-Line Applications Research Corporation (OAR).
    88 *
     
    1717#define __RTEMS_POSIX_CONDITION_VARIABLES_inl
    1818 
     19#include <pthread.h>
     20
    1921/*PAGE
    2022 *
     
    4850 *  _POSIX_Condition_variables_Get
    4951 */
    50  
    51 RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get (
     52
     53RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control
     54*_POSIX_Condition_variables_Get (
    5255  Objects_Id        *id,
    5356  Objects_Locations *location
    5457)
    5558{
    56 /* XXX should support COND_INITIALIZER */
    57   if ( id )
    58     return (POSIX_Condition_variables_Control *)
    59       _Objects_Get( &_POSIX_Condition_variables_Information, *id, location );
     59  int status;
    6060
    61   *location = OBJECTS_ERROR;
    62   return NULL;
     61  if ( !id ) {
     62    *location = OBJECTS_ERROR;
     63    return (POSIX_Condition_variables_Control *) 0;
     64  }
     65
     66  if ( *id == PTHREAD_COND_INITIALIZER ) {
     67    /*
     68     *  Do an "auto-create" here.
     69     */
     70
     71    status = pthread_cond_init( id, 0 );
     72    if ( status ) {
     73      *location = OBJECTS_ERROR;
     74      return (POSIX_Condition_variables_Control *) 0;
     75    }
     76  }
     77
     78  /*
     79   *  Now call Objects_Get()
     80   */
     81
     82  return (POSIX_Condition_variables_Control *)
     83    _Objects_Get( &_POSIX_Condition_variables_Information, *id, location );
    6384}
    6485 
  • cpukit/posix/macros/rtems/posix/cond.inl

    rbaa8dd7c r2837a5e  
    44 *  inlined routines for POSIX condition variables.
    55 *
    6  *  COPYRIGHT (c) 1989-1999.
     6 *  COPYRIGHT (c) 1989-2002.
    77 *  On-Line Applications Research Corporation (OAR).
    88 *
     
    1717#define __RTEMS_POSIX_CONDITION_VARIABLES_inl
    1818 
     19#include <pthread.h>
     20
    1921/*PAGE
    2022 *
     
    2931 *
    3032 *  _POSIX_Condition_variables_Free
     33 *
     34 *  NOTE: The support macro makes it possible for both to use exactly
     35 *        the same code to check for NULL id pointer and
     36 *        PTHREAD_COND_INITIALIZER without adding overhead.
    3137 */
    3238 
     
    3844 *
    3945 *  _POSIX_Condition_variables_Get
     46 *
     47 *  NOTE: The support macro makes it possible for both to use exactly
     48 *        the same code to check for NULL id pointer and
     49 *        PTHREAD_COND_INITIALIZER without adding overhead.
    4050 */
     51
     52#define ___POSIX_Condition_variables_Get_support( _id, _location ) \
     53  do { \
     54    int _status; \
     55    \
     56    if ( !_id ) { \
     57      *_location = OBJECTS_ERROR; \
     58      return (POSIX_Condition_variables_Control *) 0; \
     59    }  \
     60    \
     61    if ( *_id == PTHREAD_COND_INITIALIZER ) { \
     62      /* \
     63       *  Do an "auto-create" here. \
     64       */ \
     65    \
     66      _status = pthread_cond_init( _id, 0 ); \
     67      if ( _status ) { \
     68        *_location = OBJECTS_ERROR;  \
     69        return (POSIX_Condition_variables_Control *) 0; \
     70      } \
     71    } \
     72  } while (0)
    4173 
    42 /* XXX how to write this as a macro */
     74 
    4375static POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get (
    4476  Objects_Id        *id,
     
    4678)
    4779{
    48 /* XXX should support COND_INITIALIZER */
    49   if ( id )
    50     return (POSIX_Condition_variables_Control *)
     80  ___POSIX_Condition_variables_Get_support( id, location );
     81
     82  return (POSIX_Condition_variables_Control *)
    5183      _Objects_Get( &_POSIX_Condition_variables_Information, *id, location );
    52 
    53   *location = OBJECTS_ERROR;
    54   return NULL;
    5584}
    5685 
Note: See TracChangeset for help on using the changeset viewer.