[compiler-rt] r203647 - tsan: add interceptors for fopen64, freopen64, tmpfile, tmpfile64
Dmitry Vyukov
dvyukov at google.com
Wed Mar 12 01:26:44 PDT 2014
Author: dvyukov
Date: Wed Mar 12 03:26:43 2014
New Revision: 203647
URL: http://llvm.org/viewvc/llvm-project?rev=203647&view=rev
Log:
tsan: add interceptors for fopen64, freopen64, tmpfile, tmpfile64
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=203647&r1=203646&r2=203647&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Wed Mar 12 03:26:43 2014
@@ -1492,6 +1492,18 @@ TSAN_INTERCEPTOR(void*, fopen, char *pat
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) {
@@ -1509,6 +1521,45 @@ TSAN_INTERCEPTOR(void*, freopen, char *p
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);
+ if (res) {
+ int fd = fileno_unlocked(res);
+ if (fd >= 0)
+ FdFileCreate(thr, pc, fd);
+ }
+ return res;
+}
+
+TSAN_INTERCEPTOR(void*, tmpfile64, int fake) {
+ SCOPED_TSAN_INTERCEPTOR(tmpfile64, fake);
+ void *res = REAL(tmpfile64)(fake);
+ if (res) {
+ int fd = fileno_unlocked(res);
+ if (fd >= 0)
+ FdFileCreate(thr, pc, fd);
+ }
+ return res;
+}
+
TSAN_INTERCEPTOR(int, fclose, void *stream) {
// libc file streams can call user-supplied functions, see fopencookie.
{
@@ -2236,7 +2287,11 @@ void InitializeInterceptors() {
TSAN_INTERCEPT(unlink);
TSAN_INTERCEPT(fopen);
+ TSAN_INTERCEPT(fopen64);
TSAN_INTERCEPT(freopen);
+ TSAN_INTERCEPT(freopen64);
+ TSAN_INTERCEPT(tmpfile);
+ TSAN_INTERCEPT(tmpfile64);
TSAN_INTERCEPT(fclose);
TSAN_INTERCEPT(fread);
TSAN_INTERCEPT(fwrite);
More information about the llvm-commits
mailing list