[PATCH] D19412: [libcxx] Refactor pthread usage - II

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 27 12:02:28 PDT 2016


mclow.lists added a comment.

In general, I'm happy with this direction. I think we need to check that there are no ABI changes that happen here (I don't see any, but I'll keep looking), and I think the stuff in `<__os_support>` should be marked "always inline"

On a bikeshed note: is `<__os_support>` the right name? Or should it be something like `<__thread>`  or `<__threading_support>`?


================
Comment at: include/__os_support:32
@@ +31,3 @@
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __os_mutex_init(__libcpp_mutex* __m, bool is_recursive = false)
----------------
These should all be marked with `_LIBCPP_ALWAYS_INLINE`.

================
Comment at: src/algorithm.cpp:51
@@ -50,3 +50,3 @@
 #ifndef _LIBCPP_HAS_NO_THREADS
-static pthread_mutex_t __rs_mut = PTHREAD_MUTEX_INITIALIZER;
+static mutex __rs_mut;
 #endif
----------------
What happened to the initializer here?

================
Comment at: src/memory.cpp:130
@@ -129,11 +129,3 @@
 static const std::size_t __sp_mut_count = 16;
-static pthread_mutex_t mut_back_imp[__sp_mut_count] =
-{
-    PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,
-    PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,
-    PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,
-    PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER
-};
-
-static mutex* mut_back = reinterpret_cast<std::mutex*>(mut_back_imp);
+static mutex mut_back[__sp_mut_count];
 
----------------
How does this array get initialized now?

================
Comment at: src/mutex.cpp:201
@@ -222,1 +200,3 @@
+static mutex mut;
+static condition_variable cv;
 #endif
----------------
These two variables used to be initialized. Now they're not.


http://reviews.llvm.org/D19412





More information about the cfe-commits mailing list