[libc-commits] [libc] [libc] posix cleanup: rework and enable unix_* locks for macOS (PR #189773)
via libc-commits
libc-commits at lists.llvm.org
Tue Mar 31 17:00:57 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 -- libc/src/__support/threads/unix_rwlock.h libc/test/src/__support/threads/linux/raw_rwlock_test.cpp libc/include/llvm-libc-macros/pthread-macros.h libc/include/llvm-libc-types/pthread_rwlock_t.h libc/src/pthread/pthread_rwlock_clockrdlock.cpp libc/src/pthread/pthread_rwlock_clockwrlock.cpp libc/src/pthread/pthread_rwlock_destroy.cpp libc/src/pthread/pthread_rwlock_init.cpp libc/src/pthread/pthread_rwlock_rdlock.cpp libc/src/pthread/pthread_rwlock_timedrdlock.cpp libc/src/pthread/pthread_rwlock_timedwrlock.cpp libc/src/pthread/pthread_rwlock_tryrdlock.cpp libc/src/pthread/pthread_rwlock_trywrlock.cpp libc/src/pthread/pthread_rwlock_unlock.cpp libc/src/pthread/pthread_rwlock_wrlock.cpp libc/test/integration/src/pthread/pthread_rwlock_test.cpp libc/src/__support/threads/raw_rwlock.h --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/libc/src/__support/threads/raw_rwlock.h b/libc/src/__support/threads/raw_rwlock.h
index 570757209..e92c0333e 100644
--- a/libc/src/__support/threads/raw_rwlock.h
+++ b/libc/src/__support/threads/raw_rwlock.h
@@ -147,7 +147,9 @@ public:
LIBC_INLINE constexpr bool has_pending_writer() const {
return state & PENDING_WRITER_BIT;
}
- LIBC_INLINE constexpr bool has_pending() const { return state & PENDING_MASK; }
+ LIBC_INLINE constexpr bool has_pending() const {
+ return state & PENDING_MASK;
+ }
LIBC_INLINE constexpr RwState set_writer_bit() const {
return RwState(state | ACTIVE_WRITER_BIT);
@@ -382,8 +384,7 @@ public:
LIBC_INLINE constexpr RawRwLock(Role preference = Role::Reader,
bool is_pshared = false)
: is_pshared(is_pshared),
- preference(static_cast<unsigned>(preference) & 1u), state(0),
- queue() {}
+ preference(static_cast<unsigned>(preference) & 1u), state(0), queue() {}
[[nodiscard]]
LIBC_INLINE LockResult try_read_lock() {
diff --git a/libc/src/__support/threads/unix_rwlock.h b/libc/src/__support/threads/unix_rwlock.h
index 92efee4a4..c0a8674d7 100644
--- a/libc/src/__support/threads/unix_rwlock.h
+++ b/libc/src/__support/threads/unix_rwlock.h
@@ -10,8 +10,8 @@
#define LLVM_LIBC_SRC___SUPPORT_THREADS_UNIX_RWLOCK_H
#include "hdr/types/pid_t.h"
-#include "src/__support/common.h"
#include "src/__support/CPP/atomic.h"
+#include "src/__support/common.h"
#include "src/__support/threads/identifier.h"
#include "src/__support/threads/raw_rwlock.h"
diff --git a/libc/test/integration/src/pthread/pthread_rwlock_test.cpp b/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
index 67551e414..57d336d07 100644
--- a/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
@@ -12,8 +12,8 @@
#include "src/__support/CPP/new.h"
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/macros/config.h"
-#include "src/__support/threads/raw_rwlock.h"
#include "src/__support/threads/raw_mutex.h"
+#include "src/__support/threads/raw_rwlock.h"
#include "src/__support/threads/sleep.h"
#include "src/pthread/pthread_create.h"
#include "src/pthread/pthread_join.h"
@@ -131,7 +131,8 @@ static void nullptr_test() {
// counts.
static void high_reader_count_test() {
pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;
- rwlock.__raw.__state = LIBC_NAMESPACE::rwlock::RwLockTester::full_reader_state();
+ rwlock.__raw.__state =
+ LIBC_NAMESPACE::rwlock::RwLockTester::full_reader_state();
ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_rdlock(&rwlock), EAGAIN);
ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_tryrdlock(&rwlock), EAGAIN);
// allocate 4 reader slots.
``````````
</details>
https://github.com/llvm/llvm-project/pull/189773
More information about the libc-commits
mailing list