diff --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base index 4940f931c97f..a6d5e79c4c86 100644 --- a/libcxx/include/__mutex_base +++ b/libcxx/include/__mutex_base @@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex { -#ifndef _LIBCPP_HAS_NO_CONSTEXPR +#ifndef _LIBCPP_CXX03_LANG __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER; #else __libcpp_mutex_t __m_; @@ -42,7 +42,7 @@ class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mut public: _LIBCPP_INLINE_VISIBILITY -#ifndef _LIBCPP_HAS_NO_CONSTEXPR +#ifndef _LIBCPP_CXX03_LANG constexpr mutex() _NOEXCEPT = default; #else mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;} @@ -66,7 +66,7 @@ struct _LIBCPP_TYPE_VIS defer_lock_t {}; struct _LIBCPP_TYPE_VIS try_to_lock_t {}; struct _LIBCPP_TYPE_VIS adopt_lock_t {}; -#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MUTEX) +#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_MUTEX) extern const defer_lock_t defer_lock; extern const try_to_lock_t try_to_lock; @@ -150,7 +150,7 @@ private: unique_lock& operator=(unique_lock const&); // = delete; public: -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY unique_lock(unique_lock&& __u) _NOEXCEPT : __m_(__u.__m_), __owns_(__u.__owns_) @@ -167,7 +167,7 @@ public: return *this; } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif // _LIBCPP_CXX03_LANG void lock(); bool try_lock(); @@ -279,7 +279,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status) class _LIBCPP_TYPE_VIS condition_variable { -#ifndef _LIBCPP_HAS_NO_CONSTEXPR +#ifndef _LIBCPP_CXX03_LANG __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER; #else __libcpp_condvar_t __cv_; @@ -287,7 +287,7 @@ class _LIBCPP_TYPE_VIS condition_variable public: _LIBCPP_INLINE_VISIBILITY -#ifndef _LIBCPP_HAS_NO_CONSTEXPR +#ifndef _LIBCPP_CXX03_LANG constexpr condition_variable() _NOEXCEPT = default; #else condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;} diff --git a/libcxx/include/mutex b/libcxx/include/mutex index f28d37c83e63..e92baa51ae75 100644 --- a/libcxx/include/mutex +++ b/libcxx/include/mutex @@ -191,7 +191,7 @@ template #include <__mutex_base> #include #include -#ifndef _LIBCPP_HAS_NO_VARIADICS +#ifndef _LIBCPP_CXX03_LANG #include #endif #include <__threading_support> @@ -343,7 +343,7 @@ try_lock(_L0& __l0, _L1& __l1) return 0; } -#ifndef _LIBCPP_HAS_NO_VARIADICS +#ifndef _LIBCPP_CXX03_LANG template int @@ -362,7 +362,7 @@ try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) return __r; } -#endif // _LIBCPP_HAS_NO_VARIADICS +#endif // _LIBCPP_CXX03_LANG template void @@ -391,7 +391,7 @@ lock(_L0& __l0, _L1& __l1) } } -#ifndef _LIBCPP_HAS_NO_VARIADICS +#ifndef _LIBCPP_CXX03_LANG template void @@ -466,7 +466,7 @@ void __unlock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { _VSTD::__unlock(__l2, __l3...); } -#endif // _LIBCPP_HAS_NO_VARIADICS +#endif // _LIBCPP_CXX03_LANG #if _LIBCPP_STD_VER > 14 template @@ -550,13 +550,13 @@ private: struct _LIBCPP_TEMPLATE_VIS once_flag; -#ifndef _LIBCPP_HAS_NO_VARIADICS +#ifndef _LIBCPP_CXX03_LANG template _LIBCPP_INLINE_VISIBILITY void call_once(once_flag&, _Callable&&, _Args&&...); -#else // _LIBCPP_HAS_NO_VARIADICS +#else // _LIBCPP_CXX03_LANG template _LIBCPP_INLINE_VISIBILITY @@ -566,7 +566,7 @@ template _LIBCPP_INLINE_VISIBILITY void call_once(once_flag&, const _Callable&); -#endif // _LIBCPP_HAS_NO_VARIADICS +#endif // _LIBCPP_CXX03_LANG struct _LIBCPP_TEMPLATE_VIS once_flag { @@ -580,11 +580,11 @@ private: unsigned long __state_; -#ifndef _LIBCPP_HAS_NO_VARIADICS +#ifndef _LIBCPP_CXX03_LANG template friend void call_once(once_flag&, _Callable&&, _Args&&...); -#else // _LIBCPP_HAS_NO_VARIADICS +#else // _LIBCPP_CXX03_LANG template friend void call_once(once_flag&, _Callable&); @@ -592,10 +592,10 @@ private: template friend void call_once(once_flag&, const _Callable&); -#endif // _LIBCPP_HAS_NO_VARIADICS +#endif // _LIBCPP_CXX03_LANG }; -#ifndef _LIBCPP_HAS_NO_VARIADICS +#ifndef _LIBCPP_CXX03_LANG template class __call_once_param @@ -650,7 +650,7 @@ __call_once_proxy(void* __vp) _LIBCPP_FUNC_VIS void __call_once(volatile unsigned long&, void*, void(*)(void*)); -#ifndef _LIBCPP_HAS_NO_VARIADICS +#ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_INLINE_VISIBILITY @@ -666,7 +666,7 @@ call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args) } } -#else // _LIBCPP_HAS_NO_VARIADICS +#else // _LIBCPP_CXX03_LANG template inline _LIBCPP_INLINE_VISIBILITY @@ -692,7 +692,7 @@ call_once(once_flag& __flag, const _Callable& __func) } } -#endif // _LIBCPP_HAS_NO_VARIADICS +#endif // _LIBCPP_CXX03_LANG _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/thread b/libcxx/include/thread index 874ce3ec196c..360b43d5e555 100644 --- a/libcxx/include/thread +++ b/libcxx/include/thread @@ -95,7 +95,7 @@ void sleep_for(const chrono::duration& rel_time); #include #include #include <__mutex_base> -#ifndef _LIBCPP_HAS_NO_VARIADICS +#ifndef _LIBCPP_CXX03_LANG #include #endif #include <__threading_support> @@ -291,7 +291,7 @@ public: _LIBCPP_INLINE_VISIBILITY thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {} -#ifndef _LIBCPP_HAS_NO_VARIADICS +#ifndef _LIBCPP_CXX03_LANG template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp&& __f, _Args&&... __args); -#else // _LIBCPP_HAS_NO_VARIADICS +#else // _LIBCPP_CXX03_LANG template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp __f); #endif ~thread(); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) {__t.__t_ = _LIBCPP_NULL_THREAD;} _LIBCPP_INLINE_VISIBILITY thread& operator=(thread&& __t) _NOEXCEPT; -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif // _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY void swap(thread& __t) _NOEXCEPT {_VSTD::swap(__t_, __t.__t_);} @@ -329,7 +329,7 @@ public: static unsigned hardware_concurrency() _NOEXCEPT; }; -#ifndef _LIBCPP_HAS_NO_VARIADICS +#ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_INLINE_VISIBILITY @@ -369,7 +369,18 @@ thread::thread(_Fp&& __f, _Args&&... __args) __throw_system_error(__ec, "thread constructor failed"); } -#else // _LIBCPP_HAS_NO_VARIADICS +inline +thread& +thread::operator=(thread&& __t) _NOEXCEPT +{ + if (!__libcpp_thread_isnull(&__t_)) + terminate(); + __t_ = __t.__t_; + __t.__t_ = _LIBCPP_NULL_THREAD; + return *this; +} + +#else // _LIBCPP_CXX03_LANG template struct __thread_invoke_pair { @@ -404,22 +415,7 @@ thread::thread(_Fp __f) __throw_system_error(__ec, "thread constructor failed"); } -#endif // _LIBCPP_HAS_NO_VARIADICS - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - -inline -thread& -thread::operator=(thread&& __t) _NOEXCEPT -{ - if (!__libcpp_thread_isnull(&__t_)) - terminate(); - __t_ = __t.__t_; - __t.__t_ = _LIBCPP_NULL_THREAD; - return *this; -} - -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif // _LIBCPP_CXX03_LANG inline _LIBCPP_INLINE_VISIBILITY void swap(thread& __x, thread& __y) _NOEXCEPT {__x.swap(__y);} diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp index 245c480885b8..a0071cd6594e 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp @@ -188,7 +188,7 @@ int main() } } #endif -#ifndef _LIBCPP_HAS_NO_VARIADICS +#if TEST_STD_VER >= 11 { L0 l0; L0 l1; @@ -518,5 +518,5 @@ int main() } } #endif // TEST_HAS_NO_EXCEPTIONS -#endif // _LIBCPP_HAS_NO_VARIADICS +#endif // TEST_STD_VER >= 11 } diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp index fb563cbe0b14..4ad7a3ac2853 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp @@ -126,7 +126,7 @@ int main() } } #endif -#ifndef _LIBCPP_HAS_NO_VARIADICS +#if TEST_STD_VER >= 11 { L0 l0; L0 l1; @@ -522,5 +522,5 @@ int main() assert(!l2.locked()); assert(!l3.locked()); } -#endif // _LIBCPP_HAS_NO_VARIADICS +#endif // TEST_STD_VER >= 11 } diff --git a/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp index 138b657196da..dfd2f10b79e2 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp @@ -66,7 +66,7 @@ void f3() #endif } -#ifndef _LIBCPP_HAS_NO_VARIADICS +#if TEST_STD_VER >= 11 struct init1 { @@ -101,7 +101,7 @@ void f2() std::call_once(flg2, init2(), 4, 5); } -#endif // _LIBCPP_HAS_NO_VARIADICS +#endif // TEST_STD_VER >= 11 std::once_flag flg41; std::once_flag flg42; @@ -135,7 +135,7 @@ void f42() std::call_once(flg41, init41); } -#ifndef _LIBCPP_HAS_NO_VARIADICS +#if TEST_STD_VER >= 11 class MoveOnly { @@ -174,7 +174,6 @@ public: void operator()(int&) {} }; -#if TEST_STD_VER >= 11 // reference qualifiers on functions are a C++11 extension struct RefQual { @@ -185,8 +184,8 @@ struct RefQual void operator()() & { ++lv_called; } void operator()() && { ++rv_called; } }; -#endif -#endif + +#endif // TEST_STD_VER >= 11 int main() { @@ -218,7 +217,7 @@ int main() assert(init41_called == 1); assert(init42_called == 1); } -#ifndef _LIBCPP_HAS_NO_VARIADICS +#if TEST_STD_VER >= 11 // check functors with 1 arg { std::thread t0(f1); @@ -245,7 +244,6 @@ int main() int i = 0; std::call_once(f, NonCopyable(), i); } -#if TEST_STD_VER >= 11 // reference qualifiers on functions are a C++11 extension { std::once_flag f1, f2; @@ -255,6 +253,5 @@ int main() std::call_once(f2, std::move(rq)); assert(rq.rv_called == 1); } -#endif -#endif // _LIBCPP_HAS_NO_VARIADICS +#endif // TEST_STD_VER >= 11 } diff --git a/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp index 6995f0648335..21011ed17cd9 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp @@ -14,13 +14,14 @@ // constexpr once_flag() noexcept; #include +#include "test_macros.h" int main() { { std::once_flag f; } -#ifndef _LIBCPP_HAS_NO_CONSTEXPR +#if TEST_STD_VER >= 11 { constexpr std::once_flag f; }