From 6bce3846ba4662d1e741ed04a667771253cf32ce Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Tue, 23 Jan 2024 16:33:24 -0800 Subject: [PATCH] Revert "Make the constexpr mutex constructor opt-in (#4000)" This reverts commit 782dcd536a57fd5c6a215d1b9a3014ba4c25282f. --- stl/inc/mutex | 12 ++++++------ tests/std/tests/VSO_0226079_mutex/env.lst | 2 +- tests/std/tests/VSO_0226079_mutex/test.cpp | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/stl/inc/mutex b/stl/inc/mutex index ce4c809f6a1..42f4067f503 100644 --- a/stl/inc/mutex +++ b/stl/inc/mutex @@ -32,18 +32,18 @@ _EXPORT_STD class condition_variable_any; class _Mutex_base { // base class for all mutex types public: -#ifdef _ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR +#ifdef _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR + _Mutex_base(int _Flags = 0) noexcept { + _Mtx_init_in_situ(_Mymtx(), _Flags | _Mtx_try); + } +#else // ^^^ _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR / !_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR vvv constexpr _Mutex_base(int _Flags = 0) noexcept { _Mtx_storage._Critical_section = {}; _Mtx_storage._Thread_id = -1; _Mtx_storage._Type = _Flags | _Mtx_try; _Mtx_storage._Count = 0; } -#else // ^^^ _ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR / !_ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR vvv - _Mutex_base(int _Flags = 0) noexcept { - _Mtx_init_in_situ(_Mymtx(), _Flags | _Mtx_try); - } -#endif // ^^^ !_ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR ^^^ +#endif // ^^^ !_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR ^^^ ~_Mutex_base() noexcept { _Mtx_destroy_in_situ(_Mymtx()); diff --git a/tests/std/tests/VSO_0226079_mutex/env.lst b/tests/std/tests/VSO_0226079_mutex/env.lst index de7171f19ca..d2b91697b4b 100644 --- a/tests/std/tests/VSO_0226079_mutex/env.lst +++ b/tests/std/tests/VSO_0226079_mutex/env.lst @@ -3,5 +3,5 @@ RUNALL_INCLUDE ..\impure_matrix.lst RUNALL_CROSSLIST -* PM_CL="/D_ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR" +* PM_CL="/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR" * PM_CL="" diff --git a/tests/std/tests/VSO_0226079_mutex/test.cpp b/tests/std/tests/VSO_0226079_mutex/test.cpp index dd84dd39d93..dd412444014 100644 --- a/tests/std/tests/VSO_0226079_mutex/test.cpp +++ b/tests/std/tests/VSO_0226079_mutex/test.cpp @@ -468,7 +468,7 @@ void test_vso_1253916() { do_shared_locked_things(shared_lock{mtx}); } -#ifdef _ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR +#ifndef _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR struct test_constexpr_ctor { constexpr test_constexpr_ctor() {} mutex mtx; @@ -478,7 +478,7 @@ test_constexpr_ctor obj; #if _HAS_CXX20 && !defined(_M_CEE) constinit test_constexpr_ctor obj2; #endif // _HAS_CXX20 && !defined(_M_CEE) -#endif // _ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR +#endif // !_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR int main() { {