1 | /* rtems/posix/cond.inl |
---|
2 | * |
---|
3 | * This include file contains the static inline 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 | RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control |
---|
27 | *_POSIX_Condition_variables_Allocate( void ) |
---|
28 | { |
---|
29 | return (POSIX_Condition_variables_Control *) |
---|
30 | _Objects_Allocate( &_POSIX_Condition_variables_Information ); |
---|
31 | } |
---|
32 | |
---|
33 | /*PAGE |
---|
34 | * |
---|
35 | * _POSIX_Condition_variables_Free |
---|
36 | */ |
---|
37 | |
---|
38 | RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Free ( |
---|
39 | POSIX_Condition_variables_Control *the_condition_variable |
---|
40 | ) |
---|
41 | { |
---|
42 | _Objects_Free( |
---|
43 | &_POSIX_Condition_variables_Information, |
---|
44 | &the_condition_variable->Object |
---|
45 | ); |
---|
46 | } |
---|
47 | |
---|
48 | /*PAGE |
---|
49 | * |
---|
50 | * _POSIX_Condition_variables_Get |
---|
51 | */ |
---|
52 | |
---|
53 | RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control |
---|
54 | *_POSIX_Condition_variables_Get ( |
---|
55 | Objects_Id *id, |
---|
56 | Objects_Locations *location |
---|
57 | ) |
---|
58 | { |
---|
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( id, 0 ); |
---|
72 | if ( status ) { |
---|
73 | *location = OBJECTS_ERROR; |
---|
74 | return (POSIX_Condition_variables_Control *) 0; |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | /* |
---|
79 | * Now call Objects_Get() |
---|
80 | */ |
---|
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 | RTEMS_INLINE_ROUTINE boolean _POSIX_Condition_variables_Is_null ( |
---|
92 | POSIX_Condition_variables_Control *the_condition_variable |
---|
93 | ) |
---|
94 | { |
---|
95 | return !the_condition_variable; |
---|
96 | } |
---|
97 | |
---|
98 | #endif |
---|
99 | /* end of include file */ |
---|
100 | |
---|