[libcxx-commits] [libcxx] [libc++] Use a custom once_flag implementation for locale::id::__get() (PR #212235)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jul 27 06:28:54 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions ,cpp,h -- libcxx/include/__configuration/abi.h libcxx/include/__locale libcxx/src/locale.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/__locale b/libcxx/include/__locale
index c04320a06..5f1e6a968 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -168,9 +168,9 @@ class _LIBCPP_EXPORTED_FROM_ABI locale::id {
__id_type __id_ = 0;
-#ifndef _LIBCPP_ABI_COMPACT_LOCALE_ID
+# ifndef _LIBCPP_ABI_COMPACT_LOCALE_ID
[[__maybe_unused__]] int32_t __dummy_ = 0;
-#endif
+# endif
public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR id() = default;
diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp
index deb1ebe59..1c74d826b 100644
--- a/libcxx/src/locale.cpp
+++ b/libcxx/src/locale.cpp
@@ -574,9 +574,9 @@ long locale::id::__get() {
return val - first_id;
if (val == uninitialized && __libcpp_atomic_compare_exchange(&__id_, &val, pending)) {
- auto new_id = __libcpp_atomic_add(&next_id, 1) - 1;
- __libcpp_atomic_store(&__id_, new_id);
- return new_id - first_id;
+ auto new_id = __libcpp_atomic_add(&next_id, 1) - 1;
+ __libcpp_atomic_store(&__id_, new_id);
+ return new_id - first_id;
}
// Another thread is already initializing __id_. Wait for that in a spin loop. The initialization should be incredibly
``````````
</details>
https://github.com/llvm/llvm-project/pull/212235
More information about the libcxx-commits
mailing list