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

Alexander Potapenko glider at google.com
Fri Jan 27 02:52:37 PST 2012


Author: glider
Date: Fri Jan 27 04:52:37 2012
New Revision: 149129

URL: http://llvm.org/viewvc/llvm-project?rev=149129&view=rev
Log:
Make compiler-rt/trunk/lib/asan compileable with g++.
Patch by Timur Iskhodzhanov (timurrrr at google.com)

The double-extern thing is
http://llvm.org/bugs/show_bug.cgi?id=11869

And the #include <string[s].h> are only needed on Mac (see comments in
the original code)
and also including them might make strchr/index conflict with the g++
system headers (which don't follow the man pages, ouch!)

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=149129&r1=149128&r2=149129&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Fri Jan 27 04:52:37 2012
@@ -26,8 +26,6 @@
 #include <ctype.h>
 #include <dlfcn.h>
 
-#include <string.h>
-#include <strings.h>
 #include <pthread.h>
 
 // To replace weak system functions on Linux we just need to declare functions
@@ -44,6 +42,10 @@
 // calls to our interceptors. We store pointers to system function f()
 // in __asan::real_f().
 #ifdef __APPLE__
+// Include the declarations of the original functions.
+#include <string.h>
+#include <strings.h>
+
 #include "mach_override/mach_override.h"
 #define WRAPPER_NAME(x) "wrap_"#x
 
@@ -307,7 +309,7 @@
 }
 
 extern "C"
-extern int (sigaction)(int signum, const void *act, void *oldact);
+int (sigaction)(int signum, const void *act, void *oldact);
 
 extern "C"
 int WRAP(sigaction)(int signum, const void *act, void *oldact) {

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=149129&r1=149128&r2=149129&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Fri Jan 27 04:52:37 2012
@@ -31,6 +31,10 @@
 #endif
 #endif
 
+#if !defined(__has_feature)
+#define __has_feature(x) 0
+#endif
+
 #if defined(__has_feature) && __has_feature(address_sanitizer)
 # error "The AddressSanitizer run-time should not be"
         " instrumented by AddressSanitizer"





More information about the llvm-commits mailing list