Xenomai  3.1
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 (*signal_copyinfo_compat)(struct cobalt_extref *refthread,
58  void __user *u_si,
59  const struct siginfo *si,
60  int overrun);
61  int (*sched_yield)(struct cobalt_extref *curref);
62  int (*thread_setsched)(struct cobalt_extref *refthread, /* nklocked, IRQs off. */
63  struct xnsched_class *sched_class,
64  union xnsched_policy_param *param);
65  } ops;
66 };
67 
68 struct cobalt_extref {
69  struct cobalt_extension *extension;
70  struct list_head next;
71  void *private;
72 };
73 
74 static inline void cobalt_set_extref(struct cobalt_extref *ref,
75  struct cobalt_extension *ext,
76  void *priv)
77 {
78  ref->extension = ext;
79  ref->private = priv;
80 }
81 
87 #define cobalt_initcall_extension(__extfn, __extref, __owner, __ret, __args...) \
88  ({ \
89  int __val = 0; \
90  if ((__owner) && (__owner)->extref.extension) { \
91  (__extref)->extension = (__owner)->extref.extension; \
92  if ((__extref)->extension->ops.__extfn) { \
93  (__ret) = (__extref)->extension->ops. \
94  __extfn(__extref, ##__args ); \
95  __val = 1; \
96  } \
97  } else \
98  (__extref)->extension = NULL; \
99  __val; \
100  })
101 
102 #define cobalt_call_extension(__extfn, __extref, __ret, __args...) \
103  ({ \
104  int __val = 0; \
105  if ((__extref)->extension && \
106  (__extref)->extension->ops.__extfn) { \
107  (__ret) = (__extref)->extension->ops. \
108  __extfn(__extref, ##__args ); \
109  __val = 1; \
110  } \
111  __val; \
112  })
113 
114 #else /* !CONFIG_XENO_OPT_COBALT_EXTENSION */
115 
116 struct cobalt_extension;
117 
118 struct cobalt_extref {
119 };
120 
121 static inline void cobalt_set_extref(struct cobalt_extref *ref,
122  struct cobalt_extension *ext,
123  void *priv)
124 {
125 }
126 
127 #define cobalt_initcall_extension(__extfn, __extref, __owner, __ret, __args...) \
128  ({ (void)(__owner); (void)(__ret); 0; })
129 
130 #define cobalt_call_extension(__extfn, __extref, __ret, __args...) \
131  ({ (void)(__ret); 0; })
132 
133 #endif /* !CONFIG_XENO_OPT_COBALT_EXTENSION */
134 
135 #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:212
int timer_delete(timer_t timerid)
Delete a timer object.
Definition: timer.c:107
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:168