Xenomai  3.0.8
event.h
1 /*
2  * Copyright (C) 2014 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_TRANK_NATIVE_EVENT_H
19 #define _XENOMAI_TRANK_NATIVE_EVENT_H
20 
21 #include <alchemy/event.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 COMPAT_DECL(int, rt_event_create(RT_EVENT *event, const char *name,
28  unsigned long ivalue, int mode));
29 
30 COMPAT_DECL(int, rt_event_signal(RT_EVENT *event, unsigned long mask));
31 
32 COMPAT_DECL(int, rt_event_clear(RT_EVENT *event, unsigned long mask,
33  unsigned long *mask_r));
34 
35 #ifdef __XENO_COMPAT__
36 
37 static inline
38 int rt_event_wait_until(RT_EVENT *event,
39  unsigned long mask, unsigned long *mask_r,
40  int mode, RTIME timeout)
41 {
42  struct timespec ts;
43  unsigned int _mask;
44  int ret;
45 
46  ret = rt_event_wait_timed(event, mask, &_mask, mode,
47  alchemy_abs_timeout(timeout, &ts));
48  if (ret)
49  return ret;
50 
51  *mask_r = _mask;
52 
53  return 0;
54 }
55 
56 static inline
57 int rt_event_wait(RT_EVENT *event,
58  unsigned long mask, unsigned long *mask_r,
59  int mode, RTIME timeout)
60 {
61  struct timespec ts;
62  unsigned int _mask;
63  int ret;
64 
65  ret = rt_event_wait_timed(event, mask, &_mask, mode,
66  alchemy_rel_timeout(timeout, &ts));
67  if (ret)
68  return ret;
69 
70  *mask_r = _mask;
71 
72  return 0;
73 }
74 
75 #endif /* __XENO_COMPAT__ */
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif /* _XENOMAI_TRANK_NATIVE_EVENT_H */
int rt_event_wait_timed(RT_EVENT *event, unsigned int mask, unsigned int *mask_r, int mode, const struct timespec *abs_timeout)
Wait for an arbitrary set of events.
Definition: event.c:390
int rt_event_create(RT_EVENT *event, const char *name, unsigned int ivalue, int mode)
Create an event flag group.
Definition: event.c:172
int rt_event_clear(RT_EVENT *event, unsigned int mask, unsigned int *mask_r)
Clear event flags.
Definition: event.c:489
int rt_event_signal(RT_EVENT *event, unsigned int mask)
Signal an event.
Definition: event.c:444
static int rt_event_wait(RT_EVENT *event, unsigned int mask, unsigned int *mask_r, int mode, RTIME timeout)
Wait for an arbitrary set of events (with relative scalar timeout).
Definition: event.h:101
static int rt_event_wait_until(RT_EVENT *event, unsigned int mask, unsigned int *mask_r, int mode, RTIME timeout)
Wait for an arbitrary set of events (with absolute scalar timeout).
Definition: event.h:91