summaryrefslogtreecommitdiff
path: root/lib/tsan/rtl/tsan_interceptors.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tsan/rtl/tsan_interceptors.cc')
-rw-r--r--lib/tsan/rtl/tsan_interceptors.cc75
1 files changed, 13 insertions, 62 deletions
diff --git a/lib/tsan/rtl/tsan_interceptors.cc b/lib/tsan/rtl/tsan_interceptors.cc
index b545f8c52..6f23a460b 100644
--- a/lib/tsan/rtl/tsan_interceptors.cc
+++ b/lib/tsan/rtl/tsan_interceptors.cc
@@ -1599,64 +1599,6 @@ TSAN_INTERCEPTOR(int, unlink, char *path) {
return res;
}
-TSAN_INTERCEPTOR(void*, fopen, char *path, char *mode) {
- SCOPED_TSAN_INTERCEPTOR(fopen, path, mode);
- void *res = REAL(fopen)(path, mode);
- Acquire(thr, pc, File2addr(path));
- if (res) {
- int fd = fileno_unlocked(res);
- if (fd >= 0)
- FdFileCreate(thr, pc, fd);
- }
- return res;
-}
-
-TSAN_INTERCEPTOR(void*, fopen64, char *path, char *mode) {
- SCOPED_TSAN_INTERCEPTOR(fopen64, path, mode);
- void *res = REAL(fopen64)(path, mode);
- Acquire(thr, pc, File2addr(path));
- if (res) {
- int fd = fileno_unlocked(res);
- if (fd >= 0)
- FdFileCreate(thr, pc, fd);
- }
- return res;
-}
-
-TSAN_INTERCEPTOR(void*, freopen, char *path, char *mode, void *stream) {
- SCOPED_TSAN_INTERCEPTOR(freopen, path, mode, stream);
- if (stream) {
- int fd = fileno_unlocked(stream);
- if (fd >= 0)
- FdClose(thr, pc, fd);
- }
- void *res = REAL(freopen)(path, mode, stream);
- Acquire(thr, pc, File2addr(path));
- if (res) {
- int fd = fileno_unlocked(res);
- if (fd >= 0)
- FdFileCreate(thr, pc, fd);
- }
- return res;
-}
-
-TSAN_INTERCEPTOR(void*, freopen64, char *path, char *mode, void *stream) {
- SCOPED_TSAN_INTERCEPTOR(freopen64, path, mode, stream);
- if (stream) {
- int fd = fileno_unlocked(stream);
- if (fd >= 0)
- FdClose(thr, pc, fd);
- }
- void *res = REAL(freopen64)(path, mode, stream);
- Acquire(thr, pc, File2addr(path));
- if (res) {
- int fd = fileno_unlocked(res);
- if (fd >= 0)
- FdFileCreate(thr, pc, fd);
- }
- return res;
-}
-
TSAN_INTERCEPTOR(void*, tmpfile, int fake) {
SCOPED_TSAN_INTERCEPTOR(tmpfile, fake);
void *res = REAL(tmpfile)(fake);
@@ -2100,6 +2042,19 @@ static void HandleRecvmsg(ThreadState *thr, uptr pc,
ctx = (void *)&_ctx; \
(void) ctx;
+#define COMMON_INTERCEPTOR_FILE_OPEN(ctx, file, path) \
+ Acquire(thr, pc, File2addr(path)); \
+ if (file) { \
+ int fd = fileno_unlocked(file); \
+ if (fd >= 0) FdFileCreate(thr, pc, fd); \
+ }
+
+#define COMMON_INTERCEPTOR_FILE_CLOSE(ctx, file) \
+ if (file) { \
+ int fd = fileno_unlocked(file); \
+ if (fd >= 0) FdClose(thr, pc, fd); \
+ }
+
#define COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd) \
FdAcquire(((TsanInterceptorContext *) ctx)->thr, pc, fd)
@@ -2411,10 +2366,6 @@ void InitializeInterceptors() {
TSAN_INTERCEPT(recv);
TSAN_INTERCEPT(unlink);
- TSAN_INTERCEPT(fopen);
- TSAN_INTERCEPT(fopen64);
- TSAN_INTERCEPT(freopen);
- TSAN_INTERCEPT(freopen64);
TSAN_INTERCEPT(tmpfile);
TSAN_INTERCEPT(tmpfile64);
TSAN_INTERCEPT(fclose);