From 505ec4cf25235dc688c1204a1ded245ccf943d8d Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Tue, 2 Nov 2021 21:12:10 +0200 Subject: [PATCH 1/7] Fully drop Vista Resolves #2286 Wanted to combine with #2309, but apparently constexpr mutex will have long way to go if ever succeeds --- stl/src/awint.hpp | 10 -------- stl/src/filesystem.cpp | 15 ------------ stl/src/primitives.hpp | 53 ++++-------------------------------------- stl/src/winapisupp.cpp | 5 ++-- 4 files changed, 6 insertions(+), 77 deletions(-) diff --git a/stl/src/awint.hpp b/stl/src/awint.hpp index 66eed7ab9c..657ab2e472 100644 --- a/stl/src/awint.hpp +++ b/stl/src/awint.hpp @@ -16,16 +16,6 @@ _CRT_BEGIN_C_HEADER _CRTIMP2 BOOL __cdecl __crtIsPackagedApp(); #endif // !defined(_CRT_WINDOWS) && !defined(UNDOCKED_WINDOWS_UCRT) -#if _STL_WIN32_WINNT >= _WIN32_WINNT_WIN7 - -#define __crtTryAcquireSRWLockExclusive(pLock) TryAcquireSRWLockExclusive(pLock) - -#else // _STL_WIN32_WINNT >= _WIN32_WINNT_WIN7 - -BOOLEAN __cdecl __crtTryAcquireSRWLockExclusive(_Inout_ PSRWLOCK); - -#endif // _STL_WIN32_WINNT >= _WIN32_WINNT_WIN7 - #if _STL_WIN32_WINNT >= _WIN32_WINNT_WIN8 #define __crtGetSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime) \ diff --git a/stl/src/filesystem.cpp b/stl/src/filesystem.cpp index 97a404bde0..d6112fdef5 100644 --- a/stl/src/filesystem.cpp +++ b/stl/src/filesystem.cpp @@ -230,21 +230,6 @@ static_assert(alignof(WIN32_FIND_DATAW) == alignof(__std_fs_find_data)); return __std_win_error::_Success; } -#if _STL_WIN32_WINNT < _WIN32_WINNT_WIN7 - // If the above call failed, we might be on pre Windows 7 / Windows Server 2008 R2, which doesn't support - // FindExInfoBasic; try again with FindExInfoStandard if we got an invalid parameter error. - const __std_win_error _Last_error{GetLastError()}; - if (_Last_error != __std_win_error::_Not_supported && _Last_error != __std_win_error::_Invalid_parameter) { - return _Last_error; - } - - *_Handle = __std_fs_dir_handle{reinterpret_cast( - FindFirstFileExW(_Path_spec, FindExInfoStandard, _Results, FindExSearchNameMatch, nullptr, 0))}; - if (*_Handle != __std_fs_dir_handle::_Invalid) { - return __std_win_error::_Success; - } -#endif // _STL_WIN32_WINNT < _WIN32_WINNT_WIN7 - return __std_win_error{GetLastError()}; } diff --git a/stl/src/primitives.hpp b/stl/src/primitives.hpp index f5e37f505f..381821515a 100644 --- a/stl/src/primitives.hpp +++ b/stl/src/primitives.hpp @@ -125,7 +125,7 @@ namespace Concurrency { } bool try_lock() override { - return __crtTryAcquireSRWLockExclusive(&m_srw_lock) != 0; + return TryAcquireSRWLockExclusive(&m_srw_lock) != 0; } bool try_lock_for(unsigned int) override { @@ -181,57 +181,12 @@ namespace Concurrency { CONDITION_VARIABLE m_condition_variable; }; - inline bool are_win7_sync_apis_available() { -#if _STL_WIN32_WINNT >= _WIN32_WINNT_WIN7 - return true; -#else - // TryAcquireSRWLockExclusive ONLY available on Windows 7+ - DYNAMICGETCACHEDFUNCTION( - PFNTRYACQUIRESRWLOCKEXCLUSIVE, TryAcquireSRWLockExclusive, pfTryAcquireSRWLockExclusive); - return pfTryAcquireSRWLockExclusive != nullptr; -#endif - } - inline void create_stl_critical_section(stl_critical_section_interface* p) { -#ifdef _CRT_WINDOWS new (p) stl_critical_section_win7; -#else - switch (__stl_sync_api_impl_mode) { - case __stl_sync_api_modes_enum::normal: - case __stl_sync_api_modes_enum::win7: - if (are_win7_sync_apis_available()) { - new (p) stl_critical_section_win7; - return; - } - // fall through - case __stl_sync_api_modes_enum::vista: - new (p) stl_critical_section_vista; - return; - default: - abort(); - } -#endif // _CRT_WINDOWS } inline void create_stl_condition_variable(stl_condition_variable_interface* p) { -#ifdef _CRT_WINDOWS new (p) stl_condition_variable_win7; -#else - switch (__stl_sync_api_impl_mode) { - case __stl_sync_api_modes_enum::normal: - case __stl_sync_api_modes_enum::win7: - if (are_win7_sync_apis_available()) { - new (p) stl_condition_variable_win7; - return; - } - // fall through - case __stl_sync_api_modes_enum::vista: - new (p) stl_condition_variable_vista; - return; - default: - abort(); - } -#endif // _CRT_WINDOWS } #if defined _CRT_WINDOWS @@ -242,9 +197,9 @@ namespace Concurrency { #elif defined _STL_CONCRT_SUPPORT #ifdef _WIN64 - const size_t sizeof_stl_critical_section_concrt = 64; - const size_t sizeof_stl_condition_variable_concrt = 72; - const size_t alignof_stl_critical_section_concrt = 8; + const size_t sizeof_stl_critical_section_concrt = 64; + const size_t sizeof_stl_condition_variable_concrt = 72; + const size_t alignof_stl_critical_section_concrt = 8; const size_t alignof_stl_condition_variable_concrt = 8; #else // ^^^ 64-bit / 32-bit vvv const size_t sizeof_stl_critical_section_concrt = 36; diff --git a/stl/src/winapisupp.cpp b/stl/src/winapisupp.cpp index aa583d138a..ec4d0e5ee8 100644 --- a/stl/src/winapisupp.cpp +++ b/stl/src/winapisupp.cpp @@ -337,10 +337,9 @@ extern "C" BOOL __cdecl __crtQueueUserWorkItem(_In_ LPTHREAD_START_ROUTINE, _In_ #if _STL_WIN32_WINNT < _WIN32_WINNT_WIN7 - +// TRANSITION, ABI: preserved for binary compatibility extern "C" BOOLEAN __cdecl __crtTryAcquireSRWLockExclusive(_Inout_ PSRWLOCK const pLock) { - DYNAMICGETCACHEDFUNCTION(PFNTRYACQUIRESRWLOCKEXCLUSIVE, TryAcquireSRWLockExclusive, pfTryAcquireSRWLockExclusive); - return pfTryAcquireSRWLockExclusive(pLock); + return TryAcquireSRWLockExclusive(pLock); // Don't have fallbacks because the only caller (in primitives.hpp) will check the existence before calling } From d172b909a960593c20712eab6f4355bc438f75f2 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Tue, 2 Nov 2021 21:39:20 +0200 Subject: [PATCH 2/7] missed typedef --- stl/src/awint.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/stl/src/awint.hpp b/stl/src/awint.hpp index 657ab2e472..2dbabd271c 100644 --- a/stl/src/awint.hpp +++ b/stl/src/awint.hpp @@ -87,7 +87,6 @@ enum wrapKERNEL32Functions { extern PVOID __KERNEL32Functions[eMaxKernel32Function]; using PFNGETSYSTEMTIMEPRECISEASFILETIME = VOID(WINAPI*)(LPFILETIME); -using PFNTRYACQUIRESRWLOCKEXCLUSIVE = BOOLEAN(WINAPI*)(PSRWLOCK); // Use this macro for caching a function pointer from a DLL #define STOREFUNCTIONPOINTER(instance, function_name) \ From 04a4e5727e113b1cdc4db3113aae8e4e26630b8b Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Wed, 3 Nov 2021 13:02:32 +0200 Subject: [PATCH 3/7] what fallback? --- stl/src/winapisupp.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/stl/src/winapisupp.cpp b/stl/src/winapisupp.cpp index ec4d0e5ee8..69974a9696 100644 --- a/stl/src/winapisupp.cpp +++ b/stl/src/winapisupp.cpp @@ -340,7 +340,6 @@ extern "C" BOOL __cdecl __crtQueueUserWorkItem(_In_ LPTHREAD_START_ROUTINE, _In_ // TRANSITION, ABI: preserved for binary compatibility extern "C" BOOLEAN __cdecl __crtTryAcquireSRWLockExclusive(_Inout_ PSRWLOCK const pLock) { return TryAcquireSRWLockExclusive(pLock); - // Don't have fallbacks because the only caller (in primitives.hpp) will check the existence before calling } #endif // _STL_WIN32_WINNT < _WIN32_WINNT_WIN7 From 811b6b426a615653965db5ea55e7d53c1d4509ed Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 27 May 2022 18:12:08 -0700 Subject: [PATCH 4/7] Increase `_STL_WIN32_WINNT` default to Win7. Note that the DLL build still overrides this to XP. --- stl/inc/yvals_core.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 40d7a928a0..653c17c65c 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -1565,6 +1565,7 @@ compiler option, or define _ALLOW_RTCc_IN_STL to acknowledge that you have recei #endif // defined(MRTDLL) && !defined(_M_CEE_PURE) #define _STL_WIN32_WINNT_VISTA 0x0600 // _WIN32_WINNT_VISTA from sdkddkver.h +#define _STL_WIN32_WINNT_WIN7 0x0601 // _WIN32_WINNT_WIN7 from sdkddkver.h #define _STL_WIN32_WINNT_WIN8 0x0602 // _WIN32_WINNT_WIN8 from sdkddkver.h #define _STL_WIN32_WINNT_WINBLUE 0x0603 // _WIN32_WINNT_WINBLUE from sdkddkver.h #define _STL_WIN32_WINNT_WIN10 0x0A00 // _WIN32_WINNT_WIN10 from sdkddkver.h @@ -1577,9 +1578,9 @@ compiler option, or define _ALLOW_RTCc_IN_STL to acknowledge that you have recei #elif defined(_M_ARM) || defined(_ONECORE) || defined(_CRT_APP) // The first ARM or OneCore or App Windows was Windows 8 #define _STL_WIN32_WINNT _STL_WIN32_WINNT_WIN8 -#else // ^^^ default to Win8 // default to Vista vvv -// The earliest Windows supported by this implementation is Windows Vista -#define _STL_WIN32_WINNT _STL_WIN32_WINNT_VISTA +#else // ^^^ default to Win8 // default to Win7 vvv +// The earliest Windows supported by this implementation is Windows 7 +#define _STL_WIN32_WINNT _STL_WIN32_WINNT_WIN7 #endif // ^^^ !defined(_M_ARM) && !defined(_M_ARM64) && !defined(_ONECORE) && !defined(_CRT_APP) ^^^ #endif // _STL_WIN32_WINNT From b0327b95a651c0bf1566d48b666ff361e160e6e0 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 27 May 2022 18:20:52 -0700 Subject: [PATCH 5/7] Remove `__stl_sync_api_impl_mode`. This is now dead - its value is never read. We need to keep `__set_stl_sync_api_mode()` as a no-op for the DLL's export surface, appropriately commented. (Long ago, this function was intended to allow testing of downlevel OS fallback codepaths on modern OS machines; it had no other purpose during normal operation.) Note that `__stl_sync_api_impl_mode` wasn't mentioned outside of `stl/src`, so we don't have to worry about previously compiled user code looking for it. --- stl/src/mutex.cpp | 8 +++----- stl/src/primitives.hpp | 4 ---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/stl/src/mutex.cpp b/stl/src/mutex.cpp index fcf0efcd19..031fb02b9c 100644 --- a/stl/src/mutex.cpp +++ b/stl/src/mutex.cpp @@ -32,11 +32,9 @@ extern "C" _CRTIMP2_PURE void _Thrd_abort(const char* msg) { // abort on precond #define _THREAD_ASSERT(expr, msg) ((void) 0) #endif // _THREAD_CHECKX -__stl_sync_api_modes_enum __stl_sync_api_impl_mode = __stl_sync_api_modes_enum::normal; - -extern "C" _CRTIMP2 void __cdecl __set_stl_sync_api_mode(__stl_sync_api_modes_enum mode) { - __stl_sync_api_impl_mode = mode; -} +// TRANSITION, ABI: preserved for binary compatibility +enum class __stl_sync_api_modes_enum { normal, win7, vista, concrt }; +extern "C" _CRTIMP2 void __cdecl __set_stl_sync_api_mode(__stl_sync_api_modes_enum) {} struct _Mtx_internal_imp_t { // ConcRT mutex int type; diff --git a/stl/src/primitives.hpp b/stl/src/primitives.hpp index 381821515a..7bf089226b 100644 --- a/stl/src/primitives.hpp +++ b/stl/src/primitives.hpp @@ -9,10 +9,6 @@ #include "awint.hpp" -enum class __stl_sync_api_modes_enum { normal, win7, vista, concrt }; - -extern __stl_sync_api_modes_enum __stl_sync_api_impl_mode; - namespace Concurrency { namespace details { class __declspec(novtable) stl_critical_section_interface { From 1c88e7df5430546f3d9b048101de60aec024cda5 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 27 May 2022 19:56:52 -0700 Subject: [PATCH 6/7] Temporary static_asserts before removing code. Passed for x86, x64, ARM, ARM64. --- stl/src/primitives.hpp | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/stl/src/primitives.hpp b/stl/src/primitives.hpp index 7bf089226b..cff23535e0 100644 --- a/stl/src/primitives.hpp +++ b/stl/src/primitives.hpp @@ -185,6 +185,35 @@ namespace Concurrency { new (p) stl_condition_variable_win7; } +// TEMPORARY VERIFICATION OF EXACT VALUES: +#ifdef _WIN64 + static_assert(sizeof(stl_critical_section_vista) == 48, "Verifying exact values."); + static_assert(sizeof(stl_condition_variable_vista) == 16, "Verifying exact values."); + static_assert(alignof(stl_critical_section_vista) == 8, "Verifying exact values."); + static_assert(alignof(stl_condition_variable_vista) == 8, "Verifying exact values."); + + static_assert(sizeof(stl_critical_section_win7) == 16, "Verifying exact values."); + static_assert(sizeof(stl_condition_variable_win7) == 16, "Verifying exact values."); + static_assert(alignof(stl_critical_section_win7) == 8, "Verifying exact values."); + static_assert(alignof(stl_condition_variable_win7) == 8, "Verifying exact values."); +#else // ^^^ 64-bit / 32-bit vvv + static_assert(sizeof(stl_critical_section_vista) == 28, "Verifying exact values."); + static_assert(sizeof(stl_condition_variable_vista) == 8, "Verifying exact values."); + static_assert(alignof(stl_critical_section_vista) == 4, "Verifying exact values."); + static_assert(alignof(stl_condition_variable_vista) == 4, "Verifying exact values."); + + static_assert(sizeof(stl_critical_section_win7) == 8, "Verifying exact values."); + static_assert(sizeof(stl_condition_variable_win7) == 8, "Verifying exact values."); + static_assert(alignof(stl_critical_section_win7) == 4, "Verifying exact values."); + static_assert(alignof(stl_condition_variable_win7) == 4, "Verifying exact values."); +#endif // ^^^ 32-bit ^^^ + + // TEMPORARY VERIFICATION OF SIZE FOR !defined(_CRT_WINDOWS) && !defined(_STL_CONCRT_SUPPORT) BELOW: + static_assert(sizeof(stl_critical_section_vista) >= sizeof(stl_critical_section_win7), + "Verifying sizeof(vista) >= sizeof(win7)."); + static_assert(sizeof(stl_condition_variable_vista) >= sizeof(stl_condition_variable_win7), + "Verifying sizeof(vista) >= sizeof(win7)."); + #if defined _CRT_WINDOWS const size_t stl_critical_section_max_size = sizeof(stl_critical_section_win7); const size_t stl_condition_variable_max_size = sizeof(stl_condition_variable_win7); @@ -216,6 +245,21 @@ namespace Concurrency { const size_t stl_condition_variable_max_alignment = __max(__max(alignof_stl_condition_variable_concrt, alignof(stl_condition_variable_vista)), alignof(stl_condition_variable_win7)); + + // TEMPORARY VERIFICATION OF SIZE: + static_assert(stl_critical_section_max_size == sizeof_stl_critical_section_concrt, + "Verifying that concrt is the maximum size."); + static_assert(stl_condition_variable_max_size == sizeof_stl_condition_variable_concrt, + "Verifying that concrt is the maximum size."); + + // TEMPORARY VERIFICATION OF ALIGNMENT: + static_assert(alignof_stl_critical_section_concrt == alignof(void*), "Verifying pointer alignment."); + static_assert(alignof_stl_condition_variable_concrt == alignof(void*), "Verifying pointer alignment."); + static_assert(alignof(stl_critical_section_vista) == alignof(void*), "Verifying pointer alignment."); + static_assert(alignof(stl_condition_variable_vista) == alignof(void*), "Verifying pointer alignment."); + static_assert(alignof(stl_critical_section_win7) == alignof(void*), "Verifying pointer alignment."); + static_assert(alignof(stl_condition_variable_win7) == alignof(void*), "Verifying pointer alignment."); + #else const size_t stl_critical_section_max_size = __max(sizeof(stl_critical_section_vista), sizeof(stl_critical_section_win7)); From b08c3fcdaad934698b0ba58ca3169aac32f92436 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 27 May 2022 20:29:41 -0700 Subject: [PATCH 7/7] Remove stl_critical_section_vista, stl_condition_variable_vista. --- stl/src/primitives.hpp | 175 +++++------------------------------------ 1 file changed, 20 insertions(+), 155 deletions(-) diff --git a/stl/src/primitives.hpp b/stl/src/primitives.hpp index cff23535e0..53d95f1eb8 100644 --- a/stl/src/primitives.hpp +++ b/stl/src/primitives.hpp @@ -3,7 +3,6 @@ #pragma once -#include // for __max #include #include @@ -29,81 +28,6 @@ namespace Concurrency { virtual void destroy() = 0; }; - class stl_critical_section_vista final : public stl_critical_section_interface { - public: - stl_critical_section_vista() { - InitializeCriticalSectionEx(&_M_critical_section, 4000, 0); - } - - stl_critical_section_vista(const stl_critical_section_vista&) = delete; - stl_critical_section_vista& operator=(const stl_critical_section_vista&) = delete; - ~stl_critical_section_vista() = delete; - - void destroy() override { - DeleteCriticalSection(&_M_critical_section); - } - - void lock() override { - EnterCriticalSection(&_M_critical_section); - } - - bool try_lock() override { - return TryEnterCriticalSection(&_M_critical_section) != 0; - } - - bool try_lock_for(unsigned int) override { - // STL will call try_lock_for once again if this call will not succeed - return stl_critical_section_vista::try_lock(); - } - - void unlock() override { - LeaveCriticalSection(&_M_critical_section); - } - - LPCRITICAL_SECTION native_handle() { - return &_M_critical_section; - } - - private: - CRITICAL_SECTION _M_critical_section; - }; - - class stl_condition_variable_vista final : public stl_condition_variable_interface { - public: - stl_condition_variable_vista() { - InitializeConditionVariable(&m_condition_variable); - } - - ~stl_condition_variable_vista() = delete; - stl_condition_variable_vista(const stl_condition_variable_vista&) = delete; - stl_condition_variable_vista& operator=(const stl_condition_variable_vista&) = delete; - - void destroy() override {} - - void wait(stl_critical_section_interface* lock) override { - if (!stl_condition_variable_vista::wait_for(lock, INFINITE)) { - std::terminate(); - } - } - - bool wait_for(stl_critical_section_interface* lock, unsigned int timeout) override { - return SleepConditionVariableCS(&m_condition_variable, - static_cast(lock)->native_handle(), timeout) - != 0; - } - - void notify_one() override { - WakeConditionVariable(&m_condition_variable); - } - - void notify_all() override { - WakeAllConditionVariable(&m_condition_variable); - } - - private: - CONDITION_VARIABLE m_condition_variable; - }; - class stl_critical_section_win7 final : public stl_critical_section_interface { public: stl_critical_section_win7() { @@ -185,90 +109,31 @@ namespace Concurrency { new (p) stl_condition_variable_win7; } -// TEMPORARY VERIFICATION OF EXACT VALUES: #ifdef _WIN64 - static_assert(sizeof(stl_critical_section_vista) == 48, "Verifying exact values."); - static_assert(sizeof(stl_condition_variable_vista) == 16, "Verifying exact values."); - static_assert(alignof(stl_critical_section_vista) == 8, "Verifying exact values."); - static_assert(alignof(stl_condition_variable_vista) == 8, "Verifying exact values."); - - static_assert(sizeof(stl_critical_section_win7) == 16, "Verifying exact values."); - static_assert(sizeof(stl_condition_variable_win7) == 16, "Verifying exact values."); - static_assert(alignof(stl_critical_section_win7) == 8, "Verifying exact values."); - static_assert(alignof(stl_condition_variable_win7) == 8, "Verifying exact values."); + const size_t sizeof_stl_critical_section_concrt = 64; + const size_t sizeof_stl_condition_variable_concrt = 72; + const size_t sizeof_stl_critical_section_vista = 48; + const size_t sizeof_stl_condition_variable_vista = 16; #else // ^^^ 64-bit / 32-bit vvv - static_assert(sizeof(stl_critical_section_vista) == 28, "Verifying exact values."); - static_assert(sizeof(stl_condition_variable_vista) == 8, "Verifying exact values."); - static_assert(alignof(stl_critical_section_vista) == 4, "Verifying exact values."); - static_assert(alignof(stl_condition_variable_vista) == 4, "Verifying exact values."); - - static_assert(sizeof(stl_critical_section_win7) == 8, "Verifying exact values."); - static_assert(sizeof(stl_condition_variable_win7) == 8, "Verifying exact values."); - static_assert(alignof(stl_critical_section_win7) == 4, "Verifying exact values."); - static_assert(alignof(stl_condition_variable_win7) == 4, "Verifying exact values."); + const size_t sizeof_stl_critical_section_concrt = 36; + const size_t sizeof_stl_condition_variable_concrt = 40; + const size_t sizeof_stl_critical_section_vista = 28; + const size_t sizeof_stl_condition_variable_vista = 8; #endif // ^^^ 32-bit ^^^ - // TEMPORARY VERIFICATION OF SIZE FOR !defined(_CRT_WINDOWS) && !defined(_STL_CONCRT_SUPPORT) BELOW: - static_assert(sizeof(stl_critical_section_vista) >= sizeof(stl_critical_section_win7), - "Verifying sizeof(vista) >= sizeof(win7)."); - static_assert(sizeof(stl_condition_variable_vista) >= sizeof(stl_condition_variable_win7), - "Verifying sizeof(vista) >= sizeof(win7)."); - -#if defined _CRT_WINDOWS - const size_t stl_critical_section_max_size = sizeof(stl_critical_section_win7); - const size_t stl_condition_variable_max_size = sizeof(stl_condition_variable_win7); +#if defined(_CRT_WINDOWS) + const size_t stl_critical_section_max_size = sizeof(stl_critical_section_win7); + const size_t stl_condition_variable_max_size = sizeof(stl_condition_variable_win7); +#elif defined(_STL_CONCRT_SUPPORT) + const size_t stl_critical_section_max_size = sizeof_stl_critical_section_concrt; + const size_t stl_condition_variable_max_size = sizeof_stl_condition_variable_concrt; +#else // vvv !defined(_CRT_WINDOWS) && !defined(_STL_CONCRT_SUPPORT) vvv + const size_t stl_critical_section_max_size = sizeof_stl_critical_section_vista; + const size_t stl_condition_variable_max_size = sizeof_stl_condition_variable_vista; +#endif // ^^^ !defined(_CRT_WINDOWS) && !defined(_STL_CONCRT_SUPPORT) ^^^ + + // concrt, vista, and win7 alignments are all identical to alignof(void*) const size_t stl_critical_section_max_alignment = alignof(stl_critical_section_win7); const size_t stl_condition_variable_max_alignment = alignof(stl_condition_variable_win7); -#elif defined _STL_CONCRT_SUPPORT - -#ifdef _WIN64 - const size_t sizeof_stl_critical_section_concrt = 64; - const size_t sizeof_stl_condition_variable_concrt = 72; - const size_t alignof_stl_critical_section_concrt = 8; - const size_t alignof_stl_condition_variable_concrt = 8; -#else // ^^^ 64-bit / 32-bit vvv - const size_t sizeof_stl_critical_section_concrt = 36; - const size_t sizeof_stl_condition_variable_concrt = 40; - const size_t alignof_stl_critical_section_concrt = 4; - const size_t alignof_stl_condition_variable_concrt = 4; -#endif // ^^^ 32-bit ^^^ - - const size_t stl_critical_section_max_size = - __max(__max(sizeof_stl_critical_section_concrt, sizeof(stl_critical_section_vista)), - sizeof(stl_critical_section_win7)); - const size_t stl_condition_variable_max_size = - __max(__max(sizeof_stl_condition_variable_concrt, sizeof(stl_condition_variable_vista)), - sizeof(stl_condition_variable_win7)); - const size_t stl_critical_section_max_alignment = - __max(__max(alignof_stl_critical_section_concrt, alignof(stl_critical_section_vista)), - alignof(stl_critical_section_win7)); - const size_t stl_condition_variable_max_alignment = - __max(__max(alignof_stl_condition_variable_concrt, alignof(stl_condition_variable_vista)), - alignof(stl_condition_variable_win7)); - - // TEMPORARY VERIFICATION OF SIZE: - static_assert(stl_critical_section_max_size == sizeof_stl_critical_section_concrt, - "Verifying that concrt is the maximum size."); - static_assert(stl_condition_variable_max_size == sizeof_stl_condition_variable_concrt, - "Verifying that concrt is the maximum size."); - - // TEMPORARY VERIFICATION OF ALIGNMENT: - static_assert(alignof_stl_critical_section_concrt == alignof(void*), "Verifying pointer alignment."); - static_assert(alignof_stl_condition_variable_concrt == alignof(void*), "Verifying pointer alignment."); - static_assert(alignof(stl_critical_section_vista) == alignof(void*), "Verifying pointer alignment."); - static_assert(alignof(stl_condition_variable_vista) == alignof(void*), "Verifying pointer alignment."); - static_assert(alignof(stl_critical_section_win7) == alignof(void*), "Verifying pointer alignment."); - static_assert(alignof(stl_condition_variable_win7) == alignof(void*), "Verifying pointer alignment."); - -#else - const size_t stl_critical_section_max_size = - __max(sizeof(stl_critical_section_vista), sizeof(stl_critical_section_win7)); - const size_t stl_condition_variable_max_size = - __max(sizeof(stl_condition_variable_vista), sizeof(stl_condition_variable_win7)); - const size_t stl_critical_section_max_alignment = - __max(alignof(stl_critical_section_vista), alignof(stl_critical_section_win7)); - const size_t stl_condition_variable_max_alignment = - __max(alignof(stl_condition_variable_vista), alignof(stl_condition_variable_win7)); -#endif } // namespace details } // namespace Concurrency