about summary refs log tree commit diff
path: root/absl/flags/flag.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/flags/flag.cc')
-rw-r--r--absl/flags/flag.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/absl/flags/flag.cc b/absl/flags/flag.cc
index f16cc75e3843..a02d069e9b00 100644
--- a/absl/flags/flag.cc
+++ b/absl/flags/flag.cc
@@ -41,4 +41,20 @@ ABSL_FLAGS_INTERNAL_FOR_EACH_LOCK_FREE(ABSL_FLAGS_ATOMIC_GET)
 
 #undef ABSL_FLAGS_ATOMIC_GET
 
+// This global nutex protects on-demand construction of flag objects in MSVC
+// builds.
+#if defined(_MSC_VER)
+
+namespace flags_internal {
+
+ABSL_CONST_INIT static absl::Mutex construction_guard(absl::kConstInit);
+
+void LockGlobalConstructionGuard() { construction_guard.Lock(); }
+
+void UnlockGlobalConstructionGuard() { construction_guard.Unlock(); }
+
+}  // namespace flags_internal
+
+#endif
+
 }  // namespace absl