@@ -57,19 +57,12 @@ struct DlsymAlloc : public DlSymAllocator<DlsymAlloc> {
57
57
};
58
58
} // namespace
59
59
60
- void ExpectNotRealtime (const char *intercepted_function_name) {
61
- __rtsan_ensure_initialized ();
62
-
63
- __rtsan::GetContextForThisThread ().ExpectNotRealtime (
64
- intercepted_function_name);
65
- }
66
-
67
60
// Filesystem
68
61
69
62
INTERCEPTOR (int , open, const char *path, int oflag, ...) {
70
63
// TODO Establish whether we should intercept here if the flag contains
71
64
// O_NONBLOCK
72
- ExpectNotRealtime (" open" );
65
+ __rtsan_expect_not_realtime (" open" );
73
66
74
67
va_list args;
75
68
va_start (args, oflag);
@@ -83,7 +76,7 @@ INTERCEPTOR(int, open, const char *path, int oflag, ...) {
83
76
INTERCEPTOR (int , openat, int fd, const char *path, int oflag, ...) {
84
77
// TODO Establish whether we should intercept here if the flag contains
85
78
// O_NONBLOCK
86
- ExpectNotRealtime (" openat" );
79
+ __rtsan_expect_not_realtime (" openat" );
87
80
88
81
va_list args;
89
82
va_start (args, oflag);
@@ -97,13 +90,13 @@ INTERCEPTOR(int, openat, int fd, const char *path, int oflag, ...) {
97
90
INTERCEPTOR (int , creat, const char *path, mode_t mode) {
98
91
// TODO Establish whether we should intercept here if the flag contains
99
92
// O_NONBLOCK
100
- ExpectNotRealtime (" creat" );
93
+ __rtsan_expect_not_realtime (" creat" );
101
94
const int result = REAL (creat)(path, mode);
102
95
return result;
103
96
}
104
97
105
98
INTERCEPTOR (int , fcntl, int filedes, int cmd, ...) {
106
- ExpectNotRealtime (" fcntl" );
99
+ __rtsan_expect_not_realtime (" fcntl" );
107
100
108
101
va_list args;
109
102
va_start (args, cmd);
@@ -124,71 +117,71 @@ INTERCEPTOR(int, fcntl, int filedes, int cmd, ...) {
124
117
}
125
118
126
119
INTERCEPTOR (int , close, int filedes) {
127
- ExpectNotRealtime (" close" );
120
+ __rtsan_expect_not_realtime (" close" );
128
121
return REAL (close)(filedes);
129
122
}
130
123
131
124
INTERCEPTOR (FILE *, fopen, const char *path, const char *mode) {
132
- ExpectNotRealtime (" fopen" );
125
+ __rtsan_expect_not_realtime (" fopen" );
133
126
return REAL (fopen)(path, mode);
134
127
}
135
128
136
129
INTERCEPTOR (size_t , fread, void *ptr, size_t size, size_t nitems,
137
130
FILE *stream) {
138
- ExpectNotRealtime (" fread" );
131
+ __rtsan_expect_not_realtime (" fread" );
139
132
return REAL (fread)(ptr, size, nitems, stream);
140
133
}
141
134
142
135
INTERCEPTOR (size_t , fwrite, const void *ptr, size_t size, size_t nitems,
143
136
FILE *stream) {
144
- ExpectNotRealtime (" fwrite" );
137
+ __rtsan_expect_not_realtime (" fwrite" );
145
138
return REAL (fwrite)(ptr, size, nitems, stream);
146
139
}
147
140
148
141
INTERCEPTOR (int , fclose, FILE *stream) {
149
- ExpectNotRealtime (" fclose" );
142
+ __rtsan_expect_not_realtime (" fclose" );
150
143
return REAL (fclose)(stream);
151
144
}
152
145
153
146
INTERCEPTOR (int , fputs, const char *s, FILE *stream) {
154
- ExpectNotRealtime (" fputs" );
147
+ __rtsan_expect_not_realtime (" fputs" );
155
148
return REAL (fputs)(s, stream);
156
149
}
157
150
158
151
// Streams
159
152
INTERCEPTOR (int , puts, const char *s) {
160
- ExpectNotRealtime (" puts" );
153
+ __rtsan_expect_not_realtime (" puts" );
161
154
return REAL (puts)(s);
162
155
}
163
156
164
157
INTERCEPTOR (ssize_t , read, int fd, void *buf, size_t count) {
165
- ExpectNotRealtime (" read" );
158
+ __rtsan_expect_not_realtime (" read" );
166
159
return REAL (read)(fd, buf, count);
167
160
}
168
161
169
162
INTERCEPTOR (ssize_t , write, int fd, const void *buf, size_t count) {
170
- ExpectNotRealtime (" write" );
163
+ __rtsan_expect_not_realtime (" write" );
171
164
return REAL (write)(fd, buf, count);
172
165
}
173
166
174
167
INTERCEPTOR (ssize_t , pread, int fd, void *buf, size_t count, off_t offset) {
175
- ExpectNotRealtime (" pread" );
168
+ __rtsan_expect_not_realtime (" pread" );
176
169
return REAL (pread)(fd, buf, count, offset);
177
170
}
178
171
179
172
INTERCEPTOR (ssize_t , readv, int fd, const struct iovec *iov, int iovcnt) {
180
- ExpectNotRealtime (" readv" );
173
+ __rtsan_expect_not_realtime (" readv" );
181
174
return REAL (readv)(fd, iov, iovcnt);
182
175
}
183
176
184
177
INTERCEPTOR (ssize_t , pwrite, int fd, const void *buf, size_t count,
185
178
off_t offset) {
186
- ExpectNotRealtime (" pwrite" );
179
+ __rtsan_expect_not_realtime (" pwrite" );
187
180
return REAL (pwrite)(fd, buf, count, offset);
188
181
}
189
182
190
183
INTERCEPTOR (ssize_t , writev, int fd, const struct iovec *iov, int iovcnt) {
191
- ExpectNotRealtime (" writev" );
184
+ __rtsan_expect_not_realtime (" writev" );
192
185
return REAL (writev)(fd, iov, iovcnt);
193
186
}
194
187
@@ -198,95 +191,95 @@ INTERCEPTOR(ssize_t, writev, int fd, const struct iovec *iov, int iovcnt) {
198
191
// OSSpinLockLock is deprecated, but still in use in libc++
199
192
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
200
193
INTERCEPTOR (void , OSSpinLockLock, volatile OSSpinLock *lock) {
201
- ExpectNotRealtime (" OSSpinLockLock" );
194
+ __rtsan_expect_not_realtime (" OSSpinLockLock" );
202
195
return REAL (OSSpinLockLock)(lock);
203
196
}
204
197
#pragma clang diagnostic pop
205
198
206
199
INTERCEPTOR (void , os_unfair_lock_lock, os_unfair_lock_t lock) {
207
- ExpectNotRealtime (" os_unfair_lock_lock" );
200
+ __rtsan_expect_not_realtime (" os_unfair_lock_lock" );
208
201
return REAL (os_unfair_lock_lock)(lock);
209
202
}
210
203
#elif SANITIZER_LINUX
211
204
INTERCEPTOR (int , pthread_spin_lock, pthread_spinlock_t *spinlock) {
212
- ExpectNotRealtime (" pthread_spin_lock" );
205
+ __rtsan_expect_not_realtime (" pthread_spin_lock" );
213
206
return REAL (pthread_spin_lock)(spinlock);
214
207
}
215
208
#endif
216
209
217
210
INTERCEPTOR (int , pthread_create, pthread_t *thread, const pthread_attr_t *attr,
218
211
void *(*start_routine)(void *), void *arg) {
219
- ExpectNotRealtime (" pthread_create" );
212
+ __rtsan_expect_not_realtime (" pthread_create" );
220
213
return REAL (pthread_create)(thread, attr, start_routine, arg);
221
214
}
222
215
223
216
INTERCEPTOR (int , pthread_mutex_lock, pthread_mutex_t *mutex) {
224
- ExpectNotRealtime (" pthread_mutex_lock" );
217
+ __rtsan_expect_not_realtime (" pthread_mutex_lock" );
225
218
return REAL (pthread_mutex_lock)(mutex);
226
219
}
227
220
228
221
INTERCEPTOR (int , pthread_mutex_unlock, pthread_mutex_t *mutex) {
229
- ExpectNotRealtime (" pthread_mutex_unlock" );
222
+ __rtsan_expect_not_realtime (" pthread_mutex_unlock" );
230
223
return REAL (pthread_mutex_unlock)(mutex);
231
224
}
232
225
233
226
INTERCEPTOR (int , pthread_join, pthread_t thread, void **value_ptr) {
234
- ExpectNotRealtime (" pthread_join" );
227
+ __rtsan_expect_not_realtime (" pthread_join" );
235
228
return REAL (pthread_join)(thread, value_ptr);
236
229
}
237
230
238
231
INTERCEPTOR (int , pthread_cond_signal, pthread_cond_t *cond) {
239
- ExpectNotRealtime (" pthread_cond_signal" );
232
+ __rtsan_expect_not_realtime (" pthread_cond_signal" );
240
233
return REAL (pthread_cond_signal)(cond);
241
234
}
242
235
243
236
INTERCEPTOR (int , pthread_cond_broadcast, pthread_cond_t *cond) {
244
- ExpectNotRealtime (" pthread_cond_broadcast" );
237
+ __rtsan_expect_not_realtime (" pthread_cond_broadcast" );
245
238
return REAL (pthread_cond_broadcast)(cond);
246
239
}
247
240
248
241
INTERCEPTOR (int , pthread_cond_wait, pthread_cond_t *cond,
249
242
pthread_mutex_t *mutex) {
250
- ExpectNotRealtime (" pthread_cond_wait" );
243
+ __rtsan_expect_not_realtime (" pthread_cond_wait" );
251
244
return REAL (pthread_cond_wait)(cond, mutex);
252
245
}
253
246
254
247
INTERCEPTOR (int , pthread_cond_timedwait, pthread_cond_t *cond,
255
248
pthread_mutex_t *mutex, const timespec *ts) {
256
- ExpectNotRealtime (" pthread_cond_timedwait" );
249
+ __rtsan_expect_not_realtime (" pthread_cond_timedwait" );
257
250
return REAL (pthread_cond_timedwait)(cond, mutex, ts);
258
251
}
259
252
260
253
INTERCEPTOR (int , pthread_rwlock_rdlock, pthread_rwlock_t *lock) {
261
- ExpectNotRealtime (" pthread_rwlock_rdlock" );
254
+ __rtsan_expect_not_realtime (" pthread_rwlock_rdlock" );
262
255
return REAL (pthread_rwlock_rdlock)(lock);
263
256
}
264
257
265
258
INTERCEPTOR (int , pthread_rwlock_unlock, pthread_rwlock_t *lock) {
266
- ExpectNotRealtime (" pthread_rwlock_unlock" );
259
+ __rtsan_expect_not_realtime (" pthread_rwlock_unlock" );
267
260
return REAL (pthread_rwlock_unlock)(lock);
268
261
}
269
262
270
263
INTERCEPTOR (int , pthread_rwlock_wrlock, pthread_rwlock_t *lock) {
271
- ExpectNotRealtime (" pthread_rwlock_wrlock" );
264
+ __rtsan_expect_not_realtime (" pthread_rwlock_wrlock" );
272
265
return REAL (pthread_rwlock_wrlock)(lock);
273
266
}
274
267
275
268
// Sleeping
276
269
277
270
INTERCEPTOR (unsigned int , sleep, unsigned int s) {
278
- ExpectNotRealtime (" sleep" );
271
+ __rtsan_expect_not_realtime (" sleep" );
279
272
return REAL (sleep)(s);
280
273
}
281
274
282
275
INTERCEPTOR (int , usleep, useconds_t u) {
283
- ExpectNotRealtime (" usleep" );
276
+ __rtsan_expect_not_realtime (" usleep" );
284
277
return REAL (usleep)(u);
285
278
}
286
279
287
280
INTERCEPTOR (int , nanosleep, const struct timespec *rqtp,
288
281
struct timespec *rmtp) {
289
- ExpectNotRealtime (" nanosleep" );
282
+ __rtsan_expect_not_realtime (" nanosleep" );
290
283
return REAL (nanosleep)(rqtp, rmtp);
291
284
}
292
285
@@ -296,7 +289,7 @@ INTERCEPTOR(void *, calloc, SIZE_T num, SIZE_T size) {
296
289
if (DlsymAlloc::Use ())
297
290
return DlsymAlloc::Callocate (num, size);
298
291
299
- ExpectNotRealtime (" calloc" );
292
+ __rtsan_expect_not_realtime (" calloc" );
300
293
return REAL (calloc)(num, size);
301
294
}
302
295
@@ -305,7 +298,7 @@ INTERCEPTOR(void, free, void *ptr) {
305
298
return DlsymAlloc::Free (ptr);
306
299
307
300
if (ptr != NULL ) {
308
- ExpectNotRealtime (" free" );
301
+ __rtsan_expect_not_realtime (" free" );
309
302
}
310
303
return REAL (free)(ptr);
311
304
}
@@ -314,31 +307,31 @@ INTERCEPTOR(void *, malloc, SIZE_T size) {
314
307
if (DlsymAlloc::Use ())
315
308
return DlsymAlloc::Allocate (size);
316
309
317
- ExpectNotRealtime (" malloc" );
310
+ __rtsan_expect_not_realtime (" malloc" );
318
311
return REAL (malloc)(size);
319
312
}
320
313
321
314
INTERCEPTOR (void *, realloc, void *ptr, SIZE_T size) {
322
315
if (DlsymAlloc::Use () || DlsymAlloc::PointerIsMine (ptr))
323
316
return DlsymAlloc::Realloc (ptr, size);
324
317
325
- ExpectNotRealtime (" realloc" );
318
+ __rtsan_expect_not_realtime (" realloc" );
326
319
return REAL (realloc)(ptr, size);
327
320
}
328
321
329
322
INTERCEPTOR (void *, reallocf, void *ptr, SIZE_T size) {
330
- ExpectNotRealtime (" reallocf" );
323
+ __rtsan_expect_not_realtime (" reallocf" );
331
324
return REAL (reallocf)(ptr, size);
332
325
}
333
326
334
327
INTERCEPTOR (void *, valloc, SIZE_T size) {
335
- ExpectNotRealtime (" valloc" );
328
+ __rtsan_expect_not_realtime (" valloc" );
336
329
return REAL (valloc)(size);
337
330
}
338
331
339
332
#if SANITIZER_INTERCEPT_ALIGNED_ALLOC
340
333
INTERCEPTOR (void *, aligned_alloc, SIZE_T alignment, SIZE_T size) {
341
- ExpectNotRealtime (" aligned_alloc" );
334
+ __rtsan_expect_not_realtime (" aligned_alloc" );
342
335
return REAL (aligned_alloc)(alignment, size);
343
336
}
344
337
#define RTSAN_MAYBE_INTERCEPT_ALIGNED_ALLOC INTERCEPT_FUNCTION (aligned_alloc)
@@ -347,65 +340,65 @@ INTERCEPTOR(void *, aligned_alloc, SIZE_T alignment, SIZE_T size) {
347
340
#endif
348
341
349
342
INTERCEPTOR (int , posix_memalign, void **memptr, size_t alignment, size_t size) {
350
- ExpectNotRealtime (" posix_memalign" );
343
+ __rtsan_expect_not_realtime (" posix_memalign" );
351
344
return REAL (posix_memalign)(memptr, alignment, size);
352
345
}
353
346
354
347
#if SANITIZER_INTERCEPT_MEMALIGN
355
348
INTERCEPTOR (void *, memalign, size_t alignment, size_t size) {
356
- ExpectNotRealtime (" memalign" );
349
+ __rtsan_expect_not_realtime (" memalign" );
357
350
return REAL (memalign)(alignment, size);
358
351
}
359
352
#endif
360
353
361
354
#if SANITIZER_INTERCEPT_PVALLOC
362
355
INTERCEPTOR (void *, pvalloc, size_t size) {
363
- ExpectNotRealtime (" pvalloc" );
356
+ __rtsan_expect_not_realtime (" pvalloc" );
364
357
return REAL (pvalloc)(size);
365
358
}
366
359
#endif
367
360
368
361
// Sockets
369
362
INTERCEPTOR (int , socket, int domain, int type, int protocol) {
370
- ExpectNotRealtime (" socket" );
363
+ __rtsan_expect_not_realtime (" socket" );
371
364
return REAL (socket)(domain, type, protocol);
372
365
}
373
366
374
367
INTERCEPTOR (ssize_t , send, int sockfd, const void *buf, size_t len, int flags) {
375
- ExpectNotRealtime (" send" );
368
+ __rtsan_expect_not_realtime (" send" );
376
369
return REAL (send)(sockfd, buf, len, flags);
377
370
}
378
371
379
372
INTERCEPTOR (ssize_t , sendmsg, int socket, const struct msghdr *message,
380
373
int flags) {
381
- ExpectNotRealtime (" sendmsg" );
374
+ __rtsan_expect_not_realtime (" sendmsg" );
382
375
return REAL (sendmsg)(socket, message, flags);
383
376
}
384
377
385
378
INTERCEPTOR (ssize_t , sendto, int socket, const void *buffer, size_t length,
386
379
int flags, const struct sockaddr *dest_addr, socklen_t dest_len) {
387
- ExpectNotRealtime (" sendto" );
380
+ __rtsan_expect_not_realtime (" sendto" );
388
381
return REAL (sendto)(socket, buffer, length, flags, dest_addr, dest_len);
389
382
}
390
383
391
384
INTERCEPTOR (ssize_t , recv, int socket, void *buffer, size_t length, int flags) {
392
- ExpectNotRealtime (" recv" );
385
+ __rtsan_expect_not_realtime (" recv" );
393
386
return REAL (recv)(socket, buffer, length, flags);
394
387
}
395
388
396
389
INTERCEPTOR (ssize_t , recvfrom, int socket, void *buffer, size_t length,
397
390
int flags, struct sockaddr *address, socklen_t *address_len) {
398
- ExpectNotRealtime (" recvfrom" );
391
+ __rtsan_expect_not_realtime (" recvfrom" );
399
392
return REAL (recvfrom)(socket, buffer, length, flags, address, address_len);
400
393
}
401
394
402
395
INTERCEPTOR (ssize_t , recvmsg, int socket, struct msghdr *message, int flags) {
403
- ExpectNotRealtime (" recvmsg" );
396
+ __rtsan_expect_not_realtime (" recvmsg" );
404
397
return REAL (recvmsg)(socket, message, flags);
405
398
}
406
399
407
400
INTERCEPTOR (int , shutdown, int socket, int how) {
408
- ExpectNotRealtime (" shutdown" );
401
+ __rtsan_expect_not_realtime (" shutdown" );
409
402
return REAL (shutdown)(socket, how);
410
403
}
411
404
0 commit comments