[llvm-commits] [compiler-rt] r158052 - in /compiler-rt/trunk/lib: sanitizer_common/sanitizer_libc.h sanitizer_common/sanitizer_linux.cc sanitizer_common/sanitizer_mac.cc sanitizer_common/sanitizer_win.cc tsan/rtl/tsan_platform.h tsan/rtl/tsan_platform_linux.cc
Alexey Samsonov
samsonov at google.com
Wed Jun 6 00:30:33 PDT 2012
Author: samsonov
Date: Wed Jun 6 02:30:33 2012
New Revision: 158052
URL: http://llvm.org/viewvc/llvm-project?rev=158052&view=rev
Log:
[Sanitizer] move internal_filesize and internal_dup2 from TSan to sanitizer_common.
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h
compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h?rev=158052&r1=158051&r2=158052&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h Wed Jun 6 02:30:33 2012
@@ -40,6 +40,8 @@
fd_t internal_open(const char *filename, bool write);
uptr internal_read(fd_t fd, void *buf, uptr count);
uptr internal_write(fd_t fd, const void *buf, uptr count);
+uptr internal_filesize(fd_t fd); // -1 on error.
+int internal_dup2(int oldfd, int newfd);
int internal_sscanf(const char *str, const char *format, ...);
} // namespace __sanitizer
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=158052&r1=158051&r2=158052&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Wed Jun 6 02:30:33 2012
@@ -55,6 +55,17 @@
return (uptr)syscall(__NR_write, fd, buf, count);
}
+uptr internal_filesize(fd_t fd) {
+ struct stat st = {};
+ if (syscall(__NR_fstat, fd, &st))
+ return -1;
+ return (uptr)st.st_size;
+}
+
+int internal_dup2(int oldfd, int newfd) {
+ return syscall(__NR_dup2, oldfd, newfd);
+}
+
} // namespace __sanitizer
#endif // __linux__
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc?rev=158052&r1=158051&r2=158052&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc Wed Jun 6 02:30:33 2012
@@ -51,6 +51,17 @@
return write(fd, buf, count);
}
+uptr internal_filesize(fd_t fd) {
+ struct stat st = {};
+ if (fstat(fd, &st))
+ return -1;
+ return (uptr)st.st_size;
+}
+
+int internal_dup2(int oldfd, int newfd) {
+ return dup2(oldfd, newfd);
+}
+
} // namespace __sanitizer
#endif // __APPLE__
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=158052&r1=158051&r2=158052&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Wed Jun 6 02:30:33 2012
@@ -63,6 +63,16 @@
return ret;
}
+uptr internal_filesize(fd_t fd) {
+ UNIMPLEMENTED_WIN();
+ return -1;
+}
+
+int internal_dup2(int oldfd, int newfd) {
+ UNIMPLEMENTED_WIN();
+ return -1;
+}
+
int internal_sscanf(const char *str, const char *format, ...) {
UNIMPLEMENTED_WIN();
return -1;
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h?rev=158052&r1=158051&r2=158052&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h Wed Jun 6 02:30:33 2012
@@ -76,9 +76,6 @@
void internal_start_thread(void(*func)(void*), void *arg);
-typedef int fd_t;
-uptr internal_filesize(fd_t fd); // -1 on error.
-int internal_dup2(int oldfd, int newfd);
const char *internal_getpwd();
uptr GetTlsSize();
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc?rev=158052&r1=158051&r2=158052&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc Wed Jun 6 02:30:33 2012
@@ -83,18 +83,6 @@
usleep(ms * 1000);
}
-uptr internal_filesize(fd_t fd) {
- struct stat st = {};
- if (syscall(__NR_fstat, fd, &st))
- return -1;
- return (uptr)st.st_size;
-}
-
-int internal_dup2(int oldfd, int newfd) {
- ScopedInRtl in_rtl;
- return syscall(__NR_dup2, oldfd, newfd);
-}
-
const char *internal_getpwd() {
return getenv("PWD");
}
More information about the llvm-commits
mailing list