hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 * Copyright (C) 2013 Philippe Gerum <rpm@xenomai.org>.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
#ifndef _COBALT_POSIX_SIGNAL_H
#define _COBALT_POSIX_SIGNAL_H
 
#include <linux/signal.h>
#include <cobalt/kernel/timer.h>
#include <cobalt/kernel/list.h>
#include <cobalt/uapi/signal.h>
#include <xenomai/posix/syscall.h>
 
struct cobalt_thread;
 
struct cobalt_sigpending {
   struct siginfo si;
   struct list_head next;
};
 
static inline
void cobalt_copy_siginfo(int code,
            struct siginfo *__restrict__ dst,
            const struct siginfo *__restrict__ src)
{
   dst->si_signo = src->si_signo;
   dst->si_errno = src->si_errno;
   dst->si_code = code;
 
   switch (code) {
   case SI_TIMER:
       dst->si_tid = src->si_tid;
       dst->si_overrun = src->si_overrun;
       dst->si_value = src->si_value;
       break;
   case SI_QUEUE:
   case SI_MESGQ:
       dst->si_value = src->si_value;
       fallthrough;
   case SI_USER:
       dst->si_pid = src->si_pid;
       dst->si_uid = src->si_uid;
   }
}
 
int __cobalt_sigwait(sigset_t *set);
 
int __cobalt_sigtimedwait(sigset_t *set,
             const struct timespec64 *timeout,
             void __user *u_si,
             bool compat);
 
int __cobalt_sigwaitinfo(sigset_t *set,
            void __user *u_si,
            bool compat);
 
int __cobalt_sigqueue(pid_t pid, int sig, const union sigval *value);
 
int cobalt_signal_send(struct cobalt_thread *thread,
              struct cobalt_sigpending *sigp,
              int group);
 
int cobalt_signal_send_pid(pid_t pid,
              struct cobalt_sigpending *sigp);
 
struct cobalt_sigpending *cobalt_signal_alloc(void);
 
void cobalt_signal_free(struct cobalt_sigpending *sigp);
 
void cobalt_signal_flush(struct cobalt_thread *thread);
 
int cobalt_signal_wait(sigset_t *set, struct siginfo *si,
              xnticks_t timeout, xntmode_t tmode);
 
int __cobalt_kill(struct cobalt_thread *thread,
         int sig, int group);
 
COBALT_SYSCALL_DECL(sigwait,
           (const sigset_t __user *u_set, int __user *u_sig));
 
COBALT_SYSCALL_DECL(sigtimedwait,
           (const sigset_t __user *u_set,
            struct siginfo __user *u_si,
            const struct __user_old_timespec __user *u_timeout));
 
COBALT_SYSCALL_DECL(sigtimedwait64,
           (const sigset_t __user *u_set,
            struct siginfo __user *u_si,
            const struct __kernel_timespec __user *u_timeout));
 
COBALT_SYSCALL_DECL(sigwaitinfo,
           (const sigset_t __user *u_set,
            struct siginfo __user *u_si));
 
COBALT_SYSCALL_DECL(sigpending,
           (old_sigset_t __user *u_set));
 
COBALT_SYSCALL_DECL(kill, (pid_t pid, int sig));
 
COBALT_SYSCALL_DECL(sigqueue,
           (pid_t pid, int sig, const union sigval __user *u_value));
 
int cobalt_signal_init(void);
 
void cobalt_signal_cleanup(void);
 
#endif /* !_COBALT_POSIX_SIGNAL_H */