1 | /** |
---|
2 | * @file rtems/posix/cond.inl |
---|
3 | */ |
---|
4 | |
---|
5 | /* rtems/posix/cond.inl |
---|
6 | * |
---|
7 | * This include file contains the static inline 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 | RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control |
---|
31 | *_POSIX_Condition_variables_Allocate( void ) |
---|
32 | { |
---|
33 | return (POSIX_Condition_variables_Control *) |
---|
34 | _Objects_Allocate( &_POSIX_Condition_variables_Information ); |
---|
35 | } |
---|
36 | |
---|
37 | /*PAGE |
---|
38 | * |
---|
39 | * _POSIX_Condition_variables_Free |
---|
40 | */ |
---|
41 | |
---|
42 | RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Free ( |
---|
43 | POSIX_Condition_variables_Control *the_condition_variable |
---|
44 | ) |
---|
45 | { |
---|
46 | _Objects_Free( |
---|
47 | &_POSIX_Condition_variables_Information, |
---|
48 | &the_condition_variable->Object |
---|
49 | ); |
---|
50 | } |
---|
51 | |
---|
52 | /*PAGE |
---|
53 | * |
---|
54 | * _POSIX_Condition_variables_Get |
---|
55 | */ |
---|
56 | |
---|
57 | RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control |
---|
58 | *_POSIX_Condition_variables_Get ( |
---|
59 | Objects_Id *id, |
---|
60 | Objects_Locations *location |
---|
61 | ) |
---|
62 | { |
---|
63 | int status; |
---|
64 | |
---|
65 | if ( !id ) { |
---|
66 | *location = OBJECTS_ERROR; |
---|
67 | return (POSIX_Condition_variables_Control *) 0; |
---|
68 | } |
---|
69 | |
---|
70 | if ( *id == PTHREAD_COND_INITIALIZER ) { |
---|
71 | /* |
---|
72 | * Do an "auto-create" here. |
---|
73 | */ |
---|
74 | |
---|
75 | status = pthread_cond_init( (pthread_cond_t *)id, 0 ); |
---|
76 | if ( status ) { |
---|
77 | *location = OBJECTS_ERROR; |
---|
78 | return (POSIX_Condition_variables_Control *) 0; |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | /* |
---|
83 | * Now call Objects_Get() |
---|
84 | */ |
---|
85 | |
---|
86 | return (POSIX_Condition_variables_Control *) |
---|
87 | _Objects_Get( &_POSIX_Condition_variables_Information, *id, location ); |
---|
88 | } |
---|
89 | |
---|
90 | /*PAGE |
---|
91 | * |
---|
92 | * _POSIX_Condition_variables_Is_null |
---|
93 | */ |
---|
94 | |
---|
95 | RTEMS_INLINE_ROUTINE boolean _POSIX_Condition_variables_Is_null ( |
---|
96 | POSIX_Condition_variables_Control *the_condition_variable |
---|
97 | ) |
---|
98 | { |
---|
99 | return !the_condition_variable; |
---|
100 | } |
---|
101 | |
---|
102 | #endif |
---|
103 | /* end of include file */ |
---|
104 | |
---|