Some pthread implementations use volatile types in their structs.
C++11 does not allow initializing volatile types in constexpr constructors.
This fixes building libcxx on musl-libc and NetBSD.
elram on Jun 23 2016, 1:00 AM.Authored by
@joerg. I think this has been fixed in newer versions of NetBSD.
Sure would be nice if someone could fix this on the MUSL side of things.
See https://bugs.musicpd.org/view.php?id=4110 for fun conversations about mutex, PTHREAD_MUTEX_INIT and constexpr.
Also, the first revision of this review:
C++03 does not support default member initializers but libc++ provides both of these classes an extensions in C++03.
I think the current patch looks good for C++11, but a fallback implementation is needed for C++03.
Small side question: so how are __m_ and __cv_ initialized in this setup? is it that pthread_mutex_lock() and the like would be able to handle an un-initialized blob of memory (in a thread-safe way)? Because I don't see a call to pthread_mutex_init() anywhere in the code-path.
__m_ and __cv_ are initialized during non-static data member initialization. They didn't previously call pthread_mutex_lock(), instead they directly initialized 'm_' and 'cv_' in the constructors initializer list.
And according to the current spec we are allowed to use PTHREAD_MUTEX_INITIALIZER to initialize non-static mutexes.