<div dir="ltr">Shouldn't the ManagedStatic be inside  <span style="font-family:arial,sans-serif;font-size:13px">#ifdef HAVE_TERMINFO?</span></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 22, 2014 at 3:39 PM, Chris Bieneman <span dir="ltr"><<a href="mailto:beanz@apple.com" target="_blank">beanz@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: cbieneman<br>
Date: Mon Sep 22 17:39:20 2014<br>
New Revision: 218283<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=218283&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=218283&view=rev</a><br>
Log:<br>
Converting terminalHasColors mutex to a global ManagedStatic to avoid the static destructor.<br>
<br>
Modified:<br>
    llvm/trunk/lib/Support/Unix/Process.inc<br>
<br>
Modified: llvm/trunk/lib/Support/Unix/Process.inc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Process.inc?rev=218283&r1=218282&r2=218283&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Process.inc?rev=218283&r1=218282&r2=218283&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Support/Unix/Process.inc (original)<br>
+++ llvm/trunk/lib/Support/Unix/Process.inc Mon Sep 22 17:39:20 2014<br>
@@ -14,6 +14,7 @@<br>
 #include "Unix.h"<br>
 #include "llvm/ADT/Hashing.h"<br>
 #include "llvm/ADT/StringRef.h"<br>
+#include "llvm/Support/ManagedStatic.h"<br>
 #include "llvm/Support/Mutex.h"<br>
 #include "llvm/Support/MutexGuard.h"<br>
 #include "llvm/Support/TimeValue.h"<br>
@@ -263,11 +264,12 @@ extern "C" int del_curterm(struct term *<br>
 extern "C" int tigetnum(char *capname);<br>
 #endif<br>
<br>
+static ManagedStatic<sys::Mutex> TermColorMutex;<br>
+<br>
 static bool terminalHasColors(int fd) {<br>
 #ifdef HAVE_TERMINFO<br>
   // First, acquire a global lock because these C routines are thread hostile.<br>
-  static sys::Mutex M;<br>
-  MutexGuard G(M);<br>
+  MutexGuard G(*TermColorMutex);<br>
<br>
   int errret = 0;<br>
   if (setupterm((char *)nullptr, fd, &errret) != 0)<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><br clear="all"><div><br></div>-- <br>~Craig
</div>