From 036ea5953b197e79caf69d39d938d8a80c004ec8 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 10 Aug 2023 17:44:26 -0700 Subject: [PATCH] Various cleanups (#3935) --- CMakeLists.txt | 10 +++---- README.md | 4 +-- azure-devops/provision-image.ps1 | 2 +- benchmarks/CMakeLists.txt | 8 +++--- stl/inc/algorithm | 2 -- stl/inc/complex | 2 +- stl/inc/exception | 4 +-- stl/inc/experimental/coroutine | 8 +++--- stl/inc/format | 12 +++++---- stl/inc/hash_map | 4 +-- stl/inc/hash_set | 4 +-- stl/inc/istream | 4 +-- stl/inc/iterator | 2 -- stl/inc/random | 10 +++++-- stl/inc/ratio | 2 +- stl/inc/type_traits | 2 -- stl/inc/vector | 3 +-- stl/inc/xcall_once.h | 2 ++ stl/inc/xhash | 8 ++---- stl/inc/xstring | 5 ++-- stl/inc/xthreads.h | 26 +++++++------------ stl/inc/xtimec.h | 3 +++ stl/inc/yvals_core.h | 6 ----- stl/src/StlCompareStringA.cpp | 2 +- stl/src/StlCompareStringW.cpp | 2 +- stl/src/StlLCMapStringA.cpp | 2 +- stl/src/StlLCMapStringW.cpp | 2 +- stl/src/cond.cpp | 6 +---- stl/src/mutex.cpp | 12 +++------ stl/src/primitives.hpp | 10 ------- stl/src/uncaught_exception.cpp | 3 ++- stl/src/uncaught_exceptions.cpp | 2 +- stl/src/xmath.hpp | 4 +-- .../std/tests/P0811R3_midpoint_lerp/test.cpp | 2 +- .../std/tests/P0896R4_views_elements/test.cpp | 2 +- .../std/tests/P2278R4_views_as_const/test.cpp | 2 +- 36 files changed, 75 insertions(+), 109 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47f6022e0..62756db88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ option(STL_USE_ANALYZE "Pass the /analyze flag to MSVC" OFF) set(VCLIBS_EXPLICIT_MACHINE "") -if("${VCLIBS_TARGET_ARCHITECTURE}" MATCHES "^x86$") +if("${VCLIBS_TARGET_ARCHITECTURE}" STREQUAL "x86") set(VCLIBS_TARGET_ARCHITECTURE "x86") set(VCLIBS_I386_OR_AMD64 "i386") set(VCLIBS_X86_OR_X64 "x86") @@ -58,22 +58,22 @@ if("${VCLIBS_TARGET_ARCHITECTURE}" MATCHES "^x86$") # runtime dynamic linking by setting our own _STL_WIN32_WINNT back to Windows XP. add_compile_definitions(_X86_ _VCRT_WIN32_WINNT=0x0501 _STL_WIN32_WINNT=0x0501) add_compile_options($<$:/arch:IA32>) -elseif(VCLIBS_TARGET_ARCHITECTURE MATCHES "^x64$") +elseif(VCLIBS_TARGET_ARCHITECTURE STREQUAL "x64") set(VCLIBS_TARGET_ARCHITECTURE "x64") set(VCLIBS_I386_OR_AMD64 "amd64") set(VCLIBS_X86_OR_X64 "x64") add_compile_definitions(_AMD64_ _VCRT_WIN32_WINNT=0x0501 _STL_WIN32_WINNT=0x0501) -elseif(VCLIBS_TARGET_ARCHITECTURE MATCHES "^armv7$") +elseif(VCLIBS_TARGET_ARCHITECTURE STREQUAL "armv7") set(VCLIBS_TARGET_ARCHITECTURE "arm") set(VCLIBS_I386_OR_AMD64 "arm") set(VCLIBS_X86_OR_X64 "arm") add_compile_definitions(_ARM_ _VCRT_WIN32_WINNT=0x0602 _STL_WIN32_WINNT=0x0602) -elseif(VCLIBS_TARGET_ARCHITECTURE MATCHES "^arm64$") +elseif(VCLIBS_TARGET_ARCHITECTURE STREQUAL "arm64") set(VCLIBS_TARGET_ARCHITECTURE "arm64") set(VCLIBS_I386_OR_AMD64 "arm64") set(VCLIBS_X86_OR_X64 "arm64") add_compile_definitions(_ARM64_ _VCRT_WIN32_WINNT=0x0A00 _STL_WIN32_WINNT=0x0A00) -elseif(VCLIBS_TARGET_ARCHITECTURE MATCHES "^arm64ec$") +elseif(VCLIBS_TARGET_ARCHITECTURE STREQUAL "arm64ec") set(VCLIBS_TARGET_ARCHITECTURE "arm64ec") set(VCLIBS_I386_OR_AMD64 "arm64ec") set(VCLIBS_X86_OR_X64 "arm64") # Yes, really: `%VCToolsInstallDir%lib\arm64ec` only contains the Link Options diff --git a/README.md b/README.md index c3ea0da31..44333b0cd 100644 --- a/README.md +++ b/README.md @@ -549,5 +549,5 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception [lit]: https://llvm.org/docs/CommandGuide/lit.html [lit result codes]: https://llvm.org/docs/CommandGuide/lit.html#test-status-results [opencode@microsoft.com]: mailto:opencode@microsoft.com -[redistributables]: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads -[natvis documentation]: https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects +[redistributables]: https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist +[natvis documentation]: https://learn.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects diff --git a/azure-devops/provision-image.ps1 b/azure-devops/provision-image.ps1 index 4b09f5597..d6de6a305 100644 --- a/azure-devops/provision-image.ps1 +++ b/azure-devops/provision-image.ps1 @@ -84,7 +84,7 @@ if ([string]::IsNullOrEmpty($AdminUserPassword)) { } else { Write-Host 'AdminUser password supplied; switching to AdminUser.' - # https://docs.microsoft.com/en-us/sysinternals/downloads/psexec + # https://learn.microsoft.com/en-us/sysinternals/downloads/psexec $PsToolsZipUrl = 'https://download.sysinternals.com/files/PSTools.zip' Write-Host "Downloading: $PsToolsZipUrl" $ExtractedPsToolsPath = DownloadAndExtractZip -Url $PsToolsZipUrl diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 11df4398d..d9b35a2e6 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -19,13 +19,13 @@ if(DEFINED STL_BINARY_DIR) string(TOLOWER "${VCLIBS_TARGET_ARCHITECTURE}" VCLIBS_TARGET_ARCHITECTURE) - if("${VCLIBS_TARGET_ARCHITECTURE}" MATCHES "^x86$") + if("${VCLIBS_TARGET_ARCHITECTURE}" STREQUAL "x86") set(VCLIBS_I386_OR_AMD64 "i386") - elseif(VCLIBS_TARGET_ARCHITECTURE MATCHES "^x64$") + elseif(VCLIBS_TARGET_ARCHITECTURE STREQUAL "x64") set(VCLIBS_I386_OR_AMD64 "amd64") - elseif(VCLIBS_TARGET_ARCHITECTURE MATCHES "^armv7$") + elseif(VCLIBS_TARGET_ARCHITECTURE STREQUAL "armv7") set(VCLIBS_I386_OR_AMD64 "arm") - elseif(VCLIBS_TARGET_ARCHITECTURE MATCHES "^arm64$") + elseif(VCLIBS_TARGET_ARCHITECTURE STREQUAL "arm64") set(VCLIBS_I386_OR_AMD64 "arm64") else() message(FATAL_ERROR "Could not determine target architecture: VCLIBS_TARGET_ARCHITECTURE: ${VCLIBS_TARGET_ARCHITECTURE}") diff --git a/stl/inc/algorithm b/stl/inc/algorithm index a00976f2d..29579e712 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -4148,9 +4148,7 @@ _FwdIt2 remove_copy_if(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _P _REQUIRE_CPP17_MUTABLE_ITERATOR(_FwdIt2); return _STD remove_copy_if(_First, _Last, _Dest, _Pass_fn(_Pred)); } -#endif // _HAS_CXX17 -#if _HAS_CXX17 _EXPORT_STD template = 0> _NODISCARD_REMOVE_ALG _FwdIt remove(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, const _Ty& _Val) noexcept; // terminates diff --git a/stl/inc/complex b/stl/inc/complex index 1042faaef..eb192359b 100644 --- a/stl/inc/complex +++ b/stl/inc/complex @@ -18,7 +18,7 @@ #ifdef _M_CEE_PURE // no intrinsics for /clr:pure #elif defined(_M_ARM64) || defined(_M_ARM64EC) -// https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#base-requirements +// https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#base-requirements // Both floating-point and NEON support are presumed to be present in hardware. #define _FMP_USING_STD_FMA #elif defined(__clang__) // ^^^ defined(_M_ARM64) || defined(_M_ARM64EC) ^^^ diff --git a/stl/inc/exception b/stl/inc/exception index f6df092e1..72bf3d74e 100644 --- a/stl/inc/exception +++ b/stl/inc/exception @@ -21,10 +21,10 @@ _STL_DISABLE_CLANG_WARNINGS _STD_BEGIN #if _HAS_DEPRECATED_UNCAUGHT_EXCEPTION -_EXPORT_STD extern "C++" _CXX17_DEPRECATE_UNCAUGHT_EXCEPTION _CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL +_EXPORT_STD extern "C++" _CXX17_DEPRECATE_UNCAUGHT_EXCEPTION _NODISCARD _CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL uncaught_exception() noexcept; #endif // _HAS_DEPRECATED_UNCAUGHT_EXCEPTION -_EXPORT_STD extern "C++" _CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL uncaught_exceptions() noexcept; +_EXPORT_STD extern "C++" _NODISCARD _CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL uncaught_exceptions() noexcept; _STD_END diff --git a/stl/inc/experimental/coroutine b/stl/inc/experimental/coroutine index 0758b0b3d..f31a4381e 100644 --- a/stl/inc/experimental/coroutine +++ b/stl/inc/experimental/coroutine @@ -59,10 +59,10 @@ namespace experimental { using promise_type = typename _Ret::promise_type; }; - template + template struct coroutine_traits : _Coroutine_traits_sfinae<_Ret> {}; - template + template struct coroutine_handle; template <> @@ -126,7 +126,7 @@ namespace experimental { _Resumable_frame_prefix* _Ptr = nullptr; }; - template + template struct coroutine_handle : coroutine_handle<> { // general form using coroutine_handle<>::coroutine_handle; @@ -226,7 +226,7 @@ namespace experimental { // _Resumable_helper_traits class isolates front-end from public surface // naming changes - template + template struct _Resumable_helper_traits { using _Traits = coroutine_traits<_Ret, _Ts...>; using _PromiseT = typename _Traits::promise_type; diff --git a/stl/inc/format b/stl/inc/format index 2375581f5..0150c7478 100644 --- a/stl/inc/format +++ b/stl/inc/format @@ -129,7 +129,9 @@ _NODISCARD constexpr bool _Is_arithmetic_fmt_type(_Basic_format_arg_type _Ty) { return _Ty > _Basic_format_arg_type::_None && _Ty <= _Basic_format_arg_type::_Long_double_type; } -struct _Auto_id_tag {}; +struct _Auto_id_tag { + explicit _Auto_id_tag() = default; +}; // clang-format off template @@ -956,7 +958,7 @@ _NODISCARD constexpr bool _Is_execution_charset_self_synchronizing() { // We care about this because if a charset is self-synchronizing then we can search through it // for formatting control characters _without_ generally decoding the format string. switch (_MSVC_EXECUTION_CHARACTER_SET) { - // See: https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers + // See: https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers case 874: // Thai (Windows) case 1250: // ANSI Central European; Central European (Windows) case 1251: // ANSI Cyrillic; Cyrillic (Windows) @@ -1680,7 +1682,7 @@ public: _Dynamic_specs._Dynamic_width_index = _Verify_dynamic_arg_index_in_range(_Arg_id); } - constexpr void _On_dynamic_width(const _Auto_id_tag) { + constexpr void _On_dynamic_width(_Auto_id_tag) { _Dynamic_specs._Dynamic_width_index = _Verify_dynamic_arg_index_in_range(_Parse_ctx.next_arg_id()); } @@ -1689,7 +1691,7 @@ public: _Dynamic_specs._Dynamic_precision_index = _Verify_dynamic_arg_index_in_range(_Arg_id); } - constexpr void _On_dynamic_precision(const _Auto_id_tag) { + constexpr void _On_dynamic_precision(_Auto_id_tag) { _Dynamic_specs._Dynamic_precision_index = _Verify_dynamic_arg_index_in_range(_Parse_ctx.next_arg_id()); } @@ -3975,7 +3977,7 @@ public: _Specs._Dynamic_width_index = _Verify_dynamic_arg_index_in_range(_Arg_id); } - constexpr void _On_dynamic_width(const _Auto_id_tag) { + constexpr void _On_dynamic_width(_Auto_id_tag) { _Specs._Dynamic_width_index = _Verify_dynamic_arg_index_in_range(_Parse_ctx.next_arg_id()); } diff --git a/stl/inc/hash_map b/stl/inc/hash_map index 037d8183b..e026e2457 100644 --- a/stl/inc/hash_map +++ b/stl/inc/hash_map @@ -108,7 +108,7 @@ namespace stdext { float _Max_buckets = 0.0F; // current maximum bucket size }; - template >, + template >, class _Alloc = allocator>> class hash_map : public _Hash<_Hmap_traits<_Kty, _Ty, _Tr, _Alloc, false>> { // hash table of {key, mapped} values, unique keys @@ -297,7 +297,7 @@ namespace stdext { return !(_Left == _Right); } - template >, + template >, class _Alloc = allocator>> class hash_multimap : public _Hash<_Hmap_traits<_Kty, _Ty, _Tr, _Alloc, true>> { // hash table of {key, mapped} values, non-unique keys diff --git a/stl/inc/hash_set b/stl/inc/hash_set index 5e68d85bc..69c7d2965 100644 --- a/stl/inc/hash_set +++ b/stl/inc/hash_set @@ -85,7 +85,7 @@ namespace stdext { float _Max_buckets = 0.0F; // current maximum bucket size }; - template >, class _Alloc = allocator<_Kty>> + template >, class _Alloc = allocator<_Kty>> class hash_set : public _Hash<_Hset_traits<_Kty, _Tr, _Alloc, false>> { // hash table of key values, unique keys public: using _Mybase = _Hash<_Hset_traits<_Kty, _Tr, _Alloc, false>>; @@ -230,7 +230,7 @@ namespace stdext { return !(_Left == _Right); } - template >, class _Alloc = allocator<_Kty>> + template >, class _Alloc = allocator<_Kty>> class hash_multiset : public _Hash<_Hset_traits<_Kty, _Tr, _Alloc, true>> { // hash table of key values, non-unique keys public: diff --git a/stl/inc/istream b/stl/inc/istream index df59f875c..5c10f4797 100644 --- a/stl/inc/istream +++ b/stl/inc/istream @@ -36,9 +36,7 @@ public: } #endif // defined(__FORCE_INSTANCE) - explicit __CLR_OR_THIS_CALL basic_istream(_Mysb* _Strbuf, bool _Isstd = false) - - : _Chcount(0) { + explicit __CLR_OR_THIS_CALL basic_istream(_Mysb* _Strbuf, bool _Isstd = false) : _Chcount(0) { _Myios::init(_Strbuf, _Isstd); } diff --git a/stl/inc/iterator b/stl/inc/iterator index eb496572d..531b46840 100644 --- a/stl/inc/iterator +++ b/stl/inc/iterator @@ -1466,8 +1466,6 @@ struct iterator_traits> : iterator_traits<_Iter> { _STD_END _STDEXT_BEGIN -using _STD size_t; - template class _DEPRECATE_STDEXT_ARR_ITERS checked_array_iterator { // wrap a pointer with checking private: diff --git a/stl/inc/random b/stl/inc/random index 6f61fbc6e..54fa87dd8 100644 --- a/stl/inc/random +++ b/stl/inc/random @@ -656,7 +656,13 @@ struct _Circ_buf { // holds historical values for generators } size_t _Base(size_t _Ix = 0) const noexcept { - return (_Ix += _Idx) < _Nw ? (_Ix + _Nw) : (_Ix - _Nw); + _Ix += _Idx; + + if (_Ix < _Nw) { + return _Ix + _Nw; + } else { + return _Ix - _Nw; + } } unsigned int _Idx; @@ -999,7 +1005,7 @@ public: }; #if _HAS_TR1_NAMESPACE -_CONSTEVAL double _Cx_exp2(const int _Exp) noexcept { +constexpr double _Cx_exp2(const int _Exp) noexcept { double _Ret = 1.0; for (int _Count = _Exp; _Count > 0; --_Count) { _Ret *= 2.0; diff --git a/stl/inc/ratio b/stl/inc/ratio index 4222fdc45..429a2b9f3 100644 --- a/stl/inc/ratio +++ b/stl/inc/ratio @@ -181,7 +181,7 @@ struct _Big_uint128 { uint64_t _Upper; uint64_t _Lower; - constexpr bool operator<(const _Big_uint128 _Rhs) const noexcept { + _NODISCARD constexpr bool operator<(const _Big_uint128 _Rhs) const noexcept { if (_Upper != _Rhs._Upper) { return _Upper < _Rhs._Upper; } diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 2f1741396..2339de93f 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1541,9 +1541,7 @@ struct _Fold_common_reference>, _Ty1, _Ty2 template struct common_reference<_Ty1, _Ty2, _Ty3, _Rest...> : _Fold_common_reference {}; -#endif // _HAS_CXX20 -#if _HAS_CXX20 _EXPORT_STD template struct type_identity { using type = _Ty; diff --git a/stl/inc/vector b/stl/inc/vector index cee280283..8286166d3 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -8,14 +8,13 @@ #include #if _STL_COMPILER_PREPROCESSOR #include <__msvc_bit_utils.hpp> +#include <__msvc_sanitizer_annotate_container.hpp> #include #if _HAS_CXX17 #include #endif // _HAS_CXX17 -#include <__msvc_sanitizer_annotate_container.hpp> - #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) #pragma warning(disable : _STL_DISABLED_WARNINGS) diff --git a/stl/inc/xcall_once.h b/stl/inc/xcall_once.h index 8ea01a7d6..5b9954a0d 100644 --- a/stl/inc/xcall_once.h +++ b/stl/inc/xcall_once.h @@ -28,12 +28,14 @@ _EXPORT_STD struct once_flag { // opaque data structure for call_once() void* _Opaque; }; +#ifdef _CRTBLD // Returns BOOL, nonzero to indicate success, zero for failure using _Execute_once_fp_t = int(__stdcall*)(void*, void*, void**); // Returns BOOL, nonzero to indicate success, zero for failure extern "C++" _CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Execute_once( once_flag& _Flag, _Execute_once_fp_t _Callback, void* _Pv) noexcept; +#endif // _CRTBLD template union _Immortalizer_impl { // constructs _Ty, never destroys diff --git a/stl/inc/xhash b/stl/inc/xhash index f9aa72162..3b7cf6777 100644 --- a/stl/inc/xhash +++ b/stl/inc/xhash @@ -32,10 +32,6 @@ _STL_DISABLE_CLANG_WARNINGS #ifdef _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS namespace stdext { - using _STD basic_string; - using _STD less; - using _STD size_t; - template _NODISCARD size_t hash_value(const _Kty& _Keyval) noexcept { if constexpr (_STD is_pointer_v<_Kty> || _STD is_null_pointer_v<_Kty>) { @@ -46,7 +42,7 @@ namespace stdext { } template - _NODISCARD size_t hash_value(const basic_string<_Elem, _Traits, _Alloc>& _Str) noexcept { + _NODISCARD size_t hash_value(const _STD basic_string<_Elem, _Traits, _Alloc>& _Str) noexcept { return _STD _Hash_array_representation(_Str.c_str(), _Str.size()); } @@ -58,7 +54,7 @@ namespace stdext { return _STD _Hash_array_representation(_Str, _CSTD wcslen(_Str)); } - template > + template > class hash_compare { // traits class for hash containers public: enum { // parameters for hash table diff --git a/stl/inc/xstring b/stl/inc/xstring index 9fb63f2c1..f86799975 100644 --- a/stl/inc/xstring +++ b/stl/inc/xstring @@ -9,6 +9,7 @@ #define _XSTRING_ #include #if _STL_COMPILER_PREPROCESSOR +#include <__msvc_sanitizer_annotate_container.hpp> #include #include @@ -16,8 +17,6 @@ #include #endif // _HAS_CXX17 -#include <__msvc_sanitizer_annotate_container.hpp> - #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) #pragma warning(disable : _STL_DISABLED_WARNINGS) @@ -684,7 +683,7 @@ template class _String_bitmap<_Elem, false> { // _String_bitmap for wchar_t/unsigned short/char16_t/char32_t/etc. types public: static_assert(is_unsigned_v<_Elem>, - "Standard char_traits is only provided for char, wchar_t, char16_t, and char32_t. See N5687 [char.traits]. " + "Standard char_traits is only provided for char, wchar_t, char16_t, and char32_t. See N4950 [char.traits]. " "Visual C++ accepts other unsigned integral types as an extension."); constexpr bool _Mark(const _Elem* _First, const _Elem* const _Last) noexcept { diff --git a/stl/inc/xthreads.h b/stl/inc/xthreads.h index d64ec1dcd..167c20994 100644 --- a/stl/inc/xthreads.h +++ b/stl/inc/xthreads.h @@ -59,23 +59,15 @@ struct _Mtx_internal_imp_t { }; // Size and alignment for _Cnd_internal_imp_t -#ifdef _CRT_WINDOWS -#ifdef _WIN64 -_INLINE_VAR constexpr size_t _Cnd_internal_imp_size = 16; -_INLINE_VAR constexpr size_t _Cnd_internal_imp_alignment = 8; -#else // ^^^ defined(_WIN64) / !defined(_WIN64) vvv -_INLINE_VAR constexpr size_t _Cnd_internal_imp_size = 8; -_INLINE_VAR constexpr size_t _Cnd_internal_imp_alignment = 4; -#endif // ^^^ !defined(_WIN64) ^^^ -#else // ^^^ defined(_CRT_WINDOWS) / !defined(_CRT_WINDOWS) vvv -#ifdef _WIN64 -_INLINE_VAR constexpr size_t _Cnd_internal_imp_size = 72; -_INLINE_VAR constexpr size_t _Cnd_internal_imp_alignment = 8; -#else // ^^^ defined(_WIN64) / !defined(_WIN64) vvv -_INLINE_VAR constexpr size_t _Cnd_internal_imp_size = 40; -_INLINE_VAR constexpr size_t _Cnd_internal_imp_alignment = 4; -#endif // ^^^ !defined(_WIN64) ^^^ -#endif // ^^^ !defined(_CRT_WINDOWS) ^^^ +#if defined(_CRT_WINDOWS) // for Windows-internal code +_INLINE_VAR constexpr size_t _Cnd_internal_imp_size = 2 * sizeof(void*); +#elif defined(_WIN64) // ordinary 64-bit code +_INLINE_VAR constexpr size_t _Cnd_internal_imp_size = 72; +#else // vvv ordinary 32-bit code vvv +_INLINE_VAR constexpr size_t _Cnd_internal_imp_size = 40; +#endif // ^^^ ordinary 32-bit code ^^^ + +_INLINE_VAR constexpr size_t _Cnd_internal_imp_alignment = alignof(void*); using _Mtx_t = _Mtx_internal_imp_t*; diff --git a/stl/inc/xtimec.h b/stl/inc/xtimec.h index f325bd7de..5b36daa8a 100644 --- a/stl/inc/xtimec.h +++ b/stl/inc/xtimec.h @@ -19,7 +19,10 @@ _STL_DISABLE_CLANG_WARNINGS _EXTERN_C +#ifdef _CRTBLD _CRTIMP2_PURE long __cdecl _Xtime_diff_to_millis2(const _timespec64*, const _timespec64*); +#endif // _CRTBLD + _CRTIMP2_PURE long long __cdecl _Xtime_get_ticks(); #ifdef _CRTBLD diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 72fcb1d32..4b64c69d7 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -1020,12 +1020,6 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect #define _STL_OPTIMIZE_SYSTEM_ERROR_OPERATORS 1 #endif // _STL_OPTIMIZE_SYSTEM_ERROR_OPERATORS -#ifdef __cpp_consteval -#define _CONSTEVAL consteval -#else // ^^^ supports consteval / no consteval vvv -#define _CONSTEVAL constexpr -#endif // ^^^ no consteval ^^^ - // Controls whether the STL will force /fp:fast to enable vectorization of algorithms defined // in the standard as special cases; such as reduce, transform_reduce, inclusive_scan, exclusive_scan #ifndef _STD_VECTORIZE_WITH_FLOAT_CONTROL diff --git a/stl/src/StlCompareStringA.cpp b/stl/src/StlCompareStringA.cpp index 81eb6e41c..4fe6173c7 100644 --- a/stl/src/StlCompareStringA.cpp +++ b/stl/src/StlCompareStringA.cpp @@ -18,7 +18,7 @@ // // Entry: // LPCWSTR LocaleName - locale context for the comparison. -// DWORD dwCmpFlags - see docs.microsoft.com +// DWORD dwCmpFlags - see https://aka.ms/stl/comparestringex // LPCSTR lpStringn - multibyte string to be compared // int cchCountn - char (byte) count (NOT including null terminator) // (-1 if null terminated) diff --git a/stl/src/StlCompareStringW.cpp b/stl/src/StlCompareStringW.cpp index 424593c03..25033046d 100644 --- a/stl/src/StlCompareStringW.cpp +++ b/stl/src/StlCompareStringW.cpp @@ -14,7 +14,7 @@ // // Entry: // LPCWSTR LocaleName - locale context for the comparison. -// DWORD dwCmpFlags - see docs.microsoft.com +// DWORD dwCmpFlags - see https://aka.ms/stl/comparestringex // LPCWSTR lpStringn - wide string to be compared // int cchCountn - wide char (word) count (NOT including null terminator) // (-1 if null terminated) diff --git a/stl/src/StlLCMapStringA.cpp b/stl/src/StlLCMapStringA.cpp index 2ddf8258b..929d0f2a6 100644 --- a/stl/src/StlLCMapStringA.cpp +++ b/stl/src/StlLCMapStringA.cpp @@ -14,7 +14,7 @@ // // Entry: // LPCWSTR LocaleName - locale context for the comparison. -// DWORD dwMapFlags - see docs.microsoft.com +// DWORD dwMapFlags - see https://aka.ms/stl/lcmapstringex // LPCSTR lpSrcStr - pointer to string to be mapped // int cchSrc - wide char (word) count of input string // (including null terminator if any) diff --git a/stl/src/StlLCMapStringW.cpp b/stl/src/StlLCMapStringW.cpp index 625e8f807..14785ea37 100644 --- a/stl/src/StlLCMapStringW.cpp +++ b/stl/src/StlLCMapStringW.cpp @@ -12,7 +12,7 @@ // // Entry: // LPCWSTR locale_name - locale context for the comparison. -// DWORD map_flags - see docs.microsoft.com +// DWORD map_flags - see https://aka.ms/stl/lcmapstringex // LPCWSTR source - pointer to string to be mapped // int source_count - wide char (word) count of input string // (including null terminator if any) diff --git a/stl/src/cond.cpp b/stl/src/cond.cpp index 157d97577..2b5a4f1c0 100644 --- a/stl/src/cond.cpp +++ b/stl/src/cond.cpp @@ -12,8 +12,7 @@ #include "primitives.hpp" struct _Cnd_internal_imp_t { // condition variable implementation for ConcRT - typename std::_Aligned_storage::type cv; + typename std::_Aligned_storage<_Cnd_internal_imp_size, _Cnd_internal_imp_alignment>::type cv; [[nodiscard]] Concurrency::details::stl_condition_variable_win7* _get_cv() noexcept { // get pointer to implementation @@ -21,9 +20,6 @@ struct _Cnd_internal_imp_t { // condition variable implementation for ConcRT } }; -static_assert(sizeof(_Cnd_internal_imp_t) == _Cnd_internal_imp_size, "incorrect _Cnd_internal_imp_size"); -static_assert(alignof(_Cnd_internal_imp_t) == _Cnd_internal_imp_alignment, "incorrect _Cnd_internal_imp_alignment"); - void _Cnd_init_in_situ(const _Cnd_t cond) { // initialize condition variable in situ Concurrency::details::create_stl_condition_variable(cond->_get_cv()); } diff --git a/stl/src/mutex.cpp b/stl/src/mutex.cpp index 4af1e40a0..ece2ddf18 100644 --- a/stl/src/mutex.cpp +++ b/stl/src/mutex.cpp @@ -19,19 +19,13 @@ extern "C" [[noreturn]] _CRTIMP2_PURE void _Thrd_abort(const char* msg) { // abo abort(); } -#if defined(_THREAD_CHECK) || defined(_DEBUG) -#define _THREAD_CHECKX 1 -#else // defined(_THREAD_CHECK) || defined(_DEBUG) -#define _THREAD_CHECKX 0 -#endif // defined(_THREAD_CHECK) || defined(_DEBUG) - -#if _THREAD_CHECKX +#ifdef _DEBUG #define _THREAD_QUOTX(x) #x #define _THREAD_QUOT(x) _THREAD_QUOTX(x) #define _THREAD_ASSERT(expr, msg) ((expr) ? (void) 0 : _Thrd_abort(__FILE__ "(" _THREAD_QUOT(__LINE__) "): " msg)) -#else // ^^^ _THREAD_CHECKX / !_THREAD_CHECKX vvv +#else // ^^^ defined(_DEBUG) / !defined(_DEBUG) vvv #define _THREAD_ASSERT(expr, msg) ((void) 0) -#endif // ^^^ !_THREAD_CHECKX ^^^ +#endif // ^^^ !defined(_DEBUG) ^^^ // TRANSITION, ABI: preserved for binary compatibility enum class __stl_sync_api_modes_enum { normal, win7, vista, concrt }; diff --git a/stl/src/primitives.hpp b/stl/src/primitives.hpp index 494eb7eb1..89d35a2c7 100644 --- a/stl/src/primitives.hpp +++ b/stl/src/primitives.hpp @@ -51,15 +51,5 @@ namespace Concurrency { inline void create_stl_condition_variable(stl_condition_variable_win7* p) { new (p) stl_condition_variable_win7; } - -#if defined(_CRT_WINDOWS) // for Windows-internal code - const size_t stl_condition_variable_max_size = 2 * sizeof(void*); -#elif defined(_WIN64) // ordinary 64-bit code - const size_t stl_condition_variable_max_size = 72; -#else // vvv ordinary 32-bit code vvv - const size_t stl_condition_variable_max_size = 40; -#endif // ^^^ ordinary 32-bit code ^^^ - - const size_t stl_condition_variable_max_alignment = alignof(void*); } // namespace details } // namespace Concurrency diff --git a/stl/src/uncaught_exception.cpp b/stl/src/uncaught_exception.cpp index 4e7e41348..df21b68dc 100644 --- a/stl/src/uncaught_exception.cpp +++ b/stl/src/uncaught_exception.cpp @@ -5,7 +5,8 @@ #include _STD_BEGIN -_CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL uncaught_exception() noexcept { // report if handling a throw +_CXX17_DEPRECATE_UNCAUGHT_EXCEPTION _NODISCARD _CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL + uncaught_exception() noexcept { return __uncaught_exception(); } diff --git a/stl/src/uncaught_exceptions.cpp b/stl/src/uncaught_exceptions.cpp index c89c45873..2977b8e06 100644 --- a/stl/src/uncaught_exceptions.cpp +++ b/stl/src/uncaught_exceptions.cpp @@ -5,7 +5,7 @@ #include _STD_BEGIN -_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL uncaught_exceptions() noexcept { // report number of throws being handled +_NODISCARD _CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL uncaught_exceptions() noexcept { return __uncaught_exceptions(); } diff --git a/stl/src/xmath.hpp b/stl/src/xmath.hpp index e7f441d5c..4968e4070 100644 --- a/stl/src/xmath.hpp +++ b/stl/src/xmath.hpp @@ -185,14 +185,14 @@ _END_EXTERN_C_UNLESS_PURE #pragma float_control(except, on, push) #endif -template +template [[nodiscard]] T _Xfe_overflow(const T sign) noexcept { static_assert(_STD is_floating_point_v, "Expected is_floating_point_v."); constexpr T huge = _STD numeric_limits::max(); return _STD copysign(huge, sign) * huge; } -template +template [[nodiscard]] T _Xfe_underflow(const T sign) noexcept { static_assert(_STD is_floating_point_v, "Expected is_floating_point_v."); constexpr T tiny = _STD numeric_limits::min(); diff --git a/tests/std/tests/P0811R3_midpoint_lerp/test.cpp b/tests/std/tests/P0811R3_midpoint_lerp/test.cpp index 6ee188526..4c19a1b77 100644 --- a/tests/std/tests/P0811R3_midpoint_lerp/test.cpp +++ b/tests/std/tests/P0811R3_midpoint_lerp/test.cpp @@ -25,7 +25,7 @@ using limits = numeric_limits; #ifdef _M_FP_STRICT // According to: -// https://docs.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior +// https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior // Under the default /fp:precise mode: // The compiler generates code intended to run in the default floating-point environment and assumes that the // floating-point environment is not accessed or modified at runtime. diff --git a/tests/std/tests/P0896R4_views_elements/test.cpp b/tests/std/tests/P0896R4_views_elements/test.cpp index 61a76c174..24ad30929 100644 --- a/tests/std/tests/P0896R4_views_elements/test.cpp +++ b/tests/std/tests/P0896R4_views_elements/test.cpp @@ -50,7 +50,7 @@ constexpr bool test_one(Rng&& rng) { // ... with lvalue argument STATIC_ASSERT(CanViewElements); constexpr bool is_view = ranges::view>; - if constexpr (CanViewElements) { // Validate lvalue + { // Validate lvalue constexpr bool is_noexcept = !is_view || is_nothrow_copy_constructible_v; STATIC_ASSERT(same_as(rng)), R>); diff --git a/tests/std/tests/P2278R4_views_as_const/test.cpp b/tests/std/tests/P2278R4_views_as_const/test.cpp index c33e2e1b1..f2c37b940 100644 --- a/tests/std/tests/P2278R4_views_as_const/test.cpp +++ b/tests/std/tests/P2278R4_views_as_const/test.cpp @@ -202,7 +202,7 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) { STATIC_ASSERT(noexcept(as_const(rng) | views::as_const)); } - { //... with rvalue argument + { // ... with rvalue argument STATIC_ASSERT(same_as); STATIC_ASSERT(noexcept(views::as_const(move(rng))));