[Lldb-commits] [PATCH] D13940: Fix race conditions in Core/Timer

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 21 10:30:06 PDT 2015

zturner added a subscriber: zturner.

Comment at: include/lldb/Core/Timer.h:89
@@ +88,3 @@
+    static thread_local unsigned g_depth;
clayborg wrote:
> Not sure if all platforms support thread_local correctly. MacOSX might not. I also spoke with some compiler folks on using "thread_local" and they warned that the C++11 spec requires a bunch of other stuff gets initialized when _any_ thread_local variable gets used, so I was told that using the "__thread" instead of much better to do. So switch this from thread_local to __thread and it should work on most platforms. Not sure if windows will have a problem with this. 
> So the best fix is probably to make a LLDB_THREAD_LOCAL #define in lldb-defines.h and define it to "__thread" by default. Windows can fix up as needed.
Actually can you use llvm::ThreadLocal instead?

`__thread` doesn't exist on Windows, and neither does `thread_local`.  `ThreadLocal<T>` in llvm is the only thing I know that works everywhere.

Once I get the Python 3 stuff finished, we can move to MSVC 2015, which *does* support `thread_local`.  Then we can use the `LLDB_THREAD_LOCAL` define as you suggest.

Does that work for everyone?


More information about the lldb-commits mailing list