Refactor initialization of GetRealTimeClock singleton.

This CL also fixes no_exit_time_destructors in system_wrappers.

Bug: webrtc:9693
Change-Id: Ieba752f50949f862244a8348ffc1bed3c2f0150f
Reviewed-on: https://webrtc-review.googlesource.com/99081
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24660}
diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn
index ad91745..a926147 100644
--- a/system_wrappers/BUILD.gn
+++ b/system_wrappers/BUILD.gn
@@ -14,7 +14,6 @@
 
 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 c9940fb..35ab5f0 100644
--- a/system_wrappers/source/clock.cc
+++ b/system_wrappers/source/clock.cc
@@ -200,32 +200,15 @@
 };
 #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<void* volatile*>(&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)