Skip to content

Commit 0be5257

Browse files
Drop support for Win7 / Server 2008 R2 (microsoft#4742)
1 parent 881bcad commit 0be5257

File tree

15 files changed

+385
-718
lines changed

15 files changed

+385
-718
lines changed

stl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ function(add_stl_dlls D_SUFFIX REL_OR_DBG)
556556
generate_satellite_def("atomic_wait" "${D_SUFFIX}")
557557

558558
add_library(msvcp${D_SUFFIX}_atomic_wait SHARED "${CMAKE_BINARY_DIR}/msvcp_atomic_wait${D_SUFFIX}.def")
559-
target_link_libraries(msvcp${D_SUFFIX}_atomic_wait PRIVATE msvcp${D_SUFFIX}_atomic_wait_objects msvcp${D_SUFFIX}_satellite_objects msvcp${D_SUFFIX}_implib_objects "msvcp${D_SUFFIX}" "${TOOLSET_LIB}/vcruntime${D_SUFFIX}.lib" "${TOOLSET_LIB}/msvcrt${D_SUFFIX}.lib" "ucrt${D_SUFFIX}.lib" "advapi32.lib")
559+
target_link_libraries(msvcp${D_SUFFIX}_atomic_wait PRIVATE msvcp${D_SUFFIX}_atomic_wait_objects msvcp${D_SUFFIX}_satellite_objects msvcp${D_SUFFIX}_implib_objects "msvcp${D_SUFFIX}" "${TOOLSET_LIB}/vcruntime${D_SUFFIX}.lib" "${TOOLSET_LIB}/msvcrt${D_SUFFIX}.lib" "ucrt${D_SUFFIX}.lib" "advapi32.lib" "synchronization.lib")
560560
set_target_properties(msvcp${D_SUFFIX}_atomic_wait PROPERTIES ARCHIVE_OUTPUT_NAME "msvcp140_atomic_wait${D_SUFFIX}${VCLIBS_SUFFIX}")
561561
set_target_properties(msvcp${D_SUFFIX}_atomic_wait PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
562562
set_target_properties(msvcp${D_SUFFIX}_atomic_wait PROPERTIES OUTPUT_NAME "msvcp140${D_SUFFIX}_atomic_wait${VCLIBS_SUFFIX}")

stl/inc/__msvc_chrono.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ namespace chrono {
640640
return time_point<_Clock, _To>(_CHRONO round<_To>(_Time.time_since_epoch()));
641641
}
642642

643-
_EXPORT_STD struct system_clock { // wraps GetSystemTimePreciseAsFileTime/GetSystemTimeAsFileTime
643+
_EXPORT_STD struct system_clock { // wraps GetSystemTimePreciseAsFileTime
644644
using rep = long long;
645645
using period = ratio<1, 10'000'000>; // 100 nanoseconds
646646
using duration = _CHRONO duration<rep, period>;

stl/inc/xatomic_wait.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,9 @@ _STL_DISABLE_CLANG_WARNINGS
2121
extern "C" {
2222
inline constexpr unsigned long __std_atomic_wait_no_timeout = 0xFFFF'FFFF; // Pass as partial timeout
2323

24-
enum class __std_atomic_api_level : unsigned long {
25-
__not_set,
26-
__detecting,
27-
__has_srwlock,
28-
__has_wait_on_address,
29-
};
30-
31-
// This function allows testing the atomic wait support while always using the APIs for a platform with fewer
32-
// capabilities; it attempts to lock the APIs used to the level `_Requested_api_level`, and returns the actual API level
33-
// in use. Once the API level has been set by calling this function (or detected by a call to one of the atomic wait
34-
// functions), it can no longer be changed.
35-
__std_atomic_api_level __stdcall __std_atomic_set_api_level(__std_atomic_api_level _Requested_api_level) noexcept;
36-
3724
// Support for atomic waits.
3825
// The "direct" functions are used when the underlying infrastructure can use WaitOnAddress directly; that is, _Size is
39-
// 1, 2, 4, or 8. The contract is the same as the WaitOnAddress function from the Windows SDK. If WaitOnAddress is not
40-
// available on the current platform, falls back to a similar solution based on SRWLOCK and CONDITION_VARIABLE.
26+
// 1, 2, 4, or 8. The contract is the same as the WaitOnAddress function from the Windows SDK.
4127
int __stdcall __std_atomic_wait_direct(
4228
const void* _Storage, void* _Comparand, size_t _Size, unsigned long _Remaining_timeout) noexcept;
4329
void __stdcall __std_atomic_notify_one_direct(const void* _Storage) noexcept;

stl/inc/yvals_core.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,6 @@ compiler option, or define _ALLOW_RTCc_IN_STL to suppress this error.
19271927
#endif // defined(MRTDLL) && !defined(_M_CEE_PURE)
19281928

19291929
#define _STL_WIN32_WINNT_VISTA 0x0600 // _WIN32_WINNT_VISTA from sdkddkver.h
1930-
#define _STL_WIN32_WINNT_WIN7 0x0601 // _WIN32_WINNT_WIN7 from sdkddkver.h
19311930
#define _STL_WIN32_WINNT_WIN8 0x0602 // _WIN32_WINNT_WIN8 from sdkddkver.h
19321931
#define _STL_WIN32_WINNT_WINBLUE 0x0603 // _WIN32_WINNT_WINBLUE from sdkddkver.h
19331932
#define _STL_WIN32_WINNT_WIN10 0x0A00 // _WIN32_WINNT_WIN10 from sdkddkver.h
@@ -1937,13 +1936,10 @@ compiler option, or define _ALLOW_RTCc_IN_STL to suppress this error.
19371936
#if defined(_M_ARM64)
19381937
// The first ARM64 Windows was Windows 10
19391938
#define _STL_WIN32_WINNT _STL_WIN32_WINNT_WIN10
1940-
#elif defined(_M_ARM) || defined(_ONECORE) || defined(_CRT_APP)
1941-
// The first ARM or OneCore or App Windows was Windows 8
1939+
#else // ^^^ defined(_M_ARM64) / !defined(_M_ARM64) vvv
1940+
// The earliest Windows supported by this implementation is Windows 8
19421941
#define _STL_WIN32_WINNT _STL_WIN32_WINNT_WIN8
1943-
#else // ^^^ default to Win8 / default to Win7 vvv
1944-
// The earliest Windows supported by this implementation is Windows 7
1945-
#define _STL_WIN32_WINNT _STL_WIN32_WINNT_WIN7
1946-
#endif // ^^^ !defined(_M_ARM) && !defined(_M_ARM64) && !defined(_ONECORE) && !defined(_CRT_APP) ^^^
1942+
#endif // ^^^ !defined(_M_ARM64) ^^^
19471943
#endif // !defined(_STL_WIN32_WINNT)
19481944

19491945
#ifdef __cpp_noexcept_function_type

stl/msbuild/stl_atomic_wait/msvcp_atomic_wait.settings.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7070
<TargetLib Include="$(CrtLibPath)\vcruntime$(BuildSuffix)$(ClrLibSuffix).lib"/>
7171
<TargetLib Include="$(UniversalCRTLib)"/>
7272
<TargetLib Condition="'$(MsvcpFlavor)' == 'kernel32' or '$(MsvcpFlavor)' == 'netfx'" Include="$(SdkLibPath)\advapi32.lib"/>
73+
<TargetLib Condition="'$(MsvcpFlavor)' == 'kernel32' or '$(MsvcpFlavor)' == 'netfx'" Include="$(SdkLibPath)\synchronization.lib"/>
7374
</ItemGroup>
7475

7576
<!-- Copy the output dll and pdb to various destinations -->

stl/src/atomic_wait.cpp

Lines changed: 9 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include <Windows.h>
1212

13+
#pragma comment(lib, "synchronization")
14+
1315
namespace {
1416
constexpr unsigned long long _Atomic_wait_no_deadline = 0xFFFF'FFFF'FFFF'FFFF;
1517

@@ -89,120 +91,6 @@ namespace {
8991
#endif // defined(_DEBUG)
9092
}
9193

92-
#ifndef _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE
93-
#if _STL_WIN32_WINNT >= _STL_WIN32_WINNT_WIN8
94-
#define _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE 1
95-
#else // ^^^ _STL_WIN32_WINNT >= _STL_WIN32_WINNT_WIN8 / _STL_WIN32_WINNT < _STL_WIN32_WINNT_WIN8 vvv
96-
#define _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE 0
97-
#endif // ^^^ _STL_WIN32_WINNT < _STL_WIN32_WINNT_WIN8 ^^^
98-
#endif // !defined(_ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE)
99-
100-
#if _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE
101-
102-
#pragma comment(lib, "synchronization")
103-
104-
#define __crtWaitOnAddress WaitOnAddress
105-
#define __crtWakeByAddressSingle WakeByAddressSingle
106-
#define __crtWakeByAddressAll WakeByAddressAll
107-
108-
#else // ^^^ _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE / !_ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE vvv
109-
110-
struct _Wait_functions_table {
111-
_STD atomic<decltype(&::WaitOnAddress)> _Pfn_WaitOnAddress{nullptr};
112-
_STD atomic<decltype(&::WakeByAddressSingle)> _Pfn_WakeByAddressSingle{nullptr};
113-
_STD atomic<decltype(&::WakeByAddressAll)> _Pfn_WakeByAddressAll{nullptr};
114-
_STD atomic<__std_atomic_api_level> _Api_level{__std_atomic_api_level::__not_set};
115-
};
116-
117-
_Wait_functions_table _Wait_functions;
118-
119-
void _Force_wait_functions_srwlock_only() noexcept {
120-
auto _Local = _Wait_functions._Api_level.load(_STD memory_order_acquire);
121-
if (_Local <= __std_atomic_api_level::__detecting) {
122-
while (!_Wait_functions._Api_level.compare_exchange_weak(
123-
_Local, __std_atomic_api_level::__has_srwlock, _STD memory_order_acq_rel)) {
124-
if (_Local > __std_atomic_api_level::__detecting) {
125-
return;
126-
}
127-
}
128-
}
129-
}
130-
131-
[[nodiscard]] __std_atomic_api_level _Init_wait_functions(__std_atomic_api_level _Level) {
132-
while (!_Wait_functions._Api_level.compare_exchange_weak(
133-
_Level, __std_atomic_api_level::__detecting, _STD memory_order_acq_rel)) {
134-
if (_Level > __std_atomic_api_level::__detecting) {
135-
return _Level;
136-
}
137-
}
138-
139-
_Level = __std_atomic_api_level::__has_srwlock;
140-
141-
const HMODULE _Sync_module = GetModuleHandleW(L"api-ms-win-core-synch-l1-2-0.dll");
142-
if (_Sync_module != nullptr) {
143-
const auto _Wait_on_address =
144-
reinterpret_cast<decltype(&::WaitOnAddress)>(GetProcAddress(_Sync_module, "WaitOnAddress"));
145-
const auto _Wake_by_address_single =
146-
reinterpret_cast<decltype(&::WakeByAddressSingle)>(GetProcAddress(_Sync_module, "WakeByAddressSingle"));
147-
const auto _Wake_by_address_all =
148-
reinterpret_cast<decltype(&::WakeByAddressAll)>(GetProcAddress(_Sync_module, "WakeByAddressAll"));
149-
150-
if (_Wait_on_address != nullptr && _Wake_by_address_single != nullptr && _Wake_by_address_all != nullptr) {
151-
_Wait_functions._Pfn_WaitOnAddress.store(_Wait_on_address, _STD memory_order_relaxed);
152-
_Wait_functions._Pfn_WakeByAddressSingle.store(_Wake_by_address_single, _STD memory_order_relaxed);
153-
_Wait_functions._Pfn_WakeByAddressAll.store(_Wake_by_address_all, _STD memory_order_relaxed);
154-
_Level = __std_atomic_api_level::__has_wait_on_address;
155-
}
156-
}
157-
158-
// for __has_srwlock, relaxed would have been enough, not distinguishing for consistency
159-
_Wait_functions._Api_level.store(_Level, _STD memory_order_release);
160-
return _Level;
161-
}
162-
163-
[[nodiscard]] __std_atomic_api_level _Acquire_wait_functions() noexcept {
164-
auto _Level = _Wait_functions._Api_level.load(_STD memory_order_acquire);
165-
if (_Level <= __std_atomic_api_level::__detecting) {
166-
_Level = _Init_wait_functions(_Level);
167-
}
168-
169-
return _Level;
170-
}
171-
172-
[[nodiscard]] BOOL __crtWaitOnAddress(
173-
volatile VOID* Address, PVOID CompareAddress, SIZE_T AddressSize, DWORD dwMilliseconds) {
174-
const auto _Wait_on_address = _Wait_functions._Pfn_WaitOnAddress.load(_STD memory_order_relaxed);
175-
return _Wait_on_address(Address, CompareAddress, AddressSize, dwMilliseconds);
176-
}
177-
178-
VOID __crtWakeByAddressSingle(PVOID Address) {
179-
const auto _Wake_by_address_single = _Wait_functions._Pfn_WakeByAddressSingle.load(_STD memory_order_relaxed);
180-
_Wake_by_address_single(Address);
181-
}
182-
183-
VOID __crtWakeByAddressAll(PVOID Address) {
184-
const auto _Wake_by_address_all = _Wait_functions._Pfn_WakeByAddressAll.load(_STD memory_order_relaxed);
185-
_Wake_by_address_all(Address);
186-
}
187-
188-
bool __stdcall _Atomic_wait_are_equal_direct_fallback(
189-
const void* _Storage, void* _Comparand, size_t _Size, void*) noexcept {
190-
switch (_Size) {
191-
case 1:
192-
return __iso_volatile_load8(static_cast<const char*>(_Storage)) == *static_cast<const char*>(_Comparand);
193-
case 2:
194-
return __iso_volatile_load16(static_cast<const short*>(_Storage)) == *static_cast<const short*>(_Comparand);
195-
case 4:
196-
return __iso_volatile_load32(static_cast<const int*>(_Storage)) == *static_cast<const int*>(_Comparand);
197-
case 8:
198-
return __iso_volatile_load64(static_cast<const long long*>(_Storage))
199-
== *static_cast<const long long*>(_Comparand);
200-
default:
201-
_CSTD abort();
202-
}
203-
}
204-
#endif // _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE
205-
20694
[[nodiscard]] unsigned char __std_atomic_compare_exchange_128_fallback(
20795
_Inout_bytecount_(16) long long* _Destination, _In_ long long _ExchangeHigh, _In_ long long _ExchangeLow,
20896
_Inout_bytecount_(16) long long* _ComparandResult) noexcept {
@@ -225,15 +113,8 @@ namespace {
225113
extern "C" {
226114
int __stdcall __std_atomic_wait_direct(const void* const _Storage, void* const _Comparand, const size_t _Size,
227115
const unsigned long _Remaining_timeout) noexcept {
228-
#if _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE == 0
229-
if (_Acquire_wait_functions() < __std_atomic_api_level::__has_wait_on_address) {
230-
return __std_atomic_wait_indirect(
231-
_Storage, _Comparand, _Size, nullptr, &_Atomic_wait_are_equal_direct_fallback, _Remaining_timeout);
232-
}
233-
#endif // _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE == 0
234-
235-
const auto _Result = __crtWaitOnAddress(
236-
const_cast<volatile void*>(_Storage), const_cast<void*>(_Comparand), _Size, _Remaining_timeout);
116+
const auto _Result =
117+
WaitOnAddress(const_cast<volatile void*>(_Storage), const_cast<void*>(_Comparand), _Size, _Remaining_timeout);
237118

238119
if (!_Result) {
239120
_Assume_timeout();
@@ -242,25 +123,11 @@ int __stdcall __std_atomic_wait_direct(const void* const _Storage, void* const _
242123
}
243124

244125
void __stdcall __std_atomic_notify_one_direct(const void* const _Storage) noexcept {
245-
#if _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE == 0
246-
if (_Acquire_wait_functions() < __std_atomic_api_level::__has_wait_on_address) {
247-
__std_atomic_notify_one_indirect(_Storage);
248-
return;
249-
}
250-
#endif // _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE = 0
251-
252-
__crtWakeByAddressSingle(const_cast<void*>(_Storage));
126+
WakeByAddressSingle(const_cast<void*>(_Storage));
253127
}
254128

255129
void __stdcall __std_atomic_notify_all_direct(const void* const _Storage) noexcept {
256-
#if _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE == 0
257-
if (_Acquire_wait_functions() < __std_atomic_api_level::__has_wait_on_address) {
258-
__std_atomic_notify_all_indirect(_Storage);
259-
return;
260-
}
261-
#endif // _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE == 0
262-
263-
__crtWakeByAddressAll(const_cast<void*>(_Storage));
130+
WakeByAddressAll(const_cast<void*>(_Storage));
264131
}
265132

266133
void __stdcall __std_atomic_notify_one_indirect(const void* const _Storage) noexcept {
@@ -356,25 +223,10 @@ unsigned long __stdcall __std_atomic_wait_get_remaining_timeout(unsigned long lo
356223
return static_cast<unsigned long>(_Remaining);
357224
}
358225

359-
__std_atomic_api_level __stdcall __std_atomic_set_api_level(__std_atomic_api_level _Requested_api_level) noexcept {
360-
#if _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE
361-
(void) _Requested_api_level;
226+
// TRANSITION, ABI: preserved for binary compatibility
227+
enum class __std_atomic_api_level : unsigned long { __not_set, __detecting, __has_srwlock, __has_wait_on_address };
228+
__std_atomic_api_level __stdcall __std_atomic_set_api_level(__std_atomic_api_level) noexcept {
362229
return __std_atomic_api_level::__has_wait_on_address;
363-
#else // ^^^ _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE / !_ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE vvv
364-
switch (_Requested_api_level) {
365-
case __std_atomic_api_level::__not_set:
366-
case __std_atomic_api_level::__detecting:
367-
_CSTD abort();
368-
case __std_atomic_api_level::__has_srwlock:
369-
_Force_wait_functions_srwlock_only();
370-
break;
371-
case __std_atomic_api_level::__has_wait_on_address:
372-
default: // future compat: new header using an old DLL will get the highest requested level supported
373-
break;
374-
}
375-
376-
return _Acquire_wait_functions();
377-
#endif // !_ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE
378230
}
379231

380232
#pragma warning(push)

stl/src/awint.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,6 @@
1414

1515
_CRT_BEGIN_C_HEADER
1616

17-
#if _STL_WIN32_WINNT >= _WIN32_WINNT_WIN8
18-
19-
#define __crtGetSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime) \
20-
GetSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime)
21-
22-
#else // ^^^ _STL_WIN32_WINNT >= _WIN32_WINNT_WIN8 / _STL_WIN32_WINNT < _WIN32_WINNT_WIN8 vvv
23-
24-
_CRTIMP2 void __cdecl __crtGetSystemTimePreciseAsFileTime(_Out_ LPFILETIME lpSystemTimeAsFileTime) noexcept;
25-
26-
#endif // ^^^ _STL_WIN32_WINNT < _WIN32_WINNT_WIN8 ^^^
27-
2817
_CRTIMP2 int __cdecl __crtCompareStringA(_In_z_ LPCWSTR _LocaleName, _In_ DWORD _DwCmpFlags,
2918
_In_reads_(_CchCount1) LPCSTR _LpString1, _In_ int _CchCount1, _In_reads_(_CchCount2) LPCSTR _LpString2,
3019
_In_ int _CchCount2, _In_ int _CodePage) noexcept;

stl/src/ppltasks.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ namespace Concurrency {
2626

2727
namespace details {
2828
[[noreturn]] _CRTIMP2 void __cdecl _ReportUnobservedException() {
29-
#if (defined(_M_IX86) || defined(_M_X64)) && !defined(_CRT_APP) && _STL_WIN32_WINNT < _WIN32_WINNT_WIN8
30-
if (!IsProcessorFeaturePresent(PF_FASTFAIL_AVAILABLE)) {
31-
std::abort();
32-
}
33-
#endif // ^^^ __fastfail conditionally available ^^^
34-
3529
__fastfail(FAST_FAIL_INVALID_ARG);
3630
}
3731

0 commit comments

Comments
 (0)