Xenomai  3.0.5
extension.h
1 /*
2  * Copyright (C) 2013 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program 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
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18 #ifndef _COBALT_POSIX_EXTENSION_H
19 #define _COBALT_POSIX_EXTENSION_H
20 
21 #include <linux/time.h>
22 #include <linux/list.h>
23 
24 #ifdef CONFIG_XENO_OPT_COBALT_EXTENSION
25 
26 #include <cobalt/kernel/thread.h>
27 
28 struct cobalt_timer;
29 struct cobalt_sigpending;
30 struct cobalt_extref;
31 struct siginfo;
32 struct xnsched_class;
33 union xnsched_policy_param;
34 
35 struct cobalt_extension {
36  struct xnthread_personality core;
37  struct {
38  struct cobalt_thread *
39  (*timer_init)(struct cobalt_extref *reftimer, /* nklocked, IRQs off. */
40  const struct sigevent *__restrict__ evp);
41  int (*timer_settime)(struct cobalt_extref *reftimer, /* nklocked, IRQs off. */
42  const struct itimerspec *__restrict__ value,
43  int flags);
44  int (*timer_gettime)(struct cobalt_extref *reftimer, /* nklocked, IRQs off. */
45  struct itimerspec *__restrict__ value);
46  int (*timer_delete)(struct cobalt_extref *reftimer); /* nklocked, IRQs off. */
47  int (*timer_cleanup)(struct cobalt_extref *reftimer); /* nklocked, IRQs off. */
48  int (*signal_deliver)(struct cobalt_extref *refthread,
49  struct siginfo *si,
50  struct cobalt_sigpending *sigp);
51  int (*signal_queue)(struct cobalt_extref *refthread,
52  struct cobalt_sigpending *sigp);
53  int (*signal_copyinfo)(struct cobalt_extref *refthread,
54  void __user *u_si,
55  const struct siginfo *si,
56  int overrun);
57  int (*sched_yield)(struct cobalt_extref *curref);
58  int (*thread_setsched)(struct cobalt_extref *refthread, /* nklocked, IRQs off. */
59  struct xnsched_class *sched_class,
60  union xnsched_policy_param *param);
61  } ops;
62 };
63 
64 struct cobalt_extref {
65  struct cobalt_extension *extension;
66  struct list_head next;
67  void *private;
68 };
69 
70 static inline void cobalt_set_extref(struct cobalt_extref *ref,
71  struct cobalt_extension *ext,
72  void *priv)
73 {
74  ref->extension = ext;
75  ref->private = priv;
76 }
77 
83 #define cobalt_initcall_extension(__extfn, __extref, __owner, __ret, __args...) \
84  ({ \
85  int __val = 0; \
86  if ((__owner) && (__owner)->extref.extension) { \
87  (__extref)->extension = (__owner)->extref.extension; \
88  if ((__extref)->extension->ops.__extfn) { \
89  (__ret) = (__extref)->extension->ops. \
90  __extfn(__extref, ##__args ); \
91  __val = 1; \
92  } \
93  } else \
94  (__extref)->extension = NULL; \
95  __val; \
96  })
97 
98 #define cobalt_call_extension(__extfn, __extref, __ret, __args...) \
99  ({ \
100  int __val = 0; \
101  if ((__extref)->extension && \
102  (__extref)->extension->ops.__extfn) { \
103  (__ret) = (__extref)->extension->ops. \
104  __extfn(__extref, ##__args ); \
105  __val = 1; \
106  } \
107  __val; \
108  })
109 
110 #else /* !CONFIG_XENO_OPT_COBALT_EXTENSION */
111 
112 struct cobalt_extension;
113 
114 struct cobalt_extref {
115 };
116 
117 static inline void cobalt_set_extref(struct cobalt_extref *ref,
118  struct cobalt_extension *ext,
119  void *priv)
120 {
121 }
122 
123 #define cobalt_initcall_extension(__extfn, __extref, __owner, __ret, __args...) \
124  ({ (void)(__owner); (void)(__ret); 0; })
125 
126 #define cobalt_call_extension(__extfn, __extref, __ret, __args...) \
127  ({ (void)(__ret); 0; })
128 
129 #endif /* !CONFIG_XENO_OPT_COBALT_EXTENSION */
130 
131 #endif /* !_COBALT_POSIX_EXTENSION_H */
int sched_yield(void)
Yield the processor.
Definition: sched.c:58
int timer_gettime(timer_t timerid, struct itimerspec *value)
Get timer next expiration date and reload value.
Definition: timer.c:208
int timer_delete(timer_t timerid)
Delete a timer object.
Definition: timer.c:105
int timer_settime(timer_t timerid, int flags, const struct itimerspec *__restrict__ value, struct itimerspec *__restrict__ ovalue)
Start or stop a timer.
Definition: timer.c:165