Skip to content

Commit

Permalink
Revert "Make the constexpr mutex constructor opt-in (#4000)" (#4339)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
  • Loading branch information
CaseyCarter and StephanTLavavej authored Jan 25, 2024
1 parent 223e297 commit 4aad4b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions stl/inc/mutex
Original file line number Diff line number Diff line change
Expand Up @@ -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 // ^^^ defined(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) / !defined(_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 // ^^^ !defined(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) ^^^

~_Mutex_base() noexcept {
_Mtx_destroy_in_situ(_Mymtx());
Expand Down
2 changes: 1 addition & 1 deletion tests/std/tests/VSO_0226079_mutex/env.lst
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
4 changes: 2 additions & 2 deletions tests/std/tests/VSO_0226079_mutex/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ void test_vso_1253916() {
do_shared_locked_things(shared_lock<shared_mutex>{mtx});
}

#ifdef _ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
#ifndef _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
struct test_constexpr_ctor {
constexpr test_constexpr_ctor() {}
mutex mtx;
Expand All @@ -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 // !defined(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)

int main() {
{
Expand Down

0 comments on commit 4aad4b8

Please sign in to comment.