[libcxx-commits] [PATCH] D113065: [libcxx][SystemZ][z/OS] Update libcxx/src/debug.cpp to accommodate POSIX(OFF)

Daniel McIntosh via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 4 18:28:33 PDT 2021


DanielMcIntosh-IBM updated this revision to Diff 384934.
DanielMcIntosh-IBM added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113065/new/

https://reviews.llvm.org/D113065

Files:
  libcxx/src/debug.cpp


Index: libcxx/src/debug.cpp
===================================================================
--- libcxx/src/debug.cpp
+++ libcxx/src/debug.cpp
@@ -62,7 +62,27 @@
 {
 
 #ifndef _LIBCPP_HAS_NO_THREADS
-typedef mutex mutex_type;
+/// Simple wrapper around std::mutex that checks the threading API is enabled before doing anything.
+class mutex_check_threading : public mutex {
+public:
+    void lock() {
+        if (!__libcpp_is_threading_api_enabled())
+            return;
+        mutex::lock();
+    }
+    bool try_lock() {
+        if (!__libcpp_is_threading_api_enabled())
+            return true;
+        return mutex::try_lock();
+    }
+    void unlock() {
+        if (!__libcpp_is_threading_api_enabled())
+            return;
+        mutex::unlock();
+    }
+};
+
+typedef mutex_check_threading mutex_type;
 typedef lock_guard<mutex_type> WLock;
 typedef lock_guard<mutex_type> RLock;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113065.384934.patch
Type: text/x-patch
Size: 905 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211105/75b6b503/attachment.bin>


More information about the libcxx-commits mailing list