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