Xenomai  3.1
signal.h
1 /*
2  * Copyright (C) 2013 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13 
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18 #ifndef _MERCURY_BOILERPLATE_SIGNAL_H
19 #define _MERCURY_BOILERPLATE_SIGNAL_H
20 
21 #include <signal.h>
22 
23 #ifndef sigev_notify_thread_id
24 #define sigev_notify_thread_id _sigev_un._tid
25 #endif
26 
27 /* Generates reserved signal numbers for Boilerplate/Copperplate. */
28 #define __SIGRSVD(n) (SIGRTMIN + 8 + (n))
29 
30 #define SIGSUSP __SIGRSVD(0) /* Suspend request */
31 #define SIGRESM __SIGRSVD(1) /* Resume request */
32 #define SIGRELS __SIGRSVD(2) /* Syscall abort */
33 #define SIGRRB __SIGRSVD(3) /* Round-robin event */
34 #define SIGAGENT __SIGRSVD(4) /* Request to remote agent */
35 #define SIGPERIOD __SIGRSVD(5) /* Periodic signal */
36 
37 /* Generates private signal numbers for clients, up to SIGRTMAX. */
38 #define __SIGPRIV(n) __SIGRSVD(8 + (n))
39 
40 #define SIGSAFE_LOCK_ENTRY(__safelock) \
41  do { \
42  sigset_t __safeset, __oldsafeset; \
43  sigemptyset(&__safeset); \
44  sigaddset(&__safeset, SIGSUSP); \
45  pthread_sigmask(SIG_BLOCK, &__safeset, &__oldsafeset); \
46  push_cleanup_lock(__safelock); \
47  write_lock(__safelock);
48 
49 #define SIGSAFE_LOCK_EXIT(__safelock) \
50  write_unlock(__safelock); \
51  pop_cleanup_lock(&__safelock); \
52  pthread_sigmask(SIG_SETMASK, &__oldsafeset, NULL); \
53  } while (0)
54 
55 #endif /* _MERCURY_BOILERPLATE_SIGNAL_H */