[llvm-commits] [compiler-rt] r169969 - in /compiler-rt/trunk/lib: asan/asan_intercepted_functions.h sanitizer_common/sanitizer_common_interceptors.h

Alexander Potapenko glider at google.com
Wed Dec 12 03:52:26 PST 2012


Author: glider
Date: Wed Dec 12 05:52:26 2012
New Revision: 169969

URL: http://llvm.org/viewvc/llvm-project?rev=169969&view=rev
Log:
[ASan] fix compilation on Mac.

Modified:
    compiler-rt/trunk/lib/asan/asan_intercepted_functions.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h

Modified: compiler-rt/trunk/lib/asan/asan_intercepted_functions.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_intercepted_functions.h?rev=169969&r1=169968&r2=169969&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_intercepted_functions.h (original)
+++ compiler-rt/trunk/lib/asan/asan_intercepted_functions.h Wed Dec 12 05:52:26 2012
@@ -49,8 +49,10 @@
 
 #if !defined(__APPLE__)
 # define ASAN_INTERCEPT_STRNLEN 1
+# define ASAN_INTERCEPT_PREAD64 1
 #else
 # define ASAN_INTERCEPT_STRNLEN 0
+# define ASAN_INTERCEPT_PREAD64 0
 #endif
 
 #if defined(__linux__) && !defined(ANDROID)
@@ -153,6 +155,16 @@
 DECLARE_FUNCTION_AND_WRAPPER(long long, strtoll, const char *nptr, char **endptr, int base);  // NOLINT
 # endif
 
+// unistd.h
+typedef uptr size_t;
+typedef sptr ssize_t;
+typedef u64 off_t;
+typedef u64 off64_t;
+
+DECLARE_FUNCTION_AND_WRAPPER(ssize_t, read, int fd, void *buf, size_t count);
+DECLARE_FUNCTION_AND_WRAPPER(ssize_t, pread, int fd, void *buf, size_t count, off_t offset);
+DECLARE_FUNCTION_AND_WRAPPER(ssize_t, pread64, int fd, void *buf, size_t count, off64_t offset);
+
 # if ASAN_INTERCEPT_MLOCKX
 // mlock/munlock
 DECLARE_FUNCTION_AND_WRAPPER(int, mlock, const void *addr, size_t len);

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h?rev=169969&r1=169968&r2=169969&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h Wed Dec 12 05:52:26 2012
@@ -41,6 +41,7 @@
   return res;
 }
 
+#if ASAN_INTERCEPT_PREAD64
 INTERCEPTOR(ssize_t, pread64, int fd, void *ptr, size_t count, off64_t offset) {
   COMMON_INTERCEPTOR_ENTER(pread64, fd, ptr, count, offset);
   ssize_t res = REAL(pread64)(fd, ptr, count, offset);
@@ -48,10 +49,17 @@
     COMMON_INTERCEPTOR_WRITE_RANGE(ptr, res);
   return res;
 }
+#endif
+
+#if ASAN_INTERCEPT_PREAD64
+#define INIT_PREAD64 CHECK(INTERCEPT_FUNCTION(pread64))
+#else
+#define INIT_PREAD64
+#endif
 
 #define SANITIZER_COMMON_INTERCEPTORS_INIT \
   CHECK(INTERCEPT_FUNCTION(read));         \
   CHECK(INTERCEPT_FUNCTION(pread));        \
-  CHECK(INTERCEPT_FUNCTION(pread64));
+  INIT_PREAD64;                            \
 
 #endif  // SANITIZER_COMMON_INTERCEPTORS_H





More information about the llvm-commits mailing list