OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_VM_SIGNAL_HANDLER_H_ | 5 #ifndef RUNTIME_VM_SIGNAL_HANDLER_H_ |
6 #define RUNTIME_VM_SIGNAL_HANDLER_H_ | 6 #define RUNTIME_VM_SIGNAL_HANDLER_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 #elif defined(HOST_OS_WINDOWS) | 31 #elif defined(HOST_OS_WINDOWS) |
32 // Stub out for windows. | 32 // Stub out for windows. |
33 struct siginfo_t; | 33 struct siginfo_t; |
34 struct mcontext_t; | 34 struct mcontext_t; |
35 struct sigset_t {}; | 35 struct sigset_t {}; |
36 #elif defined(HOST_OS_FUCHSIA) | 36 #elif defined(HOST_OS_FUCHSIA) |
37 #include <signal.h> // NOLINT | 37 #include <signal.h> // NOLINT |
38 #include <ucontext.h> // NOLINT | 38 #include <ucontext.h> // NOLINT |
39 #endif | 39 #endif |
40 | 40 |
41 | |
42 // Old linux kernels on ARM might require a trampoline to | 41 // Old linux kernels on ARM might require a trampoline to |
43 // work around incorrect Thumb -> ARM transitions. See SignalHandlerTrampoline | 42 // work around incorrect Thumb -> ARM transitions. See SignalHandlerTrampoline |
44 // below for more details. | 43 // below for more details. |
45 #if defined(HOST_ARCH_ARM) && \ | 44 #if defined(HOST_ARCH_ARM) && \ |
46 (defined(HOST_OS_LINUX) || defined(HOST_OS_ANDROID)) && \ | 45 (defined(HOST_OS_LINUX) || defined(HOST_OS_ANDROID)) && \ |
47 !defined(__thumb__) | 46 !defined(__thumb__) |
48 #define USE_SIGNAL_HANDLER_TRAMPOLINE | 47 #define USE_SIGNAL_HANDLER_TRAMPOLINE |
49 #endif | 48 #endif |
50 | 49 |
51 | |
52 namespace dart { | 50 namespace dart { |
53 | 51 |
54 typedef void (*SignalAction)(int signal, siginfo_t* info, void* context); | 52 typedef void (*SignalAction)(int signal, siginfo_t* info, void* context); |
55 | 53 |
56 class SignalHandler : public AllStatic { | 54 class SignalHandler : public AllStatic { |
57 public: | 55 public: |
58 template <SignalAction action> | 56 template <SignalAction action> |
59 static void Install() { | 57 static void Install() { |
60 #if defined(USE_SIGNAL_HANDLER_TRAMPOLINE) | 58 #if defined(USE_SIGNAL_HANDLER_TRAMPOLINE) |
61 InstallImpl(SignalHandlerTrampoline<action>); | 59 InstallImpl(SignalHandlerTrampoline<action>); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 register siginfo_t* arg1 asm("r1") = info; | 104 register siginfo_t* arg1 asm("r1") = info; |
107 register void* arg2 asm("r2") = context_; | 105 register void* arg2 asm("r2") = context_; |
108 asm volatile("bx %3" | 106 asm volatile("bx %3" |
109 : | 107 : |
110 : "r"(arg0), "r"(arg1), "r"(arg2), "r"(action) | 108 : "r"(arg0), "r"(arg1), "r"(arg2), "r"(action) |
111 : "memory"); | 109 : "memory"); |
112 } | 110 } |
113 #endif // defined(USE_SIGNAL_HANDLER_TRAMPOLINE) | 111 #endif // defined(USE_SIGNAL_HANDLER_TRAMPOLINE) |
114 }; | 112 }; |
115 | 113 |
116 | |
117 #undef USE_SIGNAL_HANDLER_TRAMPOLINE | 114 #undef USE_SIGNAL_HANDLER_TRAMPOLINE |
118 | 115 |
119 | |
120 } // namespace dart | 116 } // namespace dart |
121 | 117 |
122 #endif // RUNTIME_VM_SIGNAL_HANDLER_H_ | 118 #endif // RUNTIME_VM_SIGNAL_HANDLER_H_ |
OLD | NEW |