[llvm] r218283 - Converting terminalHasColors mutex to a global ManagedStatic to avoid the static destructor.

Chris Bieneman beanz at apple.com
Mon Sep 22 15:39:20 PDT 2014


Author: cbieneman
Date: Mon Sep 22 17:39:20 2014
New Revision: 218283

URL: http://llvm.org/viewvc/llvm-project?rev=218283&view=rev
Log:
Converting terminalHasColors mutex to a global ManagedStatic to avoid the static destructor.

Modified:
    llvm/trunk/lib/Support/Unix/Process.inc

Modified: llvm/trunk/lib/Support/Unix/Process.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Process.inc?rev=218283&r1=218282&r2=218283&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Process.inc (original)
+++ llvm/trunk/lib/Support/Unix/Process.inc Mon Sep 22 17:39:20 2014
@@ -14,6 +14,7 @@
 #include "Unix.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/MutexGuard.h"
 #include "llvm/Support/TimeValue.h"
@@ -263,11 +264,12 @@ extern "C" int del_curterm(struct term *
 extern "C" int tigetnum(char *capname);
 #endif
 
+static ManagedStatic<sys::Mutex> TermColorMutex;
+
 static bool terminalHasColors(int fd) {
 #ifdef HAVE_TERMINFO
   // First, acquire a global lock because these C routines are thread hostile.
-  static sys::Mutex M;
-  MutexGuard G(M);
+  MutexGuard G(*TermColorMutex);
 
   int errret = 0;
   if (setupterm((char *)nullptr, fd, &errret) != 0)





More information about the llvm-commits mailing list