[llvm-commits] [compiler-rt] r153430 - in /compiler-rt/trunk/lib/asan: asan_interceptors.cc asan_internal.h

Alexey Samsonov samsonov at google.com
Mon Mar 26 02:07:29 PDT 2012


Author: samsonov
Date: Mon Mar 26 04:07:29 2012
New Revision: 153430

URL: http://llvm.org/viewvc/llvm-project?rev=153430&view=rev
Log:
[ASan] use macro to define if we should intercept signal/sigaction

Modified:
    compiler-rt/trunk/lib/asan/asan_interceptors.cc
    compiler-rt/trunk/lib/asan/asan_internal.h

Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=153430&r1=153429&r2=153430&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Mon Mar 26 04:07:29 2012
@@ -38,12 +38,18 @@
 # define ASAN_INTERCEPT_STRNLEN 0
 #endif
 
+#if defined(ANDROID) || defined(_WIN32)
+# define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 0
+#else
+# define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 1
+#endif
+
 // Use extern declarations of intercepted functions on Mac and Windows
 // to avoid including system headers.
 #if defined(__APPLE__) || (defined(_WIN32) && !defined(_DLL))
 extern "C" {
 // signal.h
-# if !defined(_WIN32)
+# if ASAN_INTERCEPT_SIGNAL_AND_SIGACTION
 struct sigaction;
 int sigaction(int sig, const struct sigaction *act,
               struct sigaction *oldact);
@@ -346,7 +352,7 @@
 }
 #endif  // !_WIN32
 
-#if !defined(ANDROID) && !defined(_WIN32)
+#if ASAN_INTERCEPT_SIGNAL_AND_SIGACTION
 INTERCEPTOR(void*, signal, int signum, void *handler) {
   if (!AsanInterceptsSignal(signum)) {
     return REAL(signal)(signum, handler);
@@ -361,7 +367,11 @@
   }
   return 0;
 }
-#endif  // !ANDROID && !_WIN32
+#elif ASAN_POSIX
+// We need to have defined REAL(sigaction) on posix systems.
+DEFINE_REAL(int, sigaction, int signum, const struct sigaction *act,
+    struct sigaction *oldact);
+#endif  // ASAN_INTERCEPT_SIGNAL_AND_SIGACTION
 
 INTERCEPTOR(void, longjmp, void *env, int val) {
   __asan_handle_no_return();
@@ -511,11 +521,6 @@
 DEFINE_REAL(char*, index, const char *string, int c);
 #endif
 
-#ifdef ANDROID
-DEFINE_REAL(int, sigaction, int signum, const struct sigaction *act,
-    struct sigaction *oldact);
-#endif
-
 INTERCEPTOR(int, strcasecmp, const char *s1, const char *s2) {
   ENSURE_ASAN_INITED();
   unsigned char c1, c2;
@@ -755,7 +760,7 @@
 
   // Intecept signal- and jump-related functions.
   CHECK(INTERCEPT_FUNCTION(longjmp));
-#if !defined(ANDROID) && !defined(_WIN32)
+#if ASAN_INTERCEPT_SIGNAL_AND_SIGACTION
   CHECK(INTERCEPT_FUNCTION(sigaction));
   CHECK(INTERCEPT_FUNCTION(signal));
 #endif

Modified: compiler-rt/trunk/lib/asan/asan_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=153430&r1=153429&r2=153430&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Mon Mar 26 04:07:29 2012
@@ -104,6 +104,8 @@
 # define ASAN_WINDOWS 0
 #endif
 
+#define ASAN_POSIX (ASAN_LINUX || ASAN_MAC)
+
 #if !defined(__has_feature)
 #define __has_feature(x) 0
 #endif





More information about the llvm-commits mailing list