diff options
| author | Eric Fiselier <eric@efcs.ca> | 2019-07-07 17:24:03 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2019-07-07 17:24:03 +0000 |
| commit | 8cedf04a6c86d6858f6ea96d463819ae18cb76fa (patch) | |
| tree | 5cbc4808568e46a7596f931ef4bf25344125ab8e /libcxx/include | |
| parent | 87210015581c52ac7fb153bf48659a72e75e36ed (diff) | |
| download | bcm5719-llvm-8cedf04a6c86d6858f6ea96d463819ae18cb76fa.tar.gz bcm5719-llvm-8cedf04a6c86d6858f6ea96d463819ae18cb76fa.zip | |
Make ~mutex and ~condition_variable trivial on Windows.
The implementations of __libcpp_mutex_destroy and __libcpp_condvar_destroy
are already NOPs, so this optimization is safe to perform.
See r365273 and PR27658 for more information.
llvm-svn: 365281
Diffstat (limited to 'libcxx/include')
| -rw-r--r-- | libcxx/include/__config | 13 | ||||
| -rw-r--r-- | libcxx/include/__mutex_base | 20 |
2 files changed, 18 insertions, 15 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config index 1ed51699932..1ecced9f479 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1098,13 +1098,22 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( #endif // The Apple, glibc, and Bionic implementation of pthreads implements -// pthread_mutex_destroy as nop for regular mutexes. +// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 +// mutexes have no destroy mechanism. // TODO(EricWF): Enable this optimization on Apple and Bionic platforms after // speaking to their respective stakeholders. -#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__) +#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \ + || defined(_LIBCPP_HAS_THREAD_API_WIN32) # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION #endif +// Destroying a condvar is a nop on Windows. +// TODO(EricWF): This is potentially true for some pthread implementations +// as well. +#if defined(_LIBCPP_HAS_THREAD_API_WIN32) +# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION +#endif + // Systems that use capability-based security (FreeBSD with Capsicum, // Nuxi CloudABI) may only provide local filesystem access (using *at()). // Functions like open(), rename(), unlink() and stat() should not be diff --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base index 61abae979ac..f828beaf780 100644 --- a/libcxx/include/__mutex_base +++ b/libcxx/include/__mutex_base @@ -282,26 +282,20 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status) class _LIBCPP_TYPE_VIS condition_variable { -#ifndef _LIBCPP_CXX03_LANG __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER; -#else - __libcpp_condvar_t __cv_; -#endif - public: _LIBCPP_INLINE_VISIBILITY -#ifndef _LIBCPP_CXX03_LANG - constexpr condition_variable() _NOEXCEPT = default; + _LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default; + +#ifdef _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION + ~condition_variable() = default; #else - condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;} -#endif ~condition_variable(); +#endif -private: - condition_variable(const condition_variable&); // = delete; - condition_variable& operator=(const condition_variable&); // = delete; + condition_variable(const condition_variable&) = delete; + condition_variable& operator=(const condition_variable&) = delete; -public: void notify_one() _NOEXCEPT; void notify_all() _NOEXCEPT; |

