Ignore:
Timestamp:
Dec 6, 2002, 1:48:27 PM (19 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.