[libc-commits] [libc] f00f11b - [libc] fix build errors (#95600)

via libc-commits libc-commits at lists.llvm.org
Fri Jun 14 14:50:16 PDT 2024


Author: Schrodinger ZHU Yifan
Date: 2024-06-14T14:50:12-07:00
New Revision: f00f11bf860cd7c4fe030cd43cc7e0d94825ca10

URL: https://github.com/llvm/llvm-project/commit/f00f11bf860cd7c4fe030cd43cc7e0d94825ca10
DIFF: https://github.com/llvm/llvm-project/commit/f00f11bf860cd7c4fe030cd43cc7e0d94825ca10.diff

LOG: [libc] fix build errors (#95600)

Bitfield conversion problem tested at: https://godbolt.org/z/dxjhs5Ghr

Added: 
    

Modified: 
    libc/src/__support/threads/linux/rwlock.h
    libc/test/integration/src/pthread/pthread_rwlock_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/threads/linux/rwlock.h b/libc/src/__support/threads/linux/rwlock.h
index 5db0590fd6aa0..1778995cf3766 100644
--- a/libc/src/__support/threads/linux/rwlock.h
+++ b/libc/src/__support/threads/linux/rwlock.h
@@ -370,8 +370,9 @@ class RwLock {
 public:
   LIBC_INLINE constexpr RwLock(Role preference = Role::Reader,
                                bool is_pshared = false)
-      : is_pshared(is_pshared), preference(static_cast<unsigned>(preference)),
-        state(0), writer_tid(0), queue() {}
+      : is_pshared(is_pshared),
+        preference(static_cast<unsigned>(preference) & 1u), state(0),
+        writer_tid(0), queue() {}
 
   [[nodiscard]]
   LIBC_INLINE LockResult try_read_lock() {

diff  --git a/libc/test/integration/src/pthread/pthread_rwlock_test.cpp b/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
index 215db1fc5addf..a2ae2281d22d0 100644
--- a/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
@@ -37,7 +37,6 @@
 #include "src/unistd/fork.h"
 #include "test/IntegrationTest/test.h"
 #include <errno.h>
-#include <optional>
 #include <pthread.h>
 #include <time.h>
 


        


More information about the libc-commits mailing list