@@ -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
372377INTERCEPTOR (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
377388INTERCEPTOR (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
383398INTERCEPTOR (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
545563INTERCEPTOR (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
551572INTERCEPTOR (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