Consistently use "rG" constraint for copy instruction in move patterns
[official-gcc.git] / libsanitizer / tsan / tsan_interceptors.h
blob89b2f990d036f2605fe2607f2bda82db43fb8a44
1 #ifndef TSAN_INTERCEPTORS_H
2 #define TSAN_INTERCEPTORS_H
4 #include "sanitizer_common/sanitizer_stacktrace.h"
5 #include "tsan_rtl.h"
7 namespace __tsan {
9 class ScopedInterceptor {
10 public:
11 ScopedInterceptor(ThreadState *thr, const char *fname, uptr pc);
12 ~ScopedInterceptor();
13 void DisableIgnores() {
14 if (UNLIKELY(ignoring_))
15 DisableIgnoresImpl();
17 void EnableIgnores() {
18 if (UNLIKELY(ignoring_))
19 EnableIgnoresImpl();
22 private:
23 ThreadState *const thr_;
24 bool in_ignored_lib_;
25 bool ignoring_;
27 void DisableIgnoresImpl();
28 void EnableIgnoresImpl();
31 LibIgnore *libignore();
33 #if !SANITIZER_GO
34 inline bool in_symbolizer() {
35 return UNLIKELY(cur_thread_init()->in_symbolizer);
37 #endif
39 } // namespace __tsan
41 #define SCOPED_INTERCEPTOR_RAW(func, ...) \
42 ThreadState *thr = cur_thread_init(); \
43 const uptr caller_pc = GET_CALLER_PC(); \
44 ScopedInterceptor si(thr, #func, caller_pc); \
45 const uptr pc = GET_CURRENT_PC(); \
46 (void)pc;
48 #define SCOPED_TSAN_INTERCEPTOR(func, ...) \
49 SCOPED_INTERCEPTOR_RAW(func, __VA_ARGS__); \
50 if (REAL(func) == 0) { \
51 Report("FATAL: ThreadSanitizer: failed to intercept %s\n", #func); \
52 Die(); \
53 } \
54 if (!thr->is_inited || thr->ignore_interceptors || thr->in_ignored_lib) \
55 return REAL(func)(__VA_ARGS__);
57 #define SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START() \
58 si.DisableIgnores();
60 #define SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_END() \
61 si.EnableIgnores();
63 #define TSAN_INTERCEPTOR(ret, func, ...) INTERCEPTOR(ret, func, __VA_ARGS__)
65 #if SANITIZER_NETBSD
66 # define TSAN_INTERCEPTOR_NETBSD_ALIAS(ret, func, ...) \
67 TSAN_INTERCEPTOR(ret, __libc_##func, __VA_ARGS__) \
68 ALIAS(WRAPPER_NAME(pthread_##func));
69 # define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR(ret, func, ...) \
70 TSAN_INTERCEPTOR(ret, __libc_thr_##func, __VA_ARGS__) \
71 ALIAS(WRAPPER_NAME(pthread_##func));
72 # define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR2(ret, func, func2, ...) \
73 TSAN_INTERCEPTOR(ret, __libc_thr_##func, __VA_ARGS__) \
74 ALIAS(WRAPPER_NAME(pthread_##func2));
75 #else
76 # define TSAN_INTERCEPTOR_NETBSD_ALIAS(ret, func, ...)
77 # define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR(ret, func, ...)
78 # define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR2(ret, func, func2, ...)
79 #endif
81 #endif // TSAN_INTERCEPTORS_H