Xenomai  3.0-rc3
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 COMPAT_DECL(int, rt_event_create(RT_EVENT *event, const char *name,
24  unsigned long ivalue, int mode));
25 
26 COMPAT_DECL(int, rt_event_signal(RT_EVENT *event, unsigned long mask));
27 
28 COMPAT_DECL(int, rt_event_clear(RT_EVENT *event, unsigned long mask,
29  unsigned long *mask_r));
30 
31 #ifdef __XENO_COMPAT__
32 
33 static inline
34 int rt_event_wait_until(RT_EVENT *event,
35  unsigned long mask, unsigned long *mask_r,
36  int mode, RTIME timeout)
37 {
38  struct timespec ts;
39  unsigned int _mask;
40  int ret;
41 
42  ret = rt_event_wait_timed(event, mask, &_mask, mode,
43  alchemy_abs_timeout(timeout, &ts));
44  if (ret)
45  return ret;
46 
47  *mask_r = _mask;
48 
49  return 0;
50 }
51 
52 static inline
53 int rt_event_wait(RT_EVENT *event,
54  unsigned long mask, unsigned long *mask_r,
55  int mode, RTIME timeout)
56 {
57  struct timespec ts;
58  unsigned int _mask;
59  int ret;
60 
61  ret = rt_event_wait_timed(event, mask, &_mask, mode,
62  alchemy_rel_timeout(timeout, &ts));
63  if (ret)
64  return ret;
65 
66  *mask_r = _mask;
67 
68  return 0;
69 }
70 
71 #endif /* __XENO_COMPAT__ */
72 
73 #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:382
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:481
int rt_event_signal(RT_EVENT *event, unsigned int mask)
Signal an event.
Definition: event.c:436
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