[libc-commits] [libc] c091dd4 - [libc] fix build errors (#95613)

via libc-commits libc-commits at lists.llvm.org
Fri Jun 14 15:59:45 PDT 2024


Author: Schrodinger ZHU Yifan
Date: 2024-06-14T15:59:42-07:00
New Revision: c091dd48008ba6d85aee68227077ee05daeb7ca7

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

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

Added: 
    

Modified: 
    libc/src/__support/threads/linux/rwlock.h
    libc/src/pthread/pthread_rwlock_timedrdlock.cpp
    libc/src/pthread/pthread_rwlock_timedwrlock.cpp
    libc/test/integration/src/pthread/CMakeLists.txt
    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 1778995cf3766..201fe92c37fc0 100644
--- a/libc/src/__support/threads/linux/rwlock.h
+++ b/libc/src/__support/threads/linux/rwlock.h
@@ -63,7 +63,7 @@ class WaitingQueue final : private RawMutex {
     WaitingQueue &queue;
     bool is_pshared;
 
-    LIBC_INLINE constexpr Guard(WaitingQueue &queue, bool is_pshared)
+    LIBC_INLINE Guard(WaitingQueue &queue, bool is_pshared)
         : queue(queue), is_pshared(is_pshared) {
       queue.lock(cpp::nullopt, is_pshared);
     }
@@ -189,6 +189,7 @@ class RwState {
       case Role::Writer:
         return !has_active_writer() && !has_pending_writer();
       }
+      __builtin_unreachable();
     } else
       return !has_acitve_owner();
   }

diff  --git a/libc/src/pthread/pthread_rwlock_timedrdlock.cpp b/libc/src/pthread/pthread_rwlock_timedrdlock.cpp
index d503d50b79f6c..6ce69ea738a93 100644
--- a/libc/src/pthread/pthread_rwlock_timedrdlock.cpp
+++ b/libc/src/pthread/pthread_rwlock_timedrdlock.cpp
@@ -42,8 +42,8 @@ LLVM_LIBC_FUNCTION(int, pthread_rwlock_timedrdlock,
     return EINVAL;
   case internal::AbsTimeout::Error::BeforeEpoch:
     return ETIMEDOUT;
-    // default: unreachable, all two cases are covered.
   }
+  __builtin_unreachable();
 }
 
 } // namespace LIBC_NAMESPACE

diff  --git a/libc/src/pthread/pthread_rwlock_timedwrlock.cpp b/libc/src/pthread/pthread_rwlock_timedwrlock.cpp
index 5e67730141946..ad3f913eb15aa 100644
--- a/libc/src/pthread/pthread_rwlock_timedwrlock.cpp
+++ b/libc/src/pthread/pthread_rwlock_timedwrlock.cpp
@@ -36,8 +36,8 @@ LLVM_LIBC_FUNCTION(int, pthread_rwlock_timedwrlock,
     return EINVAL;
   case internal::AbsTimeout::Error::BeforeEpoch:
     return ETIMEDOUT;
-    // default: unreachable, all two cases are covered.
   }
+  __builtin_unreachable();
 }
 
 } // namespace LIBC_NAMESPACE

diff  --git a/libc/test/integration/src/pthread/CMakeLists.txt b/libc/test/integration/src/pthread/CMakeLists.txt
index 16a1ff61887f8..fa5fd3ad55d5f 100644
--- a/libc/test/integration/src/pthread/CMakeLists.txt
+++ b/libc/test/integration/src/pthread/CMakeLists.txt
@@ -53,6 +53,7 @@ add_integration_test(
     libc.src.sys.wait.waitpid
     libc.src.stdlib.exit
     libc.src.__support.CPP.atomic
+    libc.src.__support.CPP.new
     libc.src.__support.threads.sleep
 )
 

diff  --git a/libc/test/integration/src/pthread/pthread_rwlock_test.cpp b/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
index a2ae2281d22d0..9175efea4be95 100644
--- a/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/__support/CPP/atomic.h"
+#include "src/__support/CPP/new.h"
 #include "src/__support/OSUtil/syscall.h"
 #include "src/__support/threads/linux/raw_mutex.h"
 #include "src/__support/threads/linux/rwlock.h"


        


More information about the libc-commits mailing list