aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorSchrodinger ZHU Yifan <yifanzhu@rochester.edu>2024-05-28 15:56:17 -0700
committerGitHub <noreply@github.com>2024-05-28 15:56:17 -0700
commit0694552cb7e8b2041fd5e765cf5b83fc40664087 (patch)
tree72bc6946c878ddc85e6ef87808b53fa4fccf46c1 /libc
parentf7c8a0339c64810a3c1b28d9b3b20e02a2be6232 (diff)
downloadllvm-0694552cb7e8b2041fd5e765cf5b83fc40664087.zip
llvm-0694552cb7e8b2041fd5e765cf5b83fc40664087.tar.gz
llvm-0694552cb7e8b2041fd5e765cf5b83fc40664087.tar.bz2
[libc] clean up MutexLock (#93619)
Diffstat (limited to 'libc')
-rw-r--r--libc/src/__support/threads/linux/CMakeLists.txt1
-rw-r--r--libc/src/__support/threads/linux/CndVar.cpp7
-rw-r--r--libc/src/__support/threads/mutex.h14
3 files changed, 5 insertions, 17 deletions
diff --git a/libc/src/__support/threads/linux/CMakeLists.txt b/libc/src/__support/threads/linux/CMakeLists.txt
index 39c4ad2..f6913ef 100644
--- a/libc/src/__support/threads/linux/CMakeLists.txt
+++ b/libc/src/__support/threads/linux/CMakeLists.txt
@@ -75,4 +75,5 @@ add_object_library(
libc.src.__support.OSUtil.osutil
libc.src.__support.threads.linux.futex_word_type
libc.src.__support.threads.mutex
+ libc.src.__support.CPP.mutex
)
diff --git a/libc/src/__support/threads/linux/CndVar.cpp b/libc/src/__support/threads/linux/CndVar.cpp
index daf56bc..b3a0fdb 100644
--- a/libc/src/__support/threads/linux/CndVar.cpp
+++ b/libc/src/__support/threads/linux/CndVar.cpp
@@ -7,9 +7,10 @@
//===----------------------------------------------------------------------===//
#include "src/__support/threads/CndVar.h"
+#include "src/__support/CPP/mutex.h"
#include "src/__support/OSUtil/syscall.h" // syscall_impl
#include "src/__support/threads/linux/futex_word.h" // FutexWordType
-#include "src/__support/threads/mutex.h" // Mutex, MutexLock
+#include "src/__support/threads/mutex.h" // Mutex
#include <sys/syscall.h> // For syscall numbers.
@@ -27,7 +28,7 @@ int CndVar::wait(Mutex *m) {
CndWaiter waiter;
{
- MutexLock ml(&qmtx);
+ cpp::lock_guard ml(qmtx);
CndWaiter *old_back = nullptr;
if (waitq_front == nullptr) {
waitq_front = waitq_back = &waiter;
@@ -83,7 +84,7 @@ void CndVar::notify_one() {
}
void CndVar::broadcast() {
- MutexLock ml(&qmtx);
+ cpp::lock_guard ml(qmtx);
uint32_t dummy_futex_word;
CndWaiter *waiter = waitq_front;
waitq_front = waitq_back = nullptr;
diff --git a/libc/src/__support/threads/mutex.h b/libc/src/__support/threads/mutex.h
index 9dded2e..392b389 100644
--- a/libc/src/__support/threads/mutex.h
+++ b/libc/src/__support/threads/mutex.h
@@ -43,18 +43,4 @@
#include "src/__support/threads/gpu/mutex.h"
#endif // __linux__
-namespace LIBC_NAMESPACE {
-
-// An RAII class for easy locking and unlocking of mutexes.
-class MutexLock {
- Mutex *mutex;
-
-public:
- explicit MutexLock(Mutex *m) : mutex(m) { mutex->lock(); }
-
- ~MutexLock() { mutex->unlock(); }
-};
-
-} // namespace LIBC_NAMESPACE
-
#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_MUTEX_H