This is a re-submission of an earlier broken patch.
Change llvm::sys::Mutex implementation to use std::mutex and std::recursive_mutex.
This patch deletes the platform specific mutex implementations, and delegates to the underlying STL implementation. Because STL mutex and recursive_mutex are implemented as separate classes, it is no longer possible to specify as a runtime param whether a recursive mutex is desired, and instead the decision must be made at compile time.
As part of this refactor, the ScopedLock class is deleted in favor of MutexGuard, which provides equivalent functionality.
To make reviewing easier, you can refer to the following table of equivalences in the format (old_type -> new_type)
SmartMutex<true>([true]) -> RecursiveDebugMutex
SmartMutex<false>([true]) -> RecursiveMutex
sys::Mutex -> SmartMutex<false>() -> RecursiveMutex
SmartMutex<true>(false) -> NonRecursiveDebugMutex
SmartMutex<false>(false) -> NonRecursiveMutex
One caveat of note is that on Windows std::*mutex cannot be used during an atexit handler. To get around this, a new type AtexitSafeMutex is defined, and on Windows this is typedefed to a critical section.