diff options
Diffstat (limited to 'compiler-rt/lib/xray/xray_log_interface.cc')
-rw-r--r-- | compiler-rt/lib/xray/xray_log_interface.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/compiler-rt/lib/xray/xray_log_interface.cc b/compiler-rt/lib/xray/xray_log_interface.cc index c7cfe5080b2..8fb6e39192e 100644 --- a/compiler-rt/lib/xray/xray_log_interface.cc +++ b/compiler-rt/lib/xray/xray_log_interface.cc @@ -12,45 +12,46 @@ //===----------------------------------------------------------------------===// #include "xray/xray_log_interface.h" +#include "sanitizer_common/sanitizer_atomic.h" +#include "sanitizer_common/sanitizer_mutex.h" #include "xray/xray_interface.h" #include "xray_defs.h" #include <memory> -#include <mutex> -std::mutex XRayImplMutex; +__sanitizer::SpinMutex XRayImplMutex; std::unique_ptr<XRayLogImpl> GlobalXRayImpl; void __xray_set_log_impl(XRayLogImpl Impl) XRAY_NEVER_INSTRUMENT { if (Impl.log_init == nullptr || Impl.log_finalize == nullptr || Impl.handle_arg0 == nullptr || Impl.flush_log == nullptr) { - std::lock_guard<std::mutex> Guard(XRayImplMutex); + __sanitizer::SpinMutexLock Guard(&XRayImplMutex); GlobalXRayImpl.reset(); return; } - std::lock_guard<std::mutex> Guard(XRayImplMutex); + __sanitizer::SpinMutexLock Guard(&XRayImplMutex); GlobalXRayImpl.reset(new XRayLogImpl); *GlobalXRayImpl = Impl; } XRayLogInitStatus __xray_init(size_t BufferSize, size_t MaxBuffers, void *Args, size_t ArgsSize) XRAY_NEVER_INSTRUMENT { - std::lock_guard<std::mutex> Guard(XRayImplMutex); + __sanitizer::SpinMutexLock Guard(&XRayImplMutex); if (!GlobalXRayImpl) return XRayLogInitStatus::XRAY_LOG_UNINITIALIZED; return GlobalXRayImpl->log_init(BufferSize, MaxBuffers, Args, ArgsSize); } XRayLogInitStatus __xray_log_finalize() XRAY_NEVER_INSTRUMENT { - std::lock_guard<std::mutex> Guard(XRayImplMutex); + __sanitizer::SpinMutexLock Guard(&XRayImplMutex); if (!GlobalXRayImpl) return XRayLogInitStatus::XRAY_LOG_UNINITIALIZED; return GlobalXRayImpl->log_finalize(); } XRayLogFlushStatus __xray_log_flushLog() XRAY_NEVER_INSTRUMENT { - std::lock_guard<std::mutex> Guard(XRayImplMutex); + __sanitizer::SpinMutexLock Guard(&XRayImplMutex); if (!GlobalXRayImpl) return XRayLogFlushStatus::XRAY_LOG_NOT_FLUSHING; return GlobalXRayImpl->flush_log(); |