OMG. Looking... <div>Which version of MAcOS is that? </div><div>I am, sure I've tested it on MacOS 10.6. </div><div><br></div><div>--kcc <br><br><div class="gmail_quote">On Tue, Jan 10, 2012 at 3:26 PM, Chad Rosier <span dir="ltr"><<a href="mailto:mcrosier@apple.com">mcrosier@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Kostya,<div>I believe we're seeing failures on our internal buildbots due to this commit.  Clang is failing to build due to the following error:</div>
<div><br></div><div><span style="font-family:Times"><pre style="font-family:'Courier New',courier,monotype"><span style="font-family:'Courier New',courier,monotype;color:red">/Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin10-gcc42-RA/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:226:5: error: conflicting types for 'pthread_create'
int pthread_create(void *thread, const void *attr,
    ^
/usr/include/pthread.h:298:11: note: previous declaration is here
int       pthread_create(pthread_t * __restrict,
          ^
1 error generated.</span></pre></span><span class="HOEnZb"><font color="#888888"><div> Chad</div></font></span></div><div><div class="h5"><div><br><div><div>On Jan 10, 2012, at 1:24 PM, Kostya Serebryany wrote:</div><br>
<blockquote type="cite"><div>Author: kcc<br>Date: Tue Jan 10 15:24:40 2012<br>New Revision: 147878<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=147878&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=147878&view=rev</a><br>
Log:<br>[asan] move OS-dependent code away from asan_lock.h<br><br>Modified:<br>    compiler-rt/trunk/lib/asan/asan_interceptors.cc<br>    compiler-rt/trunk/lib/asan/asan_linux.cc<br>    compiler-rt/trunk/lib/asan/asan_lock.h<br>
    compiler-rt/trunk/lib/asan/asan_mac.cc<br>    compiler-rt/trunk/lib/asan/asan_thread_registry.cc<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=147878&r1=147877&r2=147878&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=147878&r1=147877&r2=147878&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)<br>+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Tue Jan 10 15:24:40 2012<br>
@@ -35,7 +35,7 @@<br> typedef longjmp_f _longjmp_f;<br> typedef longjmp_f siglongjmp_f;<br> typedef void (*__cxa_throw_f)(void *, void *, void *);<br>-typedef int (*pthread_create_f)(pthread_t *thread, const pthread_attr_t *attr,<br>
+typedef int (*pthread_create_f)(void *thread, const void *attr,<br>                                 void *(*start_routine) (void *), void *arg);<br> #ifdef __APPLE__<br> dispatch_async_f_f real_dispatch_async_f;<br>@@ -223,10 +223,13 @@<br>
 }<br><br> extern "C"<br>+int pthread_create(void *thread, const void *attr,<br>+                   void *(*start_routine) (void *), void *arg);<br>+extern "C"<br> #ifndef __APPLE__<br> __attribute__((visibility("default")))<br>
 #endif<br>-int WRAP(pthread_create)(pthread_t *thread, const pthread_attr_t *attr,<br>+int WRAP(pthread_create)(void *thread, const void *attr,<br>                          void *(*start_routine) (void *), void *arg) {<br>
   GET_STACK_TRACE_HERE(kStackTraceMax, /*fast_unwind*/false);<br>   AsanThread *curr_thread = asanThreadRegistry().GetCurrent();<br><br>Modified: compiler-rt/trunk/lib/asan/asan_linux.cc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=147878&r1=147877&r2=147878&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=147878&r1=147877&r2=147878&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/asan/asan_linux.cc (original)<br>+++ compiler-rt/trunk/lib/asan/asan_linux.cc Tue Jan 10 15:24:40 2012<br>@@ -15,6 +15,7 @@<br>
<br> #include "asan_interceptors.h"<br> #include "asan_internal.h"<br>+#include "asan_lock.h"<br> #include "asan_procmaps.h"<br> #include "asan_thread.h"<br><br>@@ -276,6 +277,26 @@<br>
   CHECK(AddrIsInStack((uintptr_t)&attr));<br> }<br><br>+AsanLock::AsanLock(LinkerInitialized) {<br>+  // We assume that pthread_mutex_t initialized to all zeroes is a valid<br>+  // unlocked mutex. We can not use PTHREAD_MUTEX_INITIALIZER as it triggers<br>
+  // a gcc warning:<br>+  // extended initializer lists only available with -std=c++0x or -std=gnu++0x<br>+}<br>+<br>+void AsanLock::Lock() {<br>+  CHECK(sizeof(pthread_mutex_t) <= sizeof(opaque_storage_));<br>+  pthread_mutex_lock((pthread_mutex_t*)&opaque_storage_);<br>
+  CHECK(!owner_);<br>+  owner_ = (uintptr_t)pthread_self();<br>+}<br>+<br>+void AsanLock::Unlock() {<br>+  CHECK(owner_ == (uintptr_t)pthread_self());<br>+  owner_ = 0;<br>+  pthread_mutex_unlock((pthread_mutex_t*)&opaque_storage_);<br>
+}<br>+<br> }  // namespace __asan<br><br> #endif  // __linux__<br><br>Modified: compiler-rt/trunk/lib/asan/asan_lock.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_lock.h?rev=147878&r1=147877&r2=147878&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_lock.h?rev=147878&r1=147877&r2=147878&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/asan/asan_lock.h (original)<br>+++ compiler-rt/trunk/lib/asan/asan_lock.h Tue Jan 10 15:24:40 2012<br>@@ -19,70 +19,21 @@<br>
 // The locks in ASan are global objects and they are never destroyed to avoid<br> // at-exit races (that is, a lock is being used by other threads while the main<br> // thread is doing atexit destructors).<br>+// We define the class using opaque storage to avoid including system headers.<br>
<br>-#ifdef __APPLE__<br>-#include <pthread.h><br>-<br>-#include <libkern/OSAtomic.h><br> namespace __asan {<br>-class AsanLock {<br>- public:<br>-  explicit AsanLock(LinkerInitialized) :<br>-    mu_(OS_SPINLOCK_INIT),<br>
-    owner_(0),<br>-    is_locked_(false) {}<br><br>-  void Lock() {<br>-    CHECK(owner_ != pthread_self());<br>-    OSSpinLockLock(&mu_);<br>-    is_locked_ = true;<br>-    owner_ = pthread_self();<br>-  }<br>-  void Unlock() {<br>
-    owner_ = 0;<br>-    is_locked_ = false;<br>-    OSSpinLockUnlock(&mu_);<br>-  }<br>-<br>-  bool IsLocked() {<br>-    // This is not atomic, e.g. one thread may get different values if another<br>-    // one is about to release the lock.<br>
-    return is_locked_;<br>-  }<br>- private:<br>-  OSSpinLock mu_;<br>-  volatile pthread_t owner_;  // for debugging purposes<br>-  bool is_locked_;  // for silly malloc_introspection_t interface<br>-};<br>-}  // namespace __asan<br>
-<br>-#else  // assume linux<br>-#include <pthread.h><br>-namespace __asan {<br> class AsanLock {<br>  public:<br>-  explicit AsanLock(LinkerInitialized) {<br>-    // We assume that pthread_mutex_t initialized to all zeroes is a valid<br>
-    // unlocked mutex. We can not use PTHREAD_MUTEX_INITIALIZER as it triggers<br>-    // a gcc warning:<br>-    // extended initializer lists only available with -std=c++0x or -std=gnu++0x<br>-  }<br>-  void Lock() {<br>
-    pthread_mutex_lock(&mu_);<br>-    // pthread_spin_lock(&mu_);<br>-  }<br>-  void Unlock() {<br>-    pthread_mutex_unlock(&mu_);<br>-    // pthread_spin_unlock(&mu_);<br>-  }<br>+  explicit AsanLock(LinkerInitialized);<br>
+  void Lock();<br>+  void Unlock();<br>+  bool IsLocked() { return owner_ != 0; }<br>  private:<br>-  pthread_mutex_t mu_;<br>-  // pthread_spinlock_t mu_;<br>+  uintptr_t opaque_storage_[10];<br>+  uintptr_t owner_;  // for debugging and for malloc_introspection_t interface<br>
 };<br>-}  // namespace __asan<br>-#endif<br><br>-namespace __asan {<br> class ScopedLock {<br>  public:<br>   explicit ScopedLock(AsanLock *mu) : mu_(mu) {<br><br>Modified: compiler-rt/trunk/lib/asan/asan_mac.cc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.cc?rev=147878&r1=147877&r2=147878&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.cc?rev=147878&r1=147877&r2=147878&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/asan/asan_mac.cc (original)<br>+++ compiler-rt/trunk/lib/asan/asan_mac.cc Tue Jan 10 15:24:40 2012<br>@@ -27,6 +27,7 @@<br>
 #include <pthread.h><br> #include <fcntl.h><br> #include <unistd.h><br>+#include <libkern/OSAtomic.h><br><br> namespace __asan {<br><br>@@ -130,6 +131,27 @@<br>   CHECK(AddrIsInStack((uintptr_t)&local));<br>
 }<br><br>+<br>+AsanLock::AsanLock(LinkerInitialized) {<br>+  // We assume that OS_SPINLOCK_INIT is zero<br>+}<br>+<br>+void AsanLock::Lock() {<br>+  CHECK(sizeof(OSSpinLock) <= sizeof(opaque_storage_));<br>+  CHECK(OS_SPINLOCK_INIT == 0);<br>
+  CHECK(owner_ != (uintptr_t)pthread_self());<br>+  OSSpinLockLock((OSSpinLock*)&opaque_storage_);<br>+  CHECK(!owner_);<br>+  owner_ = (uintptr_t)pthread_self();<br>+}<br>+<br>+void AsanLock::Unlock() {<br>+  CHECK(owner_ == (uintptr_t)pthread_self());<br>
+  owner_ = 0;<br>+  OSSpinLockUnlock((OSSpinLock*)&opaque_storage_);<br>+}<br>+<br>+<br> // Support for the following functions from libdispatch on Mac OS:<br> //   dispatch_async_f()<br> //   dispatch_async()<br><br>
Modified: compiler-rt/trunk/lib/asan/asan_thread_registry.cc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread_registry.cc?rev=147878&r1=147877&r2=147878&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread_registry.cc?rev=147878&r1=147877&r2=147878&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/asan/asan_thread_registry.cc (original)<br>+++ compiler-rt/trunk/lib/asan/asan_thread_registry.cc Tue Jan 10 15:24:40 2012<br>
@@ -18,6 +18,7 @@<br> #include "asan_thread_registry.h"<br><br> #include <limits.h><br>+#include <pthread.h><br><br> namespace __asan {<br><br><br><br>_______________________________________________<br>
llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">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>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>