diff options
| author | Asiri Rathnayake <asiri.rathnayake@arm.com> | 2016-05-06 14:06:29 +0000 |
|---|---|---|
| committer | Asiri Rathnayake <asiri.rathnayake@arm.com> | 2016-05-06 14:06:29 +0000 |
| commit | c7e4239fabf2c876449697caf05a342b01bf0312 (patch) | |
| tree | 9647e2a0dd535ba2c7d71b188db257a39a1956ea /libcxx/include/__mutex_base | |
| parent | a463d31a64833c24962a38aca79f4d2e12b7f4d0 (diff) | |
| download | bcm5719-llvm-c7e4239fabf2c876449697caf05a342b01bf0312.tar.gz bcm5719-llvm-c7e4239fabf2c876449697caf05a342b01bf0312.zip | |
Refactor pthread usage of libcxx.
This patch extracts out all the pthread dependencies of libcxx into the
new header __threading_support. The motivation is to make it easy to
re-target libcxx into platforms that do not support pthread.
Original patch from Fulvio Esposito (fulvio.esposito@outlook.com) - D11781
Applied with tweaks - D19412
Change-Id: I301111f0075de93dd8129416e06babc195aa936b
llvm-svn: 268734
Diffstat (limited to 'libcxx/include/__mutex_base')
| -rw-r--r-- | libcxx/include/__mutex_base | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base index 364c69e45d6..32536a6fe13 100644 --- a/libcxx/include/__mutex_base +++ b/libcxx/include/__mutex_base @@ -14,9 +14,7 @@ #include <__config> #include <chrono> #include <system_error> -#ifndef _LIBCPP_HAS_NO_THREADS -#include <pthread.h> -#endif +#include <__threading_support> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -36,14 +34,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex { - pthread_mutex_t __m_; + __libcpp_mutex_t __m_; public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_CONSTEXPR - constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {} + constexpr mutex() _NOEXCEPT : __m_(_LIBCPP_MUTEX_INITIALIZER) {} #else - mutex() _NOEXCEPT {__m_ = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;} + mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;} #endif ~mutex(); @@ -56,7 +54,7 @@ public: bool try_lock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true)); void unlock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()); - typedef pthread_mutex_t* native_handle_type; + typedef __libcpp_mutex_t* native_handle_type; _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;} }; @@ -276,13 +274,13 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status) class _LIBCPP_TYPE_VIS condition_variable { - pthread_cond_t __cv_; + __libcpp_condvar_t __cv_; public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_CONSTEXPR - constexpr condition_variable() : __cv_(PTHREAD_COND_INITIALIZER) {} + constexpr condition_variable() : __cv_(_LIBCPP_CONDVAR_INITIALIZER) {} #else - condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;} + condition_variable() {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;} #endif ~condition_variable(); @@ -321,7 +319,7 @@ public: const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); - typedef pthread_cond_t* native_handle_type; + typedef __libcpp_condvar_t* native_handle_type; _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__cv_;} private: |

