<div><br></div><br><div><br></div><div><br><br><div class="gmail_quote">On Fri, Jan 27, 2012 at 2:52 AM, Alexander Potapenko <span dir="ltr"><<a href="mailto:glider@google.com">glider@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: glider<br>
Date: Fri Jan 27 04:52:37 2012<br>
New Revision: 149129<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=149129&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=149129&view=rev</a><br>
Log:<br>
Make compiler-rt/trunk/lib/asan compileable with g++.<br>
Patch by Timur Iskhodzhanov (<a href="mailto:timurrrr@google.com">timurrrr@google.com</a>)<br>
<br>
The double-extern thing is<br>
<a href="http://llvm.org/bugs/show_bug.cgi?id=11869" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=11869</a><br>
<br>
And the #include <string[s].h> are only needed on Mac (see comments in<br>
the original code)<br></blockquote><div><br></div><div>Ideally, we should not include these system headers at all. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

and also including them might make strchr/index conflict with the g++<br>
system headers (which don't follow the man pages, ouch!)<br>
<br>
Modified:<br>
    compiler-rt/trunk/lib/asan/asan_interceptors.cc<br>
    compiler-rt/trunk/lib/asan/asan_internal.h<br>
<br>
Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=149129&r1=149128&r2=149129&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=149129&r1=149128&r2=149129&view=diff</a><br>

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

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)<br>
+++ compiler-rt/trunk/lib/asan/asan_internal.h Fri Jan 27 04:52:37 2012<br>
@@ -31,6 +31,10 @@<br>
 #endif<br>
 #endif<br>
<br>
+#if !defined(__has_feature)<br>
+#define __has_feature(x) 0<br>
+#endif<br>
+<br>
 #if defined(__has_feature) && __has_feature(address_sanitizer)<br>
 # error "The AddressSanitizer run-time should not be"<br>
         " instrumented by AddressSanitizer"<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>