* lto.c (do_stream_out): Add PART parameter; open dump file.
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_signal_interceptors.inc
blobb278f82ce03f309da994030b798326b153aa52f3
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 //===----------------------------------------------------------------------===//
12 #include "interception/interception.h"
13 #include "sanitizer_common.h"
14 #include "sanitizer_internal_defs.h"
15 #include "sanitizer_platform_interceptors.h"
17 using namespace __sanitizer;
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);
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
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);
34 #define INIT_SIGNAL COMMON_INTERCEPT_FUNCTION(signal)
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);
41 #define INIT_SIGACTION COMMON_INTERCEPT_FUNCTION(sigaction)
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);
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
57 static void InitializeSignalInterceptors() {
58   static bool was_called_once;
59   CHECK(!was_called_once);
60   was_called_once = true;
62   INIT_BSD_SIGNAL;
63   INIT_SIGNAL;
64   INIT_SIGACTION;