[libcxx-commits] [libcxx] hxie/semaphore debug2 (PR #180357)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Feb 7 09:13:13 PST 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 -- libcxx/test/std/thread/thread.semaphore/timed.debug.pass.cpp libcxx/src/atomic.cpp libcxx/test/std/thread/thread.semaphore/timed.pass.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/src/atomic.cpp b/libcxx/src/atomic.cpp
index f16c9bf1f..4d05815c7 100644
--- a/libcxx/src/atomic.cpp
+++ b/libcxx/src/atomic.cpp
@@ -102,7 +102,8 @@ static void __platform_wait_on_address(void const* __ptr, void const* __val, opt
static_assert(_Size == 8 || _Size == 4, "Can only wait on 8 bytes or 4 bytes value");
char buffer[_Size];
std::memcpy(&buffer, const_cast<const void*>(__val), _Size);
- auto __timeout_us = !__timeout_ns.has_value() ? uint32_t(0) : std::max(static_cast<uint32_t>(*__timeout_ns / 1000), uint32_t(1));
+ auto __timeout_us =
+ !__timeout_ns.has_value() ? uint32_t(0) : std::max(static_cast<uint32_t>(*__timeout_ns / 1000), uint32_t(1));
if constexpr (_Size == 4)
__ulock_wait(
UL_COMPARE_AND_WAIT, const_cast<void*>(__ptr), *reinterpret_cast<uint32_t const*>(&buffer), __timeout_us);
diff --git a/libcxx/test/std/thread/thread.semaphore/timed.debug.pass.cpp b/libcxx/test/std/thread/thread.semaphore/timed.debug.pass.cpp
index d032145f9..a89c5dcf2 100644
--- a/libcxx/test/std/thread/thread.semaphore/timed.debug.pass.cpp
+++ b/libcxx/test/std/thread/thread.semaphore/timed.debug.pass.cpp
@@ -18,12 +18,11 @@
#include <iostream>
#include <iomanip>
-
#include "make_test_thread.h"
#include "test_macros.h"
-void test(auto log_start){
- auto log = [log_start] ()-> auto& {
+void test(auto log_start) {
+ auto log = [log_start]() -> auto& {
using namespace std::chrono;
auto elapsed = steady_clock::now() - log_start;
@@ -39,12 +38,9 @@ void test(auto log_start){
auto milliseconds = duration_cast<std::chrono::milliseconds>(elapsed);
- std::cerr << "["
- << std::setw(2) << std::setfill('0') << hours.count() << ":"
- << std::setw(2) << std::setfill('0') << minutes.count() << ":"
- << std::setw(2) << std::setfill('0') << seconds.count() << "."
- << std::setw(3) << std::setfill('0') << milliseconds.count()
- << "] ";
+ std::cerr << "[" << std::setw(2) << std::setfill('0') << hours.count() << ":" << std::setw(2) << std::setfill('0')
+ << minutes.count() << ":" << std::setw(2) << std::setfill('0') << seconds.count() << "." << std::setw(3)
+ << std::setfill('0') << milliseconds.count() << "] ";
return std::cerr;
};
@@ -52,24 +48,24 @@ void test(auto log_start){
auto const start = std::chrono::steady_clock::now();
std::counting_semaphore<> s(0);
- log() << "start: try_acquire_until: start + " << std::chrono::milliseconds(250) << "\n";
+ log() << "start: try_acquire_until: start + " << std::chrono::milliseconds(250) << "\n";
assert(!s.try_acquire_until(start + std::chrono::milliseconds(250)));
- log() << "done: try_acquire_until: start + " << std::chrono::milliseconds(250) << "\n";
+ log() << "done: try_acquire_until: start + " << std::chrono::milliseconds(250) << "\n";
log() << "start: try_acquire_for: " << std::chrono::milliseconds(250) << "\n";
assert(!s.try_acquire_for(std::chrono::milliseconds(250)));
log() << "done: try_acquire_for: " << std::chrono::milliseconds(250) << "\n";
- std::thread t = support::make_test_thread([&](){
+ std::thread t = support::make_test_thread([&]() {
std::this_thread::sleep_for(std::chrono::milliseconds(250));
s.release();
std::this_thread::sleep_for(std::chrono::milliseconds(250));
s.release();
});
- log() << "start: try_acquire_until: start + " << std::chrono::seconds(2) << "\n";
+ log() << "start: try_acquire_until: start + " << std::chrono::seconds(2) << "\n";
assert(s.try_acquire_until(start + std::chrono::seconds(2)));
- log() << "done: try_acquire_until: start + " << std::chrono::seconds(2) << "\n";
+ log() << "done: try_acquire_until: start + " << std::chrono::seconds(2) << "\n";
log() << "start: try_acquire_for: " << std::chrono::seconds(2) << "\n";
assert(s.try_acquire_for(std::chrono::seconds(2)));
@@ -80,8 +76,7 @@ void test(auto log_start){
assert(end - start < std::chrono::seconds(10));
}
-int main(int, char**)
-{
+int main(int, char**) {
auto const log_start = std::chrono::steady_clock::now();
for (auto i = 0; i < 10; ++i) {
std::cerr << "=== Iteration " << i << " ===\n";
@@ -93,5 +88,4 @@ int main(int, char**)
#else
return 0;
#endif
-
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/180357
More information about the libcxx-commits
mailing list