Xenomai  3.0.8
eventobj.h
1 /*
2  * Copyright (C) 2012 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 
19 #ifndef _COPPERPLATE_EVENTOBJ_H
20 #define _COPPERPLATE_EVENTOBJ_H
21 
22 #include <boilerplate/compiler.h>
23 #include <copperplate/reference.h>
24 
25 struct eventobj_waitentry {
26  pid_t pid;
27  char name[32];
28 };
29 
30 #ifdef CONFIG_XENO_COBALT
31 
32 #include <cobalt/uapi/event.h>
33 
34 struct eventobj_corespec {
35  cobalt_event_t event;
36 };
37 
38 struct eventobj_wait_struct {
39 };
40 
41 #define EVOBJ_FIFO COBALT_EVENT_FIFO
42 #define EVOBJ_PRIO COBALT_EVENT_PRIO
43 
44 #define EVOBJ_ALL COBALT_EVENT_ALL
45 #define EVOBJ_ANY COBALT_EVENT_ANY
46 
47 #else /* CONFIG_XENO_MERCURY */
48 
49 #include <copperplate/syncobj.h>
50 
51 struct eventobj_corespec {
52  struct syncobj sobj;
53  unsigned int value;
54  int flags;
55 };
56 
57 struct eventobj_wait_struct {
58  unsigned int value;
59  int mode;
60 };
61 
62 #define EVOBJ_FIFO 0x0
63 #define EVOBJ_PRIO 0x1
64 
65 #define EVOBJ_ALL 0x0
66 #define EVOBJ_ANY 0x1
67 
68 #endif /* CONFIG_XENO_MERCURY */
69 
70 struct eventobj {
71  struct eventobj_corespec core;
72  fnref_type(void (*)(struct eventobj *evobj)) finalizer;
73 };
74 
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78 
79 int eventobj_init(struct eventobj *evobj,
80  unsigned int value, int flags,
81  fnref_type(void (*)(struct eventobj *evobj)) finalizer) __must_check;
82 
83 int eventobj_destroy(struct eventobj *evobj);
84 
85 void eventobj_uninit(struct eventobj *evobj);
86 
87 int eventobj_post(struct eventobj *evobj,
88  unsigned int bits);
89 
90 int eventobj_wait(struct eventobj *evobj,
91  unsigned int bits,
92  unsigned int *bits_r,
93  int mode,
94  const struct timespec *timeout) __must_check;
95 
96 int eventobj_clear(struct eventobj *evobj,
97  unsigned int bits,
98  unsigned int *bits_r);
99 
100 int eventobj_inquire(struct eventobj *evobj, size_t waitsz,
101  struct eventobj_waitentry *waitlist,
102  unsigned int *bits_r);
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif /* _COPPERPLATE_EVENTOBJ_H */