[CMake] Respect CMAKE_CXX_FLAGS in custom clang_compile commands
[blocksruntime.git] / lib / asan / asan_interceptors.h
blobecdf1f0262cb2e1a2f6bf79b5ad6cadcbc84bcfc
1 //===-- asan_interceptors.h -------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of AddressSanitizer, an address sanity checker.
12 // ASan-private header for asan_interceptors.cc
13 //===----------------------------------------------------------------------===//
14 #ifndef ASAN_INTERCEPTORS_H
15 #define ASAN_INTERCEPTORS_H
17 #include "asan_internal.h"
18 #include "sanitizer_common/sanitizer_interception.h"
19 #include "sanitizer_common/sanitizer_platform_interceptors.h"
21 // Use macro to describe if specific function should be
22 // intercepted on a given platform.
23 #if !SANITIZER_WINDOWS
24 # define ASAN_INTERCEPT_ATOLL_AND_STRTOLL 1
25 # define ASAN_INTERCEPT__LONGJMP 1
26 # define ASAN_INTERCEPT_STRDUP 1
27 # define ASAN_INTERCEPT_INDEX 1
28 # define ASAN_INTERCEPT_PTHREAD_CREATE 1
29 # define ASAN_INTERCEPT_MLOCKX 1
30 #else
31 # define ASAN_INTERCEPT_ATOLL_AND_STRTOLL 0
32 # define ASAN_INTERCEPT__LONGJMP 0
33 # define ASAN_INTERCEPT_STRDUP 0
34 # define ASAN_INTERCEPT_INDEX 0
35 # define ASAN_INTERCEPT_PTHREAD_CREATE 0
36 # define ASAN_INTERCEPT_MLOCKX 0
37 #endif
39 #if SANITIZER_FREEBSD || SANITIZER_LINUX
40 # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 1
41 #else
42 # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 0
43 #endif
45 #if !SANITIZER_MAC
46 # define ASAN_INTERCEPT_STRNLEN 1
47 #else
48 # define ASAN_INTERCEPT_STRNLEN 0
49 #endif
51 #if SANITIZER_LINUX && !SANITIZER_ANDROID
52 # define ASAN_INTERCEPT_SWAPCONTEXT 1
53 #else
54 # define ASAN_INTERCEPT_SWAPCONTEXT 0
55 #endif
57 #if !SANITIZER_WINDOWS
58 # define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 1
59 #else
60 # define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 0
61 #endif
63 #if !SANITIZER_WINDOWS
64 # define ASAN_INTERCEPT_SIGLONGJMP 1
65 #else
66 # define ASAN_INTERCEPT_SIGLONGJMP 0
67 #endif
69 #if ASAN_HAS_EXCEPTIONS && !SANITIZER_WINDOWS
70 # define ASAN_INTERCEPT___CXA_THROW 1
71 #else
72 # define ASAN_INTERCEPT___CXA_THROW 0
73 #endif
75 #if !SANITIZER_WINDOWS
76 # define ASAN_INTERCEPT___CXA_ATEXIT 1
77 #else
78 # define ASAN_INTERCEPT___CXA_ATEXIT 0
79 #endif
81 DECLARE_REAL(int, memcmp, const void *a1, const void *a2, uptr size)
82 DECLARE_REAL(void*, memcpy, void *to, const void *from, uptr size)
83 DECLARE_REAL(void*, memset, void *block, int c, uptr size)
84 DECLARE_REAL(char*, strchr, const char *str, int c)
85 DECLARE_REAL(uptr, strlen, const char *s)
86 DECLARE_REAL(char*, strncpy, char *to, const char *from, uptr size)
87 DECLARE_REAL(uptr, strnlen, const char *s, uptr maxlen)
88 DECLARE_REAL(char*, strstr, const char *s1, const char *s2)
89 struct sigaction;
90 DECLARE_REAL(int, sigaction, int signum, const struct sigaction *act,
91 struct sigaction *oldact)
93 namespace __asan {
95 void InitializeAsanInterceptors();
97 #define ENSURE_ASAN_INITED() do { \
98 CHECK(!asan_init_is_running); \
99 if (!asan_inited) { \
100 AsanInitFromRtl(); \
102 } while (0)
104 } // namespace __asan
106 #endif // ASAN_INTERCEPTORS_H