Xenomai  3.0.5
cond.h
1 /*
2  * Copyright (C) 2011 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13 
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18 #ifndef _XENOMAI_ALCHEMY_COND_H
19 #define _XENOMAI_ALCHEMY_COND_H
20 
21 #include <stdint.h>
22 #include <alchemy/timer.h>
23 #include <alchemy/mutex.h>
24 
30 struct RT_COND {
31  uintptr_t handle;
32 };
33 
34 typedef struct RT_COND RT_COND;
35 
43 struct RT_COND_INFO {
47  char name[XNOBJECT_NAME_LEN];
48 };
49 
50 typedef struct RT_COND_INFO RT_COND_INFO;
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 int rt_cond_create(RT_COND *cond,
57  const char *name);
58 
59 int rt_cond_delete(RT_COND *cond);
60 
61 int rt_cond_signal(RT_COND *cond);
62 
63 int rt_cond_broadcast(RT_COND *cond);
64 
65 int rt_cond_wait_timed(RT_COND *cond,
66  RT_MUTEX *mutex,
67  const struct timespec *abs_timeout);
68 static inline
69 int rt_cond_wait_until(RT_COND *cond, RT_MUTEX *mutex, RTIME timeout)
70 {
71  struct timespec ts;
72  return rt_cond_wait_timed(cond, mutex,
73  alchemy_abs_timeout(timeout, &ts));
74 }
75 
76 static inline
77 int rt_cond_wait(RT_COND *cond, RT_MUTEX *mutex, RTIME timeout)
78 {
79  struct timespec ts;
80  return rt_cond_wait_timed(cond, mutex,
81  alchemy_rel_timeout(timeout, &ts));
82 }
83 
84 int rt_cond_inquire(RT_COND *cond,
85  RT_COND_INFO *info);
86 
87 int rt_cond_bind(RT_COND *cond,
88  const char *name, RTIME timeout);
89 
90 int rt_cond_unbind(RT_COND *cond);
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
98 #endif /* _XENOMAI_ALCHEMY_COND_H */
int rt_cond_create(RT_COND *cond, const char *name)
Create a condition variable.
Definition: cond.c:113
int rt_cond_inquire(RT_COND *cond, RT_COND_INFO *info)
Query condition variable status.
Definition: cond.c:409
static int rt_cond_wait(RT_COND *cond, RT_MUTEX *mutex, RTIME timeout)
Wait on a condition variable (with relative scalar timeout).
Definition: cond.h:77
static int rt_cond_wait_until(RT_COND *cond, RT_MUTEX *mutex, RTIME timeout)
Wait on a condition variable (with absolute scalar timeout).
Definition: cond.h:69
int rt_cond_signal(RT_COND *cond)
Signal a condition variable.
Definition: cond.c:242
Condition variable status descriptor.
Definition: cond.h:43
int rt_cond_delete(RT_COND *cond)
Delete a condition variable.
Definition: cond.c:196
int rt_cond_wait_timed(RT_COND *cond, RT_MUTEX *mutex, const struct timespec *abs_timeout)
Wait on a condition variable.
Definition: cond.c:362
char name[XNOBJECT_NAME_LEN]
Name of condition variable.
Definition: cond.h:47
int rt_cond_broadcast(RT_COND *cond)
Broadcast a condition variable.
Definition: cond.c:270
int rt_cond_bind(RT_COND *cond, const char *name, RTIME timeout)
Bind to a condition variable.
Definition: cond.c:467
int rt_cond_unbind(RT_COND *cond)
Unbind from a condition variable.
Definition: cond.c:489