source: rtems/cpukit/posix/macros/rtems/posix/cond.inl @ 2837a5e

4.104.114.84.95
Last change on this file since 2837a5e was 2837a5e, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 6, 2002 at 1:48:27 PM

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.
  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*  rtems/posix/cond.inl
2 *
3 *  This include file contains the macro implementation of the private
4 *  inlined routines for POSIX condition variables.
5 *
6 *  COPYRIGHT (c) 1989-2002.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15 
16#ifndef __RTEMS_POSIX_CONDITION_VARIABLES_inl
17#define __RTEMS_POSIX_CONDITION_VARIABLES_inl
18 
19#include <pthread.h>
20
21/*PAGE
22 *
23 *  _POSIX_Condition_variables_Allocate
24 */
25 
26#define _POSIX_Condition_variables_Allocate() \
27  (POSIX_Condition_variables_Control *) \
28    _Objects_Allocate( &_POSIX_Condition_variables_Information )
29 
30/*PAGE
31 *
32 *  _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.
37 */
38 
39#define _POSIX_Condition_variables_Free( _the_condition_variable ) \
40  _Objects_Free( &_POSIX_Condition_variables_Information, \
41    &(_the_condition_variable)->Object)
42 
43/*PAGE
44 *
45 *  _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.
50 */
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)
73 
74 
75static POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get (
76  Objects_Id        *id,
77  Objects_Locations *location
78)
79{
80  ___POSIX_Condition_variables_Get_support( id, location );
81
82  return (POSIX_Condition_variables_Control *)
83      _Objects_Get( &_POSIX_Condition_variables_Information, *id, location );
84}
85 
86/*PAGE
87 *
88 *  _POSIX_Condition_variables_Is_null
89 */
90 
91#define _POSIX_Condition_variables_Is_null( _the_condition_variable ) \
92  (!(_the_condition_variable))
93
94#endif
95/*  end of include file */
Note: See TracBrowser for help on using the repository browser.