source: rtems/cpukit/posix/macros/rtems/posix/cond.inl @ 5287d3e

4.104.114.84.95
Last change on this file since 5287d3e was 5287d3e, checked in by Joel Sherrill <joel.sherrill@…>, on 04/07/06 at 01:16:55

2006-04-06 Joel Sherrill <joel@…>

  • posix/inline/rtems/posix/mutex.inl, posix/inline/rtems/posix/timer.inl, posix/macros/rtems/posix/cond.inl, posix/macros/rtems/posix/mutex.inl, posix/macros/rtems/posix/timer.inl: Fix warnings.
  • Property mode set to 100644
File size: 2.7 KB
Line 
1/**
2 * @file rtems/posix/cond.inl
3 */
4
5/*  rtems/posix/cond.inl
6 *
7 *  This include file contains the macro implementation of the private
8 *  inlined routines for POSIX condition variables.
9 *
10 *  COPYRIGHT (c) 1989-2002.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19 
20#ifndef _RTEMS_POSIX_COND_INL
21#define _RTEMS_POSIX_COND_INL
22 
23#include <pthread.h>
24
25/*PAGE
26 *
27 *  _POSIX_Condition_variables_Allocate
28 */
29 
30#define _POSIX_Condition_variables_Allocate() \
31  (POSIX_Condition_variables_Control *) \
32    _Objects_Allocate( &_POSIX_Condition_variables_Information )
33 
34/*PAGE
35 *
36 *  _POSIX_Condition_variables_Free
37 *
38 *  NOTE: The support macro makes it possible for both to use exactly
39 *        the same code to check for NULL id pointer and
40 *        PTHREAD_COND_INITIALIZER without adding overhead.
41 */
42 
43#define _POSIX_Condition_variables_Free( _the_condition_variable ) \
44  _Objects_Free( &_POSIX_Condition_variables_Information, \
45    &(_the_condition_variable)->Object)
46 
47/*PAGE
48 *
49 *  _POSIX_Condition_variables_Get
50 *
51 *  NOTE: The support macro makes it possible for both to use exactly
52 *        the same code to check for NULL id pointer and
53 *        PTHREAD_COND_INITIALIZER without adding overhead.
54 */
55
56#define ___POSIX_Condition_variables_Get_support( _cond, _location ) \
57  do { \
58    Objects_Id        *_id = (Objects_Id *)_cond; \
59    int _status; \
60    \
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( (pthread_cond_t *)_id, 0 ); \
72      if ( _status ) { \
73        *_location = OBJECTS_ERROR;  \
74        return (POSIX_Condition_variables_Control *) 0; \
75      } \
76    } \
77  } while (0)
78 
79 
80/* If we find a compiler that doesn't accept static inline functions,
81 * then this will have to move to a .c file.  Until then, we will use this.
82 */
83static inline POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get (
84  pthread_cond_t    *cond,
85  Objects_Locations *location
86)
87{
88  Objects_Id        *id = (Objects_Id *)cond;
89  ___POSIX_Condition_variables_Get_support( id, location );
90
91  return (POSIX_Condition_variables_Control *)
92      _Objects_Get( &_POSIX_Condition_variables_Information, *id, location );
93}
94 
95/*PAGE
96 *
97 *  _POSIX_Condition_variables_Is_null
98 */
99 
100#define _POSIX_Condition_variables_Is_null( _the_condition_variable ) \
101  (!(_the_condition_variable))
102
103#endif
104/*  end of include file */
Note: See TracBrowser for help on using the repository browser.