Xenomai  3.0.8
signal.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_SIGNAL_H
19 #define _COBALT_POSIX_SIGNAL_H
20 
21 #include <linux/signal.h>
22 #include <cobalt/kernel/timer.h>
23 #include <cobalt/kernel/list.h>
24 #include <cobalt/uapi/signal.h>
25 #include <xenomai/posix/syscall.h>
26 
27 struct cobalt_thread;
28 
29 struct cobalt_sigpending {
30  struct siginfo si;
31  struct list_head next;
32 };
33 
34 static inline
35 void cobalt_copy_siginfo(int code,
36  struct siginfo *__restrict__ dst,
37  const struct siginfo *__restrict__ src)
38 {
39  dst->si_signo = src->si_signo;
40  dst->si_errno = src->si_errno;
41  dst->si_code = code;
42 
43  switch (code) {
44  case SI_TIMER:
45  dst->si_tid = src->si_tid;
46  dst->si_overrun = src->si_overrun;
47  dst->si_value = src->si_value;
48  break;
49  case SI_QUEUE:
50  case SI_MESGQ:
51  dst->si_value = src->si_value;
52  /* falldown wanted. */
53  case SI_USER:
54  dst->si_pid = src->si_pid;
55  dst->si_uid = src->si_uid;
56  }
57 }
58 
59 int __cobalt_sigwait(sigset_t *set);
60 
61 int __cobalt_sigtimedwait(sigset_t *set,
62  const struct timespec *timeout,
63  void __user *u_si,
64  int (*put_siginfo)(void __user *u_si,
65  const struct siginfo *si,
66  int overrun));
67 
68 int __cobalt_sigwaitinfo(sigset_t *set,
69  void __user *u_si,
70  int (*put_siginfo)(void __user *u_si,
71  const struct siginfo *si,
72  int overrun));
73 
74 int __cobalt_sigqueue(pid_t pid, int sig, const union sigval *value);
75 
76 int cobalt_signal_send(struct cobalt_thread *thread,
77  struct cobalt_sigpending *sigp,
78  int group);
79 
80 int cobalt_signal_send_pid(pid_t pid,
81  struct cobalt_sigpending *sigp);
82 
83 struct cobalt_sigpending *cobalt_signal_alloc(void);
84 
85 void cobalt_signal_free(struct cobalt_sigpending *sigp);
86 
87 void cobalt_signal_flush(struct cobalt_thread *thread);
88 
89 int cobalt_signal_wait(sigset_t *set, struct siginfo *si,
90  xnticks_t timeout, xntmode_t tmode);
91 
92 int __cobalt_kill(struct cobalt_thread *thread,
93  int sig, int group);
94 
95 COBALT_SYSCALL_DECL(sigwait,
96  (const sigset_t __user *u_set, int __user *u_sig));
97 
98 COBALT_SYSCALL_DECL(sigtimedwait,
99  (const sigset_t __user *u_set,
100  struct siginfo __user *u_si,
101  const struct timespec __user *u_timeout));
102 
103 COBALT_SYSCALL_DECL(sigwaitinfo,
104  (const sigset_t __user *u_set,
105  struct siginfo __user *u_si));
106 
107 COBALT_SYSCALL_DECL(sigpending,
108  (old_sigset_t __user *u_set));
109 
110 COBALT_SYSCALL_DECL(kill, (pid_t pid, int sig));
111 
112 COBALT_SYSCALL_DECL(sigqueue,
113  (pid_t pid, int sig, const union sigval __user *u_value));
114 
115 int cobalt_signal_init(void);
116 
117 #endif /* !_COBALT_POSIX_SIGNAL_H */