[PATCH] Change base mutex implementations to use STL-provided mutexes

Alp Toker alp at nuanti.com
Fri Jun 6 17:46:42 PDT 2014


On 07/06/2014 02:34, Zachary Turner wrote:
> Remove the Mutex.h dependency on windows.h, and address various other review comments.
>
> This solution is still less than ideal, because we need to include some windows preprocessor checks inside of Mutex.h.

It seems you could just have CriticalSectionMutex implemented as a 
standard Mutex when building on Unix.

That way you don't need any preprocessor conditionals in either the 
header definition or at the point of use, and the fallback on 
non-Windows platforms is seamless.

> The best solution in my opinion would require allowing some platform specific headers to be in the include tree  (for example, include\llvm\Support\Windows\CriticalSectionMutex.h).  This would remove all of the preprocessor code from Mutex.h, and allow anyone who needs this to simply write #include "llvm/Support/Windows/CriticalSectionMutex.h".

We have actual clients we need to support that break with windows.h due 
to stomping on global namespaces and definitions -- conflicts are a 
likely scenario with any non-trivial piece of code that wasn't written 
to target Windows originally.

The elegant and efficient solutions are all around if you take a look, 
but exposing windows.h isn't one of them.

Alp.


>
> http://reviews.llvm.org/D4033
>
> Files:
>    include/llvm/ExecutionEngine/ExecutionEngine.h
>    include/llvm/IR/ValueMap.h
>    include/llvm/Support/Mutex.h
>    include/llvm/Support/MutexGuard.h
>    lib/CodeGen/PseudoSourceValue.cpp
>    lib/CodeGen/SelectionDAG/SelectionDAG.cpp
>    lib/ExecutionEngine/ExecutionEngine.cpp
>    lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
>    lib/ExecutionEngine/JIT/JIT.cpp
>    lib/ExecutionEngine/JIT/JITEmitter.cpp
>    lib/ExecutionEngine/OProfileJIT/OProfileWrapper.cpp
>    lib/ExecutionEngine/RuntimeDyld/GDBRegistrar.cpp
>    lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
>    lib/IR/LeakDetector.cpp
>    lib/IR/LegacyPassManager.cpp
>    lib/Support/CMakeLists.txt
>    lib/Support/CrashRecoveryContext.cpp
>    lib/Support/DynamicLibrary.cpp
>    lib/Support/Mutex.cpp
>    lib/Support/PluginLoader.cpp
>    lib/Support/Statistic.cpp
>    lib/Support/Threading.cpp
>    lib/Support/Timer.cpp
>    lib/Support/Unix/Mutex.inc
>    lib/Support/Unix/Process.inc
>    lib/Support/Unix/Signals.inc
>    lib/Support/Windows/DynamicLibrary.inc
>    lib/Support/Windows/Mutex.inc
>    lib/Target/NVPTX/NVPTXUtilities.cpp
>    unittests/IR/ValueMapTest.cpp
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-- 
http://www.nuanti.com
the browser experts




More information about the llvm-commits mailing list