25
25
# include " tsan_interceptors.h"
26
26
# include " tsan_interface.h"
27
27
# include " tsan_interface_ann.h"
28
- # include " tsan_spinlock_defs_mac.h"
29
28
30
29
# if defined(__has_include) && __has_include(<xpc/xpc.h>)
31
30
# include < xpc/xpc.h>
@@ -96,8 +95,7 @@ static constexpr morder kMacFailureOrder = mo_relaxed;
96
95
m_orig (int32_t , uint32_t , a32, f##32 ##OrigBarrier, \
97
96
__tsan_atomic32_##tsan_atomic_f, kMacOrderBarrier )
98
97
99
- # pragma clang diagnostic push
100
- // OSAtomic* functions are deprecated.
98
+ # pragma clang diagnostic push // OSAtomic* deprecation
101
99
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
102
100
OSATOMIC_INTERCEPTORS_ARITHMETIC (OSAtomicAdd, fetch_add,
103
101
OSATOMIC_INTERCEPTOR_PLUS_X)
@@ -111,6 +109,7 @@ OSATOMIC_INTERCEPTORS_BITWISE(OSAtomicAnd, fetch_and,
111
109
OSATOMIC_INTERCEPTOR_PLUS_X, OSATOMIC_INTERCEPTOR)
112
110
OSATOMIC_INTERCEPTORS_BITWISE (OSAtomicXor, fetch_xor,
113
111
OSATOMIC_INTERCEPTOR_PLUS_X, OSATOMIC_INTERCEPTOR)
112
+ # pragma clang diagnostic pop // OSAtomic* deprecation
114
113
115
114
# define OSATOMIC_INTERCEPTORS_CAS (f, tsan_atomic_f, tsan_t, t ) \
116
115
TSAN_INTERCEPTOR (bool , f, t old_value, t new_value, t volatile *ptr) { \
@@ -128,8 +127,7 @@ OSATOMIC_INTERCEPTORS_BITWISE(OSAtomicXor, fetch_xor,
128
127
kMacOrderBarrier , kMacFailureOrder ); \
129
128
}
130
129
131
- # pragma clang diagnostic push
132
- // OSAtomicCompareAndSwap* functions are deprecated.
130
+ # pragma clang diagnostic push // OSAtomicCompareAndSwap* deprecation
133
131
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
134
132
OSATOMIC_INTERCEPTORS_CAS (OSAtomicCompareAndSwapInt, __tsan_atomic32, a32, int )
135
133
OSATOMIC_INTERCEPTORS_CAS (OSAtomicCompareAndSwapLong, __tsan_atomic64, a64,
@@ -140,7 +138,7 @@ OSATOMIC_INTERCEPTORS_CAS(OSAtomicCompareAndSwap32, __tsan_atomic32, a32,
140
138
int32_t )
141
139
OSATOMIC_INTERCEPTORS_CAS (OSAtomicCompareAndSwap64, __tsan_atomic64, a64,
142
140
int64_t )
143
- # pragma clang diagnostic pop
141
+ # pragma clang diagnostic pop // OSAtomicCompareAndSwap* deprecation
144
142
145
143
# define OSATOMIC_INTERCEPTOR_BITOP (f, op, clear, mo ) \
146
144
TSAN_INTERCEPTOR (bool , f, uint32_t n, volatile void *ptr) { \
@@ -156,9 +154,12 @@ OSATOMIC_INTERCEPTORS_CAS(OSAtomicCompareAndSwap64, __tsan_atomic64, a64,
156
154
OSATOMIC_INTERCEPTOR_BITOP (f, op, clear, kMacOrderNonBarrier ) \
157
155
OSATOMIC_INTERCEPTOR_BITOP (f##Barrier, op, clear, kMacOrderBarrier )
158
156
157
+ # pragma clang diagnostic push // OSAtomicTestAnd* deprecation
158
+ # pragma clang diagnostic ignored "-Wdeprecated-declarations"
159
159
OSATOMIC_INTERCEPTORS_BITOP (OSAtomicTestAndSet, __tsan_atomic8_fetch_or, false )
160
160
OSATOMIC_INTERCEPTORS_BITOP (OSAtomicTestAndClear, __tsan_atomic8_fetch_and,
161
161
true )
162
+ # pragma clang diagnostic pop // OSAtomicTestAnd* deprecation
162
163
163
164
TSAN_INTERCEPTOR (void , OSAtomicEnqueue, OSQueueHead *list, void *item,
164
165
size_t offset) {
@@ -196,6 +197,16 @@ TSAN_INTERCEPTOR(void *, OSAtomicFifoDequeue, OSFifoQueueHead *list,
196
197
197
198
# endif
198
199
200
+ // If `OSSPINLOCK_USE_INLINED=1` is set, then SDK headers don't declare these
201
+ // as functions, but macros that call non-deprecated APIs. Undefine these
202
+ // macros so they don't interfere with the interceptor machinery.
203
+ # undef OSSpinLockLock
204
+ # undef OSSpinLockTry
205
+ # undef OSSpinLockUnlock
206
+
207
+ # pragma clang diagnostic push // OSSpinLock* deprecation
208
+ # pragma clang diagnostic ignored "-Wdeprecated-declarations"
209
+
199
210
TSAN_INTERCEPTOR (void , OSSpinLockLock, volatile OSSpinLock *lock) {
200
211
CHECK (!cur_thread ()->is_dead );
201
212
if (!cur_thread ()->is_inited ) {
@@ -227,6 +238,7 @@ TSAN_INTERCEPTOR(void, OSSpinLockUnlock, volatile OSSpinLock *lock) {
227
238
Release (thr, pc, (uptr)lock);
228
239
REAL (OSSpinLockUnlock)(lock);
229
240
}
241
+ # pragma clang diagnostic pop // OSSpinLock* deprecation
230
242
231
243
TSAN_INTERCEPTOR (void , os_lock_lock, void *lock) {
232
244
CHECK (!cur_thread ()->is_dead );
0 commit comments