Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: sandbox/linux/system_headers/linux_signal.h

Issue 1310773006: Update sandbox/linux from upstream (Closed) Base URL: ssh://ssh.github.com/domokit/mojo.git@master
Patch Set: Update to 3909ebfa69566f7374a6900e63cd4d3c73a35378 Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SIGNAL_H_ 5 #ifndef SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SIGNAL_H_
6 #define SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SIGNAL_H_ 6 #define SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SIGNAL_H_
7 7
8 // NOTE: On some toolchains, signal related ABI is incompatible with Linux's 8 // NOTE: On some toolchains, signal related ABI is incompatible with Linux's
9 // (not undefined, but defined different values and in different memory 9 // (not undefined, but defined different values and in different memory
10 // layouts). So, fill the gap here. 10 // layouts). So, fill the gap here.
11 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
12 defined(__aarch64__)
13
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
26
27 #define LINUX_SIG_BLOCK 0
28 #define LINUX_SIG_UNBLOCK 1
29
30 #define LINUX_SA_SIGINFO 4
31 #define LINUX_SA_NODEFER 0x40000000
32 #define LINUX_SA_RESTART 0x10000000
33
34 #define LINUX_SIG_DFL 0
35
36 #elif defined(__mips__)
37
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
50
51 #define LINUX_SIG_BLOCK 1
52 #define LINUX_SIG_UNBLOCK 2
53
54 #define LINUX_SA_SIGINFO 0x00000008
55 #define LINUX_SA_NODEFER 0x40000000
56 #define LINUX_SA_RESTART 0x10000000
57
58 #define LINUX_SIG_DFL 0
59
60 #else
61 #error "Unsupported platform"
62 #endif
11 63
12 #if defined(__native_client_nonsfi__) 64 #if defined(__native_client_nonsfi__)
13 #if !defined(__i386__) && !defined(__arm__) 65 #if !defined(__i386__) && !defined(__arm__)
14 #error "Unsupported platform" 66 #error "Unsupported platform"
15 #endif 67 #endif
16 68
17 #include <signal.h> 69 #include <signal.h>
18 70
19 #define LINUX_SIGBUS 7 // 10 in PNaCl toolchain.
20 #define LINUX_SIGSEGV 11 // 11 in PNaCl toolchain. Defined for consistency.
21 #define LINUX_SIGCHLD 17 // 20 in PNaCl toolchain.
22 #define LINUX_SIGSYS 31 // 12 in PNaCl toolchain.
23
24 #define LINUX_SIG_BLOCK 0 // 1 in PNaCl toolchain.
25 #define LINUX_SIG_UNBLOCK 1 // 2 in PNaCl toolchain.
26
27 #define LINUX_SA_SIGINFO 4 // 2 in PNaCl toolchain.
28 #define LINUX_SA_NODEFER 0x40000000 // Undefined in PNaCl toolchain.
29 #define LINUX_SA_RESTART 0x10000000 // Undefined in PNaCl toolchain.
30
31 #define LINUX_SIG_DFL 0 // In PNaCl toolchain, unneeded cast is applied.
32
33 struct LinuxSigInfo { 71 struct LinuxSigInfo {
34 int si_signo; 72 int si_signo;
35 int si_errno; 73 int si_errno;
36 int si_code; 74 int si_code;
37 75
38 // Extra data is followed by the |si_code|. The length depends on the 76 // Extra data is followed by the |si_code|. The length depends on the
39 // signal number. 77 // signal number.
40 char _sifields[1]; 78 char _sifields[1];
41 }; 79 };
42 80
43 #include "sandbox/linux/system_headers/linux_ucontext.h" 81 #include "sandbox/linux/system_headers/linux_ucontext.h"
44 82
45 #else // !defined(__native_client_nonsfi__) 83 #else // !defined(__native_client_nonsfi__)
46 84
47 // Just alias the toolchain's value.
48 #include <signal.h> 85 #include <signal.h>
49 86
50 #define LINUX_SIGBUS SIGBUS 87 static_assert(LINUX_SIGHUP == SIGHUP, "LINUX_SIGHUP == SIGHUP");
51 #define LINUX_SIGSEGV SIGSEGV 88 static_assert(LINUX_SIGINT == SIGINT, "LINUX_SIGINT == SIGINT");
52 #define LINUX_SIGCHLD SIGCHLD 89 static_assert(LINUX_SIGQUIT == SIGQUIT, "LINUX_SIGQUIT == SIGQUIT");
53 #define LINUX_SIGSYS SIGSYS 90 static_assert(LINUX_SIGABRT == SIGABRT, "LINUX_SIGABRT == SIGABRT");
54 91 static_assert(LINUX_SIGBUS == SIGBUS, "LINUX_SIGBUS == SIGBUS");
55 #define LINUX_SIG_BLOCK SIG_BLOCK 92 static_assert(LINUX_SIGUSR1 == SIGUSR1, "LINUX_SIGUSR1 == SIGUSR1");
56 #define LINUX_SIG_UNBLOCK SIG_UNBLOCK 93 static_assert(LINUX_SIGSEGV == SIGSEGV, "LINUX_SIGSEGV == SIGSEGV");
57 94 static_assert(LINUX_SIGUSR2 == SIGUSR2, "LINUX_SIGUSR2 == SIGUSR2");
58 #define LINUX_SA_SIGINFO SA_SIGINFO 95 static_assert(LINUX_SIGPIPE == SIGPIPE, "LINUX_SIGPIPE == SIGPIPE");
59 #define LINUX_SA_NODEFER SA_NODEFER 96 static_assert(LINUX_SIGTERM == SIGTERM, "LINUX_SIGTERM == SIGTERM");
60 #define LINUX_SA_RESTART SA_RESTART 97 static_assert(LINUX_SIGCHLD == SIGCHLD, "LINUX_SIGCHLD == SIGCHLD");
61 98 static_assert(LINUX_SIGSYS == SIGSYS, "LINUX_SIGSYS == SIGSYS");
62 #define LINUX_SIG_DFL SIG_DFL 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");
63 106
64 typedef siginfo_t LinuxSigInfo; 107 typedef siginfo_t LinuxSigInfo;
65 108
66 #if defined(__ANDROID__) 109 #if defined(__ANDROID__)
67 // Android's signal.h doesn't define ucontext etc. 110 // Android's signal.h doesn't define ucontext etc.
68 #include "sandbox/linux/system_headers/linux_ucontext.h" 111 #include "sandbox/linux/system_headers/linux_ucontext.h"
69 #endif // defined(__ANDROID__) 112 #endif // defined(__ANDROID__)
70 113
71 #endif // !defined(__native_client_nonsfi__) 114 #endif // !defined(__native_client_nonsfi__)
72 115
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];
123 };
124 #else
125 typedef uint64_t LinuxSigSet;
126 #endif
127
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;
134 };
135 #else
136 struct LinuxSigAction {
137 void (*kernel_handler)(int);
138 uint32_t sa_flags;
139 void (*sa_restorer)(void);
140 LinuxSigSet sa_mask;
141 };
142 #endif
143
73 #endif // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SIGNAL_H_ 144 #endif // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SIGNAL_H_
OLDNEW
« no previous file with comments | « sandbox/linux/syscall_broker/broker_host_unittests.cc ('k') | sandbox/linux/tests/unit_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698