Xenomai  3.1
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  bool compat);
65 
66 int __cobalt_sigwaitinfo(sigset_t *set,
67  void __user *u_si,
68  bool compat);
69 
70 int __cobalt_sigqueue(pid_t pid, int sig, const union sigval *value);
71 
72 int cobalt_signal_send(struct cobalt_thread *thread,
73  struct cobalt_sigpending *sigp,
74  int group);
75 
76 int cobalt_signal_send_pid(pid_t pid,
77  struct cobalt_sigpending *sigp);
78 
79 struct cobalt_sigpending *cobalt_signal_alloc(void);
80 
81 void cobalt_signal_free(struct cobalt_sigpending *sigp);
82 
83 void cobalt_signal_flush(struct cobalt_thread *thread);
84 
85 int cobalt_signal_wait(sigset_t *set, struct siginfo *si,
86  xnticks_t timeout, xntmode_t tmode);
87 
88 int __cobalt_kill(struct cobalt_thread *thread,
89  int sig, int group);
90 
91 COBALT_SYSCALL_DECL(sigwait,
92  (const sigset_t __user *u_set, int __user *u_sig));
93 
94 COBALT_SYSCALL_DECL(sigtimedwait,
95  (const sigset_t __user *u_set,
96  struct siginfo __user *u_si,
97  const struct timespec __user *u_timeout));
98 
99 COBALT_SYSCALL_DECL(sigwaitinfo,
100  (const sigset_t __user *u_set,
101  struct siginfo __user *u_si));
102 
103 COBALT_SYSCALL_DECL(sigpending,
104  (old_sigset_t __user *u_set));
105 
106 COBALT_SYSCALL_DECL(kill, (pid_t pid, int sig));
107 
108 COBALT_SYSCALL_DECL(sigqueue,
109  (pid_t pid, int sig, const union sigval __user *u_value));
110 
111 int cobalt_signal_init(void);
112 
113 #endif /* !_COBALT_POSIX_SIGNAL_H */