[PATCH] D11781: Refactored pthread usage in libcxx

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 19 11:56:23 PDT 2015


EricWF added a comment.

In http://reviews.llvm.org/D11781#227606, @espositofulvio wrote:

> In http://reviews.llvm.org/D11781#227446, @EricWF wrote:
>
> > This patch has a long way to go but it has also come a long way. Here are a couple of problems I see with it.
> >
> > 2. This patch adds a lot of headers. libc++ has historically tried to keep the number of headers to a minimum for the reason that filesystem operations are expensive and its cheaper to include a few big headers as opposed to many small ones.
>
>
> I know but it was a request from reviewers so that platform specific decision were localized. I can obviously merge all of the support/mutex.h, support/thread.h and support/condition_variable.h in a single support/thread.h if that's the case.


Sorry for giving conflicting feedback. I'm happy with multiple headers for now. We can always address it later.


================
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
----------------
espositofulvio wrote:
> EricWF wrote:
> > I think this prevents __rs_mut from being initialized during constant initialization. (http://en.cppreference.com/w/cpp/language/constant_initialization)
> I think this falls in the second case:
> 
> Static or thread-local object of class type that is initialized by a constructor call, if the constructor is constexpr and all constructor arguments (including implicit conversions) are constant expressions, and if the initializers in the constructor's initializer list and the brace-or-equal initializers of the class memebers only contain constant expressions.
> 
> but I was actually relying on the fact that we have constexpr, which now I understand could not be the case.
The top of the documentation it shows the syntax that is required to get constant initialization. The initialization must have the form `T obj = <initalizer>`. I would be fine relying on constexpr though.


Repository:
  rL LLVM

http://reviews.llvm.org/D11781





More information about the cfe-commits mailing list