Skip to content

Commit 218b520

Browse files
committed
[PR] david - get rid of scoped enabler, macro, simplify interface
1 parent 5f91c56 commit 218b520

File tree

3 files changed

+14
-93
lines changed

3 files changed

+14
-93
lines changed

compiler-rt/include/sanitizer/rtsan_interface.h

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -24,59 +24,18 @@
2424
extern "C" {
2525
#endif // __cplusplus
2626

27-
// Initializes rtsan if it has not been initialized yet.
28-
// Used by the RTSan runtime to ensure that rtsan is initialized before any
29-
// other rtsan functions are called.
30-
void SANITIZER_CDECL __rtsan_ensure_initialized();
31-
32-
// Enter real-time context.
33-
// When in a real-time context, RTSan interceptors will error if realtime
34-
// violations are detected. Calls to this method are injected at the code
35-
// generation stage when RTSan is enabled.
36-
void SANITIZER_CDECL __rtsan_realtime_enter();
37-
38-
// Exit the real-time context.
39-
// When not in a real-time context, RTSan interceptors will simply forward
40-
// intercepted method calls to the real methods.
41-
void SANITIZER_CDECL __rtsan_realtime_exit();
42-
4327
// Disable all RTSan error reporting.
4428
void SANITIZER_CDECL __rtsan_disable(void);
4529

4630
// Re-enable all RTSan error reporting.
4731
// The counterpart to `__rtsan_disable`.
4832
void SANITIZER_CDECL __rtsan_enable(void);
4933

50-
// Expect that the next call to a function with the given name will not be
51-
// called from a realtime context.
52-
void SANITIZER_CDECL
53-
__rtsan_expect_not_realtime(const char *intercepted_function_name);
54-
5534
#ifdef __cplusplus
5635
} // extern "C"
5736

5837
namespace __rtsan {
59-
#if (defined(__has_feature) && __has_feature(realtime_sanitizer)) || \
60-
SANITIZE_REALTIME
61-
62-
void Initialize() { __rtsan_ensure_initialized(); }
63-
64-
class ScopedEnabler {
65-
public:
66-
ScopedEnabler() { __rtsan_realtime_enter(); }
67-
~ScopedEnabler() { __rtsan_realtime_exit(); }
68-
69-
#if __cplusplus >= 201103L
70-
ScopedEnabler(const ScopedEnabler &) = delete;
71-
ScopedEnabler &operator=(const ScopedEnabler &) = delete;
72-
ScopedEnabler(ScopedEnabler &&) = delete;
73-
ScopedEnabler &operator=(ScopedEnabler &&) = delete;
74-
#else
75-
private:
76-
ScopedEnabler(const ScopedEnabler &);
77-
ScopedEnabler &operator=(const ScopedEnabler &);
78-
#endif // __cplusplus >= 201103L
79-
};
38+
#if defined(__has_feature) && __has_feature(realtime_sanitizer)
8039

8140
class ScopedDisabler {
8241
public:
@@ -97,20 +56,12 @@ class ScopedDisabler {
9756

9857
#else // doesn't have realtime_sanitizer
9958

100-
void Initialize() {}
101-
102-
class ScopedEnabler {
103-
public:
104-
ScopedEnabler() {}
105-
};
106-
10759
class ScopedDisabler {
10860
public:
10961
ScopedDisabler() {}
11062
};
11163

112-
#endif // (defined(__has_feature) && __has_feature(realtime_sanitizer)) ||
113-
// SANITIZE_REALTIME
64+
#endif // defined(__has_feature) && __has_feature(realtime_sanitizer)
11465
} // namespace __rtsan
11566
#endif // __cplusplus
11667

compiler-rt/lib/rtsan/rtsan.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,22 @@ extern "C" {
1818
// A call to this method is added to the preinit array on Linux systems.
1919
SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_init();
2020

21-
// See documentation in rtsan_interface.h.
21+
// Initializes rtsan if it has not been initialized yet.
22+
// Used by the RTSan runtime to ensure that rtsan is initialized before any
23+
// other rtsan functions are called.
2224
SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_ensure_initialized();
2325

2426
SANITIZER_INTERFACE_ATTRIBUTE bool __rtsan_is_initialized();
2527

26-
// See documentation in rtsan_interface.h.
28+
// Enter real-time context.
29+
// When in a real-time context, RTSan interceptors will error if realtime
30+
// violations are detected. Calls to this method are injected at the code
31+
// generation stage when RTSan is enabled.
2732
SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_realtime_enter();
2833

29-
// See documentation in rtsan_interface.h.
34+
// Exit the real-time context.
35+
// When not in a real-time context, RTSan interceptors will simply forward
36+
// intercepted method calls to the real methods.
3037
SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_realtime_exit();
3138

3239
// See documentation in rtsan_interface.h.
@@ -35,7 +42,8 @@ SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_disable();
3542
// See documentation in rtsan_interface.h.
3643
SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_enable();
3744

38-
// See documentation in rtsan_interface.h.
45+
// Expect that the next call to a function with the given name will not be
46+
// called from a realtime context.
3947
SANITIZER_INTERFACE_ATTRIBUTE void
4048
__rtsan_expect_not_realtime(const char *intercepted_function_name);
4149

compiler-rt/test/rtsan/enabler.cpp

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)