match_asm_constraints: Use copy_rtx where needed (PR88001)
[official-gcc.git] / libsanitizer / tsan / tsan_interceptors.h
blob959a39465e33d2a5c294c8ea43140c8900f76781
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 void EnableIgnores();
15 private:
16 ThreadState *const thr_;
17 const uptr pc_;
18 bool in_ignored_lib_;
19 bool ignoring_;
22 LibIgnore *libignore();
24 } // namespace __tsan
26 #define SCOPED_INTERCEPTOR_RAW(func, ...) \
27 ThreadState *thr = cur_thread(); \
28 const uptr caller_pc = GET_CALLER_PC(); \
29 ScopedInterceptor si(thr, #func, caller_pc); \
30 const uptr pc = StackTrace::GetCurrentPc(); \
31 (void)pc; \
32 /**/
34 #define SCOPED_TSAN_INTERCEPTOR(func, ...) \
35 SCOPED_INTERCEPTOR_RAW(func, __VA_ARGS__); \
36 if (REAL(func) == 0) { \
37 Report("FATAL: ThreadSanitizer: failed to intercept %s\n", #func); \
38 Die(); \
39 } \
40 if (!thr->is_inited || thr->ignore_interceptors || thr->in_ignored_lib) \
41 return REAL(func)(__VA_ARGS__); \
42 /**/
44 #define SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START() \
45 si.DisableIgnores();
47 #define SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_END() \
48 si.EnableIgnores();
50 #define TSAN_INTERCEPTOR(ret, func, ...) INTERCEPTOR(ret, func, __VA_ARGS__)
52 #if SANITIZER_NETBSD
53 # define TSAN_INTERCEPTOR_NETBSD_ALIAS(ret, func, ...) \
54 TSAN_INTERCEPTOR(ret, __libc_##func, __VA_ARGS__) \
55 ALIAS(WRAPPER_NAME(pthread_##func));
56 # define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR(ret, func, ...) \
57 TSAN_INTERCEPTOR(ret, __libc_thr_##func, __VA_ARGS__) \
58 ALIAS(WRAPPER_NAME(pthread_##func));
59 #else
60 # define TSAN_INTERCEPTOR_NETBSD_ALIAS(ret, func, ...)
61 # define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR(ret, func, ...)
62 #endif
64 #endif // TSAN_INTERCEPTORS_H