[llvm] r218283 - Converting terminalHasColors mutex to a global ManagedStatic to avoid the static destructor.
Craig Topper
craig.topper at gmail.com
Tue Sep 23 23:29:32 PDT 2014
Shouldn't the ManagedStatic be inside #ifdef HAVE_TERMINFO?
On Mon, Sep 22, 2014 at 3:39 PM, Chris Bieneman <beanz at apple.com> wrote:
> 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)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140923/4a9ee283/attachment.html>
More information about the llvm-commits
mailing list