summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-02-04 10:16:50 +0000
committerAlexey Samsonov <samsonov@google.com>2013-02-04 10:16:50 +0000
commit2c5cbd2b387f67d74fe08f9a3df163186b156e67 (patch)
tree36bc2dd3297492ed50a41d549cf617ee569abbf4 /compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
parent88b95872935719214fdd45760df33942cceec42f (diff)
downloadbcm5719-llvm-2c5cbd2b387f67d74fe08f9a3df163186b156e67.tar.gz
bcm5719-llvm-2c5cbd2b387f67d74fe08f9a3df163186b156e67.zip
[Sanitizer] extend internal libc with stat/fstat/lstat functions
llvm-svn: 174316
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_linux.cc')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_linux.cc30
1 files changed, 26 insertions, 4 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
index f5edbf01a27..70f330aa9b3 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
@@ -93,16 +93,38 @@ uptr internal_write(fd_t fd, const void *buf, uptr count) {
return res;
}
+int internal_stat(const char *path, void *buf) {
+#if SANITIZER_LINUX_USES_64BIT_SYSCALLS
+ return syscall(__NR_stat, path, buf);
+#else
+ return syscall(__NR_stat64, path, buf);
+#endif
+}
+
+int internal_lstat(const char *path, void *buf) {
+#if SANITIZER_LINUX_USES_64BIT_SYSCALLS
+ return syscall(__NR_lstat, path, buf);
+#else
+ return syscall(__NR_lstat64, path, buf);
+#endif
+}
+
+int internal_fstat(fd_t fd, void *buf) {
+#if SANITIZER_LINUX_USES_64BIT_SYSCALLS
+ return syscall(__NR_fstat, fd, buf);
+#else
+ return syscall(__NR_fstat64, fd, buf);
+#endif
+}
+
uptr internal_filesize(fd_t fd) {
#if SANITIZER_LINUX_USES_64BIT_SYSCALLS
struct stat st;
- if (syscall(__NR_fstat, fd, &st))
- return -1;
#else
struct stat64 st;
- if (syscall(__NR_fstat64, fd, &st))
- return -1;
#endif
+ if (internal_fstat(fd, &st))
+ return -1;
return (uptr)st.st_size;
}
OpenPOWER on IntegriCloud