Skip to content

Commit f28e071

Browse files
authored
[rtsan] NFC: Fix style of some interceptors not using MAYBE (#118145)
There were a few interceptors that weren't using the newer MAYBE style - fixed them up for uniform style.
1 parent 666de79 commit f28e071

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -368,17 +368,32 @@ INTERCEPTOR(void, OSSpinLockLock, volatile OSSpinLock *lock) {
368368
return REAL(OSSpinLockLock)(lock);
369369
}
370370
#pragma clang diagnostic pop
371+
#define RTSAN_MAYBE_INTERCEPT_OSSPINLOCKLOCK INTERCEPT_FUNCTION(OSSpinLockLock)
372+
#else
373+
#define RTSAN_MAYBE_INTERCEPT_OSSPINLOCKLOCK
374+
#endif // SANITIZER_APPLE
371375

376+
#if SANITIZER_APPLE
372377
INTERCEPTOR(void, os_unfair_lock_lock, os_unfair_lock_t lock) {
373378
__rtsan_notify_intercepted_call("os_unfair_lock_lock");
374379
return REAL(os_unfair_lock_lock)(lock);
375380
}
376-
#elif SANITIZER_LINUX
381+
#define RTSAN_MAYBE_INTERCEPT_OS_UNFAIR_LOCK_LOCK \
382+
INTERCEPT_FUNCTION(os_unfair_lock_lock)
383+
#else
384+
#define RTSAN_MAYBE_INTERCEPT_OS_UNFAIR_LOCK_LOCK
385+
#endif // SANITIZER_APPLE
386+
387+
#if SANITIZER_LINUX
377388
INTERCEPTOR(int, pthread_spin_lock, pthread_spinlock_t *spinlock) {
378389
__rtsan_notify_intercepted_call("pthread_spin_lock");
379390
return REAL(pthread_spin_lock)(spinlock);
380391
}
381-
#endif
392+
#define RTSAN_MAYBE_INTERCEPT_PTHREAD_SPIN_LOCK \
393+
INTERCEPT_FUNCTION(pthread_spin_lock)
394+
#else
395+
#define RTSAN_MAYBE_INTERCEPT_PTHREAD_SPIN_LOCK
396+
#endif // SANITIZER_LINUX
382397

383398
INTERCEPTOR(int, pthread_create, pthread_t *thread, const pthread_attr_t *attr,
384399
void *(*start_routine)(void *), void *arg) {
@@ -539,13 +554,19 @@ INTERCEPTOR(void *, memalign, size_t alignment, size_t size) {
539554
__rtsan_notify_intercepted_call("memalign");
540555
return REAL(memalign)(alignment, size);
541556
}
557+
#define RTSAN_MAYBE_INTERCEPT_MEMALIGN INTERCEPT_FUNCTION(memalign)
558+
#else
559+
#define RTSAN_MAYBE_INTERCEPT_MEMALIGN
542560
#endif
543561

544562
#if SANITIZER_INTERCEPT_PVALLOC
545563
INTERCEPTOR(void *, pvalloc, size_t size) {
546564
__rtsan_notify_intercepted_call("pvalloc");
547565
return REAL(pvalloc)(size);
548566
}
567+
#define RTSAN_MAYBE_INTERCEPT_PVALLOC INTERCEPT_FUNCTION(pvalloc)
568+
#else
569+
#define RTSAN_MAYBE_INTERCEPT_PVALLOC
549570
#endif
550571

551572
INTERCEPTOR(void *, mmap, void *addr, size_t length, int prot, int flags,
@@ -783,12 +804,8 @@ void __rtsan::InitializeInterceptors() {
783804
INTERCEPT_FUNCTION(munmap);
784805
INTERCEPT_FUNCTION(shm_open);
785806
INTERCEPT_FUNCTION(shm_unlink);
786-
#if SANITIZER_INTERCEPT_MEMALIGN
787-
INTERCEPT_FUNCTION(memalign);
788-
#endif
789-
#if SANITIZER_INTERCEPT_PVALLOC
790-
INTERCEPT_FUNCTION(pvalloc);
791-
#endif
807+
RTSAN_MAYBE_INTERCEPT_MEMALIGN;
808+
RTSAN_MAYBE_INTERCEPT_PVALLOC;
792809

793810
INTERCEPT_FUNCTION(open);
794811
RTSAN_MAYBE_INTERCEPT_OPEN64;
@@ -820,12 +837,9 @@ void __rtsan::InitializeInterceptors() {
820837
INTERCEPT_FUNCTION(dup2);
821838
INTERCEPT_FUNCTION(ioctl);
822839

823-
#if SANITIZER_APPLE
824-
INTERCEPT_FUNCTION(OSSpinLockLock);
825-
INTERCEPT_FUNCTION(os_unfair_lock_lock);
826-
#elif SANITIZER_LINUX
827-
INTERCEPT_FUNCTION(pthread_spin_lock);
828-
#endif
840+
RTSAN_MAYBE_INTERCEPT_OSSPINLOCKLOCK;
841+
RTSAN_MAYBE_INTERCEPT_OS_UNFAIR_LOCK_LOCK;
842+
RTSAN_MAYBE_INTERCEPT_PTHREAD_SPIN_LOCK;
829843

830844
INTERCEPT_FUNCTION(pthread_create);
831845
INTERCEPT_FUNCTION(pthread_mutex_lock);

0 commit comments

Comments
 (0)