Xenomai API  2.6.5
signal.h
1 /*
2  * Copyright (C) 2006 Gilles Chanteperdrix <[email protected]>.
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 
19 #ifndef _XENO_POSIX_SIGNAL_H
20 #define _XENO_POSIX_SIGNAL_H
21 
22 #if defined(__KERNEL__) || defined(__XENO_SIM__)
23 
24 #include <nucleus/xenomai.h>
25 
26 #ifdef __KERNEL__
27 #include <linux/signal.h>
28 
29 /* These are not defined in kernel-space headers. */
30 #define sa_sigaction sa_handler
31 typedef void (*sighandler_t) (int sig);
32 typedef unsigned long sig_atomic_t;
33 #endif /* __KERNEL__ */
34 
35 #ifdef __XENO_SIM__
36 #include <posix_overrides.h>
37 #endif /* __XENO_SIM__ */
38 
39 #undef sigemptyset
40 #undef sigfillset
41 #undef sigaddset
42 #undef sigdelset
43 #undef sigismember
44 #undef sigaction
45 #undef sigqueue
46 #undef SIGRTMIN
47 #undef SIGRTMAX
48 
49 #define sigaction(sig, action, old) pse51_sigaction(sig, action, old)
50 #define sigemptyset pse51_sigemptyset
51 #define sigfillset pse51_sigfillset
52 #define sigaddset pse51_sigaddset
53 #define sigdelset pse51_sigdelset
54 #define sigismember pse51_sigismember
55 
56 #define SIGRTMIN 33
57 #define SIGRTMAX 64
58 
59 struct pse51_thread;
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 int sigemptyset(sigset_t *set);
66 
67 int sigfillset(sigset_t *set);
68 
69 int sigaddset(sigset_t *set,
70  int signum);
71 
72 int sigdelset(sigset_t *set,
73  int signum);
74 
75 int sigismember(const sigset_t *set,
76  int signum);
77 
78 int pthread_kill(struct pse51_thread *thread,
79  int sig);
80 
81 int pthread_sigmask(int how,
82  const sigset_t *set,
83  sigset_t *oset);
84 
85 int sigaction(int sig,
86  const struct sigaction *action,
87  struct sigaction *old);
88 
89 int sigpending(sigset_t *set);
90 
91 int sigwait(const sigset_t *set,
92  int *sig);
93 
94 /* Real-time signals. */
95 int sigwaitinfo(const sigset_t *__restrict__ set,
96  siginfo_t *__restrict__ info);
97 
98 int sigtimedwait(const sigset_t *__restrict__ user_set,
99  siginfo_t *__restrict__ info,
100  const struct timespec *__restrict__ timeout);
101 
102 int pthread_sigqueue_np (struct pse51_thread *thread, int sig, union sigval value);
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #else /* !(__KERNEL__ || __XENO_SIM__) */
109 
110 #pragma GCC system_header
111 
112 #include_next <signal.h>
113 /* In case signal.h is included for a side effect of an __need* macro, include
114  it a second time to get all definitions. */
115 #include_next <signal.h>
116 
117 #endif /* !(__KERNEL__ || __XENO_SIM__) */
118 
119 /*
120  * Those are pseudo-signals only available with pthread_kill() to
121  * suspend/resume/unblock threads synchronously via the low-level
122  * nucleus interface. Can't block them, queue them, or even set them
123  * in a sigset. Those are nasty, strictly anti-POSIX things; we do
124  * provide them nevertheless only because we are mean people doing
125  * harmful code for no valid reason. Can't go against your nature,
126  * right? Nah... (this said, don't blame us for POSIX, we are not
127  * _that_ mean).
128  */
129 #define SIGSUSP (SIGRTMAX + 1)
130 #define SIGRESM (SIGRTMAX + 2)
131 #define SIGRELS (SIGRTMAX + 3)
132 
133 #endif /* _XENO_POSIX_SIGNAL_H */
int sigdelset(sigset_t *set, int signum)
Delete a signal from a signal set.
Definition: signal.c:248
int sigaddset(sigset_t *set, int signum)
Add a signal to a signal set.
Definition: signal.c:215
int sigpending(sigset_t *set)
Examine pending signals.
Definition: signal.c:672
int pthread_kill(pthread_t thread, int sig)
Send a signal to a thread.
Definition: signal.c:521
int sigismember(const sigset_t *set, int signum)
Test for a signal in a signal set.
Definition: signal.c:281
int pthread_sigqueue_np(pthread_t thread, int sig, union sigval value)
Queue a signal to a thread.
Definition: signal.c:618
int sigtimedwait(const sigset_t *__restrict__ user_set, siginfo_t *__restrict__ info, const struct timespec *__restrict__ timeout)
Wait during a bounded time for signals.
Definition: signal.c:1002
int sigfillset(sigset_t *set)
Initialize and fill a signal set.
Definition: signal.c:187
int pthread_sigmask(int how, const sigset_t *set, sigset_t *oset)
Examine and change the set of signals blocked by a thread.
Definition: signal.c:735
int sigwaitinfo(const sigset_t *__restrict__ set, siginfo_t *__restrict__ info)
Wait for signals.
Definition: signal.c:949
int sigwait(const sigset_t *set, int *sig)
Wait for signals.
Definition: signal.c:908
int sigaction(int sig, const struct sigaction *action, struct sigaction *old)
Examine and change a signal action.
Definition: signal.c:466
int sigemptyset(sigset_t *set)
Initialize and empty a signal set.
Definition: signal.c:164