Skip to content

Commit 4aad4b8

Browse files
Revert "Make the constexpr mutex constructor opt-in (#4000)" (#4339)
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
1 parent 223e297 commit 4aad4b8

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

stl/inc/mutex

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ _EXPORT_STD class condition_variable_any;
3232

3333
class _Mutex_base { // base class for all mutex types
3434
public:
35-
#ifdef _ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
35+
#ifdef _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
36+
_Mutex_base(int _Flags = 0) noexcept {
37+
_Mtx_init_in_situ(_Mymtx(), _Flags | _Mtx_try);
38+
}
39+
#else // ^^^ defined(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) / !defined(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) vvv
3640
constexpr _Mutex_base(int _Flags = 0) noexcept {
3741
_Mtx_storage._Critical_section = {};
3842
_Mtx_storage._Thread_id = -1;
3943
_Mtx_storage._Type = _Flags | _Mtx_try;
4044
_Mtx_storage._Count = 0;
4145
}
42-
#else // ^^^ _ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR / !_ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR vvv
43-
_Mutex_base(int _Flags = 0) noexcept {
44-
_Mtx_init_in_situ(_Mymtx(), _Flags | _Mtx_try);
45-
}
46-
#endif // ^^^ !_ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR ^^^
46+
#endif // ^^^ !defined(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) ^^^
4747

4848
~_Mutex_base() noexcept {
4949
_Mtx_destroy_in_situ(_Mymtx());

tests/std/tests/VSO_0226079_mutex/env.lst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
RUNALL_INCLUDE ..\impure_matrix.lst
55
RUNALL_CROSSLIST
6-
* PM_CL="/D_ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR"
6+
* PM_CL="/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR"
77
* PM_CL=""

tests/std/tests/VSO_0226079_mutex/test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ void test_vso_1253916() {
468468
do_shared_locked_things(shared_lock<shared_mutex>{mtx});
469469
}
470470

471-
#ifdef _ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
471+
#ifndef _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
472472
struct test_constexpr_ctor {
473473
constexpr test_constexpr_ctor() {}
474474
mutex mtx;
@@ -478,7 +478,7 @@ test_constexpr_ctor obj;
478478
#if _HAS_CXX20 && !defined(_M_CEE)
479479
constinit test_constexpr_ctor obj2;
480480
#endif // _HAS_CXX20 && !defined(_M_CEE)
481-
#endif // _ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
481+
#endif // !defined(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
482482

483483
int main() {
484484
{

0 commit comments

Comments
 (0)