|
21 | 21 | #include "rtsan/rtsan.h"
|
22 | 22 |
|
23 | 23 | #if SANITIZER_APPLE
|
24 |
| - |
25 |
| -#if TARGET_OS_MAC |
26 |
| -// On MacOS OSSpinLockLock is deprecated and no longer present in the headers, |
27 |
| -// but the symbol still exists on the system. Forward declare here so we |
28 |
| -// don't get compilation errors. |
29 |
| -#include <stdint.h> |
30 |
| -extern "C" { |
31 |
| -typedef int32_t OSSpinLock; |
32 |
| -void OSSpinLockLock(volatile OSSpinLock *__lock); |
33 |
| -// A pointer to this type is in the interface for `_os_nospin_lock_lock`, but |
34 |
| -// it's an internal implementation detail of `os/lock.c` on Darwin, and |
35 |
| -// therefore not available in any headers. As a workaround, we forward declare |
36 |
| -// it here, which is enough to facilitate interception of _os_nospin_lock_lock. |
37 |
| -struct _os_nospin_lock_s; |
38 |
| -using _os_nospin_lock_t = _os_nospin_lock_s *; |
39 |
| -} |
40 |
| -#endif // TARGET_OS_MAC |
41 |
| - |
42 | 24 | #include <libkern/OSAtomic.h>
|
43 | 25 | #include <os/lock.h>
|
44 | 26 | #endif // SANITIZER_APPLE
|
@@ -706,26 +688,34 @@ INTERCEPTOR(mode_t, umask, mode_t cmask) {
|
706 | 688 | #pragma clang diagnostic push
|
707 | 689 | // OSSpinLockLock is deprecated, but still in use in libc++
|
708 | 690 | #pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
| 691 | +#undef OSSpinLockLock |
| 692 | + |
709 | 693 | INTERCEPTOR(void, OSSpinLockLock, volatile OSSpinLock *lock) {
|
710 | 694 | __rtsan_notify_intercepted_call("OSSpinLockLock");
|
711 | 695 | return REAL(OSSpinLockLock)(lock);
|
712 | 696 | }
|
713 |
| -#pragma clang diagnostic pop |
| 697 | + |
714 | 698 | #define RTSAN_MAYBE_INTERCEPT_OSSPINLOCKLOCK INTERCEPT_FUNCTION(OSSpinLockLock)
|
715 | 699 | #else
|
716 | 700 | #define RTSAN_MAYBE_INTERCEPT_OSSPINLOCKLOCK
|
717 | 701 | #endif // SANITIZER_APPLE
|
718 | 702 |
|
719 | 703 | #if SANITIZER_APPLE
|
720 |
| -INTERCEPTOR(void, os_unfair_lock_lock, os_unfair_lock_t lock) { |
721 |
| - __rtsan_notify_intercepted_call("os_unfair_lock_lock"); |
722 |
| - return REAL(os_unfair_lock_lock)(lock); |
723 |
| -} |
| 704 | +typedef volatile OSSpinLock *_os_nospin_lock_t; |
724 | 705 |
|
725 | 706 | INTERCEPTOR(void, _os_nospin_lock_lock, _os_nospin_lock_t lock) {
|
726 | 707 | __rtsan_notify_intercepted_call("_os_nospin_lock_lock");
|
727 | 708 | return REAL(_os_nospin_lock_lock)(lock);
|
728 | 709 | }
|
| 710 | +#endif // SANITIZER_APPLE |
| 711 | +#pragma clang diagnostic pop // "-Wdeprecated-declarations" |
| 712 | + |
| 713 | +#if SANITIZER_APPLE |
| 714 | +INTERCEPTOR(void, os_unfair_lock_lock, os_unfair_lock_t lock) { |
| 715 | + __rtsan_notify_intercepted_call("os_unfair_lock_lock"); |
| 716 | + return REAL(os_unfair_lock_lock)(lock); |
| 717 | +} |
| 718 | + |
729 | 719 | #define RTSAN_MAYBE_INTERCEPT_OS_UNFAIR_LOCK_LOCK \
|
730 | 720 | INTERCEPT_FUNCTION(os_unfair_lock_lock)
|
731 | 721 | #else
|
|
0 commit comments