[libcxx-commits] [libcxx] [libc++] Use a custom once_flag implementation for locale::id::__get() (PR #212235)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 30 04:18:20 PDT 2026


================
@@ -159,11 +158,22 @@ private:
 };
 
 class _LIBCPP_EXPORTED_FROM_ABI locale::id {
-  once_flag __flag_;
-  int32_t __id_;
+#  ifdef _LIBCPP_ABI_COMPACT_LOCALE_ID
+  using __id_type _LIBCPP_NODEBUG = int32_t;
+#  elif defined(_LIBCPP_ABI_MICROSOFT)
+  using __id_type _LIBCPP_NODEBUG = uintptr_t;
+#  else
+  using __id_type _LIBCPP_NODEBUG = unsigned long;
+#  endif
+
+  __id_type __id_ = 0;
+
+#  ifndef _LIBCPP_ABI_COMPACT_LOCALE_ID
+  [[__maybe_unused__]] int32_t __dummy_ = 0;
----------------
ldionne wrote:

Can you add a comment explaining what's the purpose of this dummy? I assume it has to do with keeping the layout the same for ABI compat purposes?

https://github.com/llvm/llvm-project/pull/212235


More information about the libcxx-commits mailing list