[llvm-commits] [compiler-rt] r157984 - /compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc

Alexey Samsonov samsonov at google.com
Mon Jun 4 23:19:00 PDT 2012


Author: samsonov
Date: Tue Jun  5 01:19:00 2012
New Revision: 157984

URL: http://llvm.org/viewvc/llvm-project?rev=157984&view=rev
Log:
[TSan] use __sanitizer::internal_mmap in TSan run-time

Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc

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=157984&r1=157983&r2=157984&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc Tue Jun  5 01:19:00 2012
@@ -12,6 +12,7 @@
 // Linux-specific code.
 //===----------------------------------------------------------------------===//
 
+#include "sanitizer_common/sanitizer_libc.h"
 #include "tsan_platform.h"
 #include "tsan_rtl.h"
 #include "tsan_flags.h"
@@ -36,6 +37,8 @@
 #include <sched.h>
 #include <dlfcn.h>
 
+using namespace __sanitizer;  // NOLINT
+
 extern "C" int arch_prctl(int code, __tsan::uptr *addr);
 
 namespace __tsan {
@@ -69,16 +72,6 @@
           MADV_DONTNEED);
 }
 
-static void *my_mmap(void *addr, size_t length, int prot, int flags,
-                    int fd, u64 offset) {
-  ScopedInRtl in_rtl;
-# if __WORDSIZE == 64
-  return (void *)syscall(__NR_mmap, addr, length, prot, flags, fd, offset);
-# else
-  return (void *)syscall(__NR_mmap2, addr, length, prot, flags, fd, offset);
-# endif
-}
-
 static void my_munmap(void *addr, size_t length) {
   ScopedInRtl in_rtl;
   syscall(__NR_munmap, addr, length);
@@ -135,7 +128,7 @@
   CHECK_LE(beg, end);
   if (beg == end)
     return;
-  if (beg != (uptr)my_mmap((void*)(beg), end - beg,
+  if (beg != (uptr)internal_mmap((void*)(beg), end - beg,
       PROT_NONE,
       MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
       -1, 0)) {
@@ -150,7 +143,7 @@
   const uptr kClosedLowEnd  = kLinuxShadowBeg - 1;
   const uptr kClosedMidBeg = kLinuxShadowEnd + 1;
   const uptr kClosedMidEnd = kLinuxAppMemBeg - 1;
-  uptr shadow = (uptr)my_mmap((void*)kLinuxShadowBeg,
+  uptr shadow = (uptr)internal_mmap((void*)kLinuxShadowBeg,
       kLinuxShadowEnd - kLinuxShadowBeg,
       PROT_READ | PROT_WRITE,
       MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
@@ -248,7 +241,7 @@
 
   if (main) {
     uptr kBufSize = 1 << 26;
-    char *buf = (char*)my_mmap(0, kBufSize, PROT_READ | PROT_WRITE,
+    char *buf = (char*)internal_mmap(0, kBufSize, PROT_READ | PROT_WRITE,
                                MAP_PRIVATE | MAP_ANON, -1, 0);
     fd_t maps = internal_open("/proc/self/maps", false);
     if (maps == kInvalidFd) {





More information about the llvm-commits mailing list