1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2015 Joyent, Inc.
25 */
26
27 #ifndef _LX_SIGNUM_H
28 #define _LX_SIGNUM_H
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #define LX_SIGHUP 1
35 #define LX_SIGINT 2
36 #define LX_SIGQUIT 3
37 #define LX_SIGILL 4
38 #define LX_SIGTRAP 5
39 #define LX_SIGABRT 6
40 #define LX_SIGIOT 6
41 #define LX_SIGBUS 7
42 #define LX_SIGFPE 8
43 #define LX_SIGKILL 9
44 #define LX_SIGUSR1 10
45 #define LX_SIGSEGV 11
46 #define LX_SIGUSR2 12
47 #define LX_SIGPIPE 13
48 #define LX_SIGALRM 14
49 #define LX_SIGTERM 15
50 #define LX_SIGSTKFLT 16
51 #define LX_SIGCHLD 17
52 #define LX_SIGCONT 18
53 #define LX_SIGSTOP 19
54 #define LX_SIGTSTP 20
55 #define LX_SIGTTIN 21
56 #define LX_SIGTTOU 22
57 #define LX_SIGURG 23
58 #define LX_SIGXCPU 24
59 #define LX_SIGXFSZ 25
60 #define LX_SIGVTALRM 26
61 #define LX_SIGPROF 27
62 #define LX_SIGWINCH 28
63 #define LX_SIGIO 29
64 #define LX_SIGPOLL LX_SIGIO
65 #define LX_SIGPWR 30
66 #define LX_SIGSYS 31
67 #define LX_SIGUNUSED 31
68
69 #define LX_NSIG 64 /* Linux _NSIG */
70
71 #define LX_SIGRTMIN 32
72 #define LX_SIGRTMAX LX_NSIG
73
74 extern const int ltos_signo[];
75 extern const int stol_signo[];
76
77 extern int lx_stol_signo(int, int);
78 extern int lx_ltos_signo(int, int);
79 extern int lx_stol_status(int, int);
80 extern int lx_stol_sigcode(int);
81
82 /*
83 * NOTE: Linux uses different definitions for 'sigset_t's and 'sigaction_t's
84 * depending on whether the definition is for user space or the kernel.
85 *
86 * The definitions below MUST correspond to the Linux kernel versions,
87 * as glibc will do the necessary translation from the Linux user
88 * versions.
89 */
90 #if defined(_LP64)
91 #define LX_NSIG_WORDS 1
92 #define LX_WSHIFT 6
93 #elif defined(_ILP32)
94 #define LX_NSIG_WORDS 2
95 #define LX_WSHIFT 5
96 #else
97 #error "LX only supports LP64 and ILP32"
98 #endif
99
100 typedef struct {
101 ulong_t __bits[LX_NSIG_WORDS];
102 } lx_sigset_t;
103
104 #define LX_NBITS (sizeof (ulong_t) * NBBY)
105 #define lx_sigmask(n) (1UL << (((n) - 1) % LX_NBITS))
106 #define lx_sigword(n) (((ulong_t)((n) - 1)) >> LX_WSHIFT)
107 #define lx_sigismember(s, n) (lx_sigmask(n) & (s)->__bits[lx_sigword(n)])
108 #define lx_sigaddset(s, n) ((s)->__bits[lx_sigword(n)] |= lx_sigmask(n))
109
110 #ifdef __cplusplus
111 }
112 #endif
113
114 #endif /* _LX_SIGNUM_H */