[libc-commits] [libc] 2e7cb8c - [libc] Remove references to the std threads library from __support/threads.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Wed Mar 16 12:36:15 PDT 2022


Author: Siva Chandra Reddy
Date: 2022-03-16T19:35:40Z
New Revision: 2e7cb8c786dd965218b5de9b0d96c64d171ab1e4

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

LOG: [libc] Remove references to the std threads library from __support/threads.

Added: 
    

Modified: 
    libc/src/__support/threads/linux/mutex.h
    libc/src/__support/threads/mutex.h
    libc/src/threads/mtx_init.cpp

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/threads/linux/mutex.h b/libc/src/__support/threads/linux/mutex.h
index 00af4a2971373..e4e06e99b5eb2 100644
--- a/libc/src/__support/threads/linux/mutex.h
+++ b/libc/src/__support/threads/linux/mutex.h
@@ -16,7 +16,6 @@
 #include <linux/futex.h>
 #include <stdint.h>
 #include <sys/syscall.h> // For syscall numbers.
-#include <threads.h>
 
 namespace __llvm_libc {
 
@@ -55,12 +54,7 @@ struct Mutex {
     return MutexError::NONE;
   }
 
-  static MutexError init(mtx_t *m, bool istimed, bool isrecur, bool isrobust) {
-    auto *mutex = reinterpret_cast<Mutex *>(m);
-    return init(mutex, istimed, isrecur, isrobust);
-  }
-
-  static MutexError destroy(mtx_t *) { return MutexError::NONE; }
+  static MutexError destroy(Mutex *) { return MutexError::NONE; }
 
   MutexError reset();
 

diff  --git a/libc/src/__support/threads/mutex.h b/libc/src/__support/threads/mutex.h
index e717038712aa7..f585dcd1c32fa 100644
--- a/libc/src/__support/threads/mutex.h
+++ b/libc/src/__support/threads/mutex.h
@@ -53,10 +53,6 @@ enum class MutexError : int {
 
 namespace __llvm_libc {
 
-static_assert(sizeof(Mutex) <= sizeof(mtx_t),
-              "The public mtx_t type cannot accommodate the internal mutex "
-              "type.");
-
 // An RAII class for easy locking and unlocking of mutexes.
 class MutexLock {
   Mutex *mutex;

diff  --git a/libc/src/threads/mtx_init.cpp b/libc/src/threads/mtx_init.cpp
index f3d1ee66f1fe9..1e4da794f6369 100644
--- a/libc/src/threads/mtx_init.cpp
+++ b/libc/src/threads/mtx_init.cpp
@@ -13,8 +13,13 @@
 
 namespace __llvm_libc {
 
+static_assert(sizeof(Mutex) <= sizeof(mtx_t),
+              "The public mtx_t type cannot accommodate the internal mutex "
+              "type.");
+
 LLVM_LIBC_FUNCTION(int, mtx_init, (mtx_t * m, int type)) {
-  auto err = Mutex::init(m, type & mtx_timed, type & mtx_recursive, 0);
+  auto err = Mutex::init(reinterpret_cast<Mutex *>(m), type & mtx_timed,
+                         type & mtx_recursive, 0);
   return err == MutexError::NONE ? thrd_success : thrd_error;
 }
 


        


More information about the libc-commits mailing list