diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn index ad917451ad..a926147bba 100644 --- a/system_wrappers/BUILD.gn +++ b/system_wrappers/BUILD.gn @@ -14,7 +14,6 @@ import("../webrtc.gni") rtc_static_library("system_wrappers") { visibility = [ "*" ] - configs += [ "..:no_exit_time_destructors" ] sources = [ "include/clock.h", "include/cpu_info.h", diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc index c9940fbe99..35ab5f0878 100644 --- a/system_wrappers/source/clock.cc +++ b/system_wrappers/source/clock.cc @@ -200,32 +200,15 @@ class UnixRealTimeClock : public RealTimeClock { }; #endif // defined(WEBRTC_POSIX) -#if defined(WEBRTC_WIN) -static WindowsRealTimeClock* volatile g_shared_clock = nullptr; -#endif // defined(WEBRTC_WIN) - Clock* Clock::GetRealTimeClock() { #if defined(WEBRTC_WIN) - // This read relies on volatile read being atomic-load-acquire. This is - // true in MSVC since at least 2005: - // "A read of a volatile object (volatile read) has Acquire semantics" - if (g_shared_clock != nullptr) - return g_shared_clock; - WindowsRealTimeClock* clock = new WindowsRealTimeClock; - if (InterlockedCompareExchangePointer( - reinterpret_cast(&g_shared_clock), clock, nullptr) != - nullptr) { - // g_shared_clock was assigned while we constructed/tried to assign our - // instance, delete our instance and use the existing one. - delete clock; - } - return g_shared_clock; + static Clock* const clock = new WindowsRealTimeClock(); #elif defined(WEBRTC_POSIX) - static UnixRealTimeClock clock; - return &clock; -#else // defined(WEBRTC_POSIX) - return nullptr; -#endif // !defined(WEBRTC_WIN) || defined(WEBRTC_POSIX) + static Clock* const clock = new UnixRealTimeClock(); +#else + static Clock* const clock = nullptr; +#endif + return clock; } SimulatedClock::SimulatedClock(int64_t initial_time_us)