Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / mfbt / LinuxSignal.h
blob9b8e1bbbbe02785d52bd133b9c4500a6d93104e2
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_LinuxSignal_h
6 #define mozilla_LinuxSignal_h
8 namespace mozilla {
10 #if defined(__arm__)
12 // Some (old) Linux kernels on ARM have a bug where a signal handler
13 // can be called without clearing the IT bits in CPSR first. The result
14 // is that the first few instructions of the handler could be skipped,
15 // ultimately resulting in crashes. To workaround this bug, the handler
16 // on ARM is a trampoline that starts with enough NOP instructions, so
17 // that even if the IT bits are not cleared, only the NOP instructions
18 // will be skipped over.
20 template <void (*H)(int, siginfo_t*, void*)>
21 __attribute__((naked)) void
22 SignalTrampoline(int aSignal, siginfo_t* aInfo, void* aContext)
24 asm volatile (
25 "nop; nop; nop; nop"
26 : : : "memory");
28 // Because the assembler may generate additional insturctions below, we
29 // need to ensure NOPs are inserted first by separating them out above.
31 asm volatile (
32 "bx %0"
34 : "r"(H), "l"(aSignal), "l"(aInfo), "l"(aContext)
35 : "memory");
38 # define MOZ_SIGNAL_TRAMPOLINE(h) (mozilla::SignalTrampoline<h>)
40 #else // __arm__
42 # define MOZ_SIGNAL_TRAMPOLINE(h) (h)
44 #endif // __arm__
46 } // namespace mozilla
48 #endif // mozilla_LinuxSignal_h