@@ -368,17 +368,32 @@ INTERCEPTOR(void, OSSpinLockLock, volatile OSSpinLock *lock) {
368
368
return REAL (OSSpinLockLock)(lock);
369
369
}
370
370
#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
371
375
376
+ #if SANITIZER_APPLE
372
377
INTERCEPTOR (void , os_unfair_lock_lock, os_unfair_lock_t lock) {
373
378
__rtsan_notify_intercepted_call (" os_unfair_lock_lock" );
374
379
return REAL (os_unfair_lock_lock)(lock);
375
380
}
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
377
388
INTERCEPTOR (int , pthread_spin_lock, pthread_spinlock_t *spinlock) {
378
389
__rtsan_notify_intercepted_call (" pthread_spin_lock" );
379
390
return REAL (pthread_spin_lock)(spinlock);
380
391
}
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
382
397
383
398
INTERCEPTOR (int , pthread_create, pthread_t *thread, const pthread_attr_t *attr,
384
399
void *(*start_routine)(void *), void *arg) {
@@ -539,13 +554,19 @@ INTERCEPTOR(void *, memalign, size_t alignment, size_t size) {
539
554
__rtsan_notify_intercepted_call (" memalign" );
540
555
return REAL (memalign)(alignment, size);
541
556
}
557
+ #define RTSAN_MAYBE_INTERCEPT_MEMALIGN INTERCEPT_FUNCTION (memalign)
558
+ #else
559
+ #define RTSAN_MAYBE_INTERCEPT_MEMALIGN
542
560
#endif
543
561
544
562
#if SANITIZER_INTERCEPT_PVALLOC
545
563
INTERCEPTOR (void *, pvalloc, size_t size) {
546
564
__rtsan_notify_intercepted_call (" pvalloc" );
547
565
return REAL (pvalloc)(size);
548
566
}
567
+ #define RTSAN_MAYBE_INTERCEPT_PVALLOC INTERCEPT_FUNCTION (pvalloc)
568
+ #else
569
+ #define RTSAN_MAYBE_INTERCEPT_PVALLOC
549
570
#endif
550
571
551
572
INTERCEPTOR (void *, mmap, void *addr, size_t length, int prot, int flags,
@@ -783,12 +804,8 @@ void __rtsan::InitializeInterceptors() {
783
804
INTERCEPT_FUNCTION (munmap);
784
805
INTERCEPT_FUNCTION (shm_open);
785
806
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;
792
809
793
810
INTERCEPT_FUNCTION (open);
794
811
RTSAN_MAYBE_INTERCEPT_OPEN64;
@@ -820,12 +837,9 @@ void __rtsan::InitializeInterceptors() {
820
837
INTERCEPT_FUNCTION (dup2);
821
838
INTERCEPT_FUNCTION (ioctl);
822
839
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;
829
843
830
844
INTERCEPT_FUNCTION (pthread_create);
831
845
INTERCEPT_FUNCTION (pthread_mutex_lock);
0 commit comments