ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
[gcc.git] / libsanitizer / sanitizer_common / sanitizer_signal_interceptors.inc
1 //===-- sanitizer_signal_interceptors.inc -----------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // Signal interceptors for sanitizers.
9 //
10 //===----------------------------------------------------------------------===//
11
12 #include "interception/interception.h"
13 #include "sanitizer_common.h"
14 #include "sanitizer_internal_defs.h"
15 #include "sanitizer_platform_interceptors.h"
16
17 using namespace __sanitizer;
18
19 #if SANITIZER_INTERCEPT_BSD_SIGNAL
20 INTERCEPTOR(void *, bsd_signal, int signum, void *handler) {
21 if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return 0;
22 return REAL(bsd_signal)(signum, handler);
23 }
24 #define INIT_BSD_SIGNAL COMMON_INTERCEPT_FUNCTION(bsd_signal)
25 #else // SANITIZER_INTERCEPT_BSD_SIGNAL
26 #define INIT_BSD_SIGNAL
27 #endif // SANITIZER_INTERCEPT_BSD_SIGNAL
28
29 #if SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION
30 INTERCEPTOR(void *, signal, int signum, void *handler) {
31 if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return nullptr;
32 return REAL(signal)(signum, handler);
33 }
34 #define INIT_SIGNAL COMMON_INTERCEPT_FUNCTION(signal)
35
36 INTERCEPTOR(int, sigaction, int signum, const struct sigaction *act,
37 struct sigaction *oldact) {
38 if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return 0;
39 return REAL(sigaction)(signum, act, oldact);
40 }
41 #define INIT_SIGACTION COMMON_INTERCEPT_FUNCTION(sigaction)
42
43 namespace __sanitizer {
44 int real_sigaction(int signum, const void *act, void *oldact) {
45 return REAL(sigaction)(signum, (const struct sigaction *)act,
46 (struct sigaction *)oldact);
47 }
48 } // namespace __sanitizer
49 #else // SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION
50 #define INIT_SIGNAL
51 #define INIT_SIGACTION
52 // We need to have defined REAL(sigaction) on other systems.
53 DEFINE_REAL(int, sigaction, int signum, const struct sigaction *act,
54 struct sigaction *oldact)
55 #endif // SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION
56
57 static void InitializeSignalInterceptors() {
58 static bool was_called_once;
59 CHECK(!was_called_once);
60 was_called_once = true;
61
62 INIT_BSD_SIGNAL;
63 INIT_SIGNAL;
64 INIT_SIGACTION;
65 }