Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / sandbox / linux / system_headers / linux_signal.h
blob6801b71cee741aeb4b7d098b3c828869bad7f206
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SIGNAL_H_
6 #define SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SIGNAL_H_
8 // NOTE: On some toolchains, signal related ABI is incompatible with Linux's
9 // (not undefined, but defined different values and in different memory
10 // layouts). So, fill the gap here.
11 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
12 defined(__aarch64__)
14 #define LINUX_SIGHUP 1
15 #define LINUX_SIGINT 2
16 #define LINUX_SIGQUIT 3
17 #define LINUX_SIGABRT 6
18 #define LINUX_SIGBUS 7
19 #define LINUX_SIGUSR1 10
20 #define LINUX_SIGSEGV 11
21 #define LINUX_SIGUSR2 12
22 #define LINUX_SIGPIPE 13
23 #define LINUX_SIGTERM 15
24 #define LINUX_SIGCHLD 17
25 #define LINUX_SIGSYS 31
27 #define LINUX_SIG_BLOCK 0
28 #define LINUX_SIG_UNBLOCK 1
30 #define LINUX_SA_SIGINFO 4
31 #define LINUX_SA_NODEFER 0x40000000
32 #define LINUX_SA_RESTART 0x10000000
34 #define LINUX_SIG_DFL 0
36 #elif defined(__mips__)
38 #define LINUX_SIGHUP 1
39 #define LINUX_SIGINT 2
40 #define LINUX_SIGQUIT 3
41 #define LINUX_SIGABRT 6
42 #define LINUX_SIGBUS 10
43 #define LINUX_SIGSEGV 11
44 #define LINUX_SIGSYS 12
45 #define LINUX_SIGPIPE 13
46 #define LINUX_SIGTERM 15
47 #define LINUX_SIGUSR1 16
48 #define LINUX_SIGUSR2 17
49 #define LINUX_SIGCHLD 18
51 #define LINUX_SIG_BLOCK 1
52 #define LINUX_SIG_UNBLOCK 2
54 #define LINUX_SA_SIGINFO 0x00000008
55 #define LINUX_SA_NODEFER 0x40000000
56 #define LINUX_SA_RESTART 0x10000000
58 #define LINUX_SIG_DFL 0
60 #else
61 #error "Unsupported platform"
62 #endif
64 #if defined(__native_client_nonsfi__)
65 #if !defined(__i386__) && !defined(__arm__)
66 #error "Unsupported platform"
67 #endif
69 #include <signal.h>
71 struct LinuxSigInfo {
72 int si_signo;
73 int si_errno;
74 int si_code;
76 // Extra data is followed by the |si_code|. The length depends on the
77 // signal number.
78 char _sifields[1];
81 #include "sandbox/linux/system_headers/linux_ucontext.h"
83 #else // !defined(__native_client_nonsfi__)
85 #include <signal.h>
87 static_assert(LINUX_SIGHUP == SIGHUP, "LINUX_SIGHUP == SIGHUP");
88 static_assert(LINUX_SIGINT == SIGINT, "LINUX_SIGINT == SIGINT");
89 static_assert(LINUX_SIGQUIT == SIGQUIT, "LINUX_SIGQUIT == SIGQUIT");
90 static_assert(LINUX_SIGABRT == SIGABRT, "LINUX_SIGABRT == SIGABRT");
91 static_assert(LINUX_SIGBUS == SIGBUS, "LINUX_SIGBUS == SIGBUS");
92 static_assert(LINUX_SIGUSR1 == SIGUSR1, "LINUX_SIGUSR1 == SIGUSR1");
93 static_assert(LINUX_SIGSEGV == SIGSEGV, "LINUX_SIGSEGV == SIGSEGV");
94 static_assert(LINUX_SIGUSR2 == SIGUSR2, "LINUX_SIGUSR2 == SIGUSR2");
95 static_assert(LINUX_SIGPIPE == SIGPIPE, "LINUX_SIGPIPE == SIGPIPE");
96 static_assert(LINUX_SIGTERM == SIGTERM, "LINUX_SIGTERM == SIGTERM");
97 static_assert(LINUX_SIGCHLD == SIGCHLD, "LINUX_SIGCHLD == SIGCHLD");
98 static_assert(LINUX_SIGSYS == SIGSYS, "LINUX_SIGSYS == SIGSYS");
99 static_assert(LINUX_SIG_BLOCK == SIG_BLOCK, "LINUX_SIG_BLOCK == SIG_BLOCK");
100 static_assert(LINUX_SIG_UNBLOCK == SIG_UNBLOCK,
101 "LINUX_SIG_UNBLOCK == SIG_UNBLOCK");
102 static_assert(LINUX_SA_SIGINFO == SA_SIGINFO, "LINUX_SA_SIGINFO == SA_SIGINFO");
103 static_assert(LINUX_SA_NODEFER == SA_NODEFER, "LINUX_SA_NODEFER == SA_NODEFER");
104 static_assert(LINUX_SA_RESTART == SA_RESTART, "LINUX_SA_RESTART == SA_RESTART");
105 static_assert(LINUX_SIG_DFL == SIG_DFL, "LINUX_SIG_DFL == SIG_DFL");
107 typedef siginfo_t LinuxSigInfo;
109 #if defined(__ANDROID__)
110 // Android's signal.h doesn't define ucontext etc.
111 #include "sandbox/linux/system_headers/linux_ucontext.h"
112 #endif // defined(__ANDROID__)
114 #endif // !defined(__native_client_nonsfi__)
116 // struct sigset_t is different size in PNaCl from the Linux's.
117 #if defined(__mips__)
118 #if !defined(_NSIG_WORDS)
119 #define _NSIG_WORDS 4
120 #endif
121 struct LinuxSigSet {
122 unsigned long sig[_NSIG_WORDS];
124 #else
125 typedef uint64_t LinuxSigSet;
126 #endif
128 // struct sigaction is different in PNaCl from the Linux's.
129 #if defined(__mips__)
130 struct LinuxSigAction {
131 unsigned int sa_flags;
132 void (*kernel_handler)(int);
133 LinuxSigSet sa_mask;
135 #else
136 struct LinuxSigAction {
137 void (*kernel_handler)(int);
138 uint32_t sa_flags;
139 void (*sa_restorer)(void);
140 LinuxSigSet sa_mask;
142 #endif
144 #endif // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SIGNAL_H_