libuv: Restore support for Windows 7

Upstream libuv no longer supports this version.
This commit is contained in:
Brad King committed 2026-10-08 09:01:24 -04:00
1 parent 1ddc97e901
commit d9f518e897
4 files changed
+92 -3

No files matched your search

+11 -2
View File
@@ -44,7 +44,6 @@ if(WIN32)
ole32
psapi
shell32
synchronization
user32
userenv
ws2_32
@@ -54,8 +53,18 @@ if(WIN32)
)
list(APPEND uv_defines
WIN32_LEAN_AND_MEAN
_WIN32_WINNT=0x0602
)
if(CMAKE_C_FLAGS MATCHES "(^| )[-/]D *_WIN32_WINNT=([0-9A-Fa-fx]+)( |$)")
# The user has explicitly specified a minimum version of Windows.
set(_WIN32_WINNT "${CMAKE_MATCH_2}")
else()
# Support Windows Vista by default.
set(_WIN32_WINNT 0x0600)
list(APPEND uv_defines _WIN32_WINNT=${_WIN32_WINNT})
endif()
if(_WIN32_WINNT GREATER_EQUAL 0x0602)
list(APPEND uv_libraries synchronization)
endif()
list(APPEND uv_headers
include/uv/win.h
include/tree.h
+12 -1
View File
@@ -38,6 +38,16 @@
#define SIGKILL 9
static int uv__windows8_or_later(void) {
OSVERSIONINFOW os_info;
if (!pRtlGetVersion)
return 0;
os_info.dwOSVersionInfoSize = sizeof(os_info);
os_info.szCSDVersion[0] = L'\0';
pRtlGetVersion(&os_info);
return os_info.dwMajorVersion > 6 ||
(os_info.dwMajorVersion == 6 && os_info.dwMinorVersion >= 2);
}
typedef struct env_var {
const WCHAR* const wide;
@@ -1062,7 +1072,8 @@ int uv_spawn(uv_loop_t* loop,
* PROC_THREAD_ATTRIBUTE_HANDLE_LIST ensures only these specific handles are
* inherited, closing the race condition where concurrent uv_spawn calls
* could cause handles intended for one child to leak into another. */
{
/* Windows 8 or above is required to avoid failing on console handles. */
if (uv__windows8_or_later()) {
#define CHILD_STDIO_COUNT(buffer) \
*((unsigned int*) (buffer))
int count = CHILD_STDIO_COUNT(child_stdio_buffer);
+59
View File
@@ -53,6 +53,45 @@ sGetFileInformationByName pGetFileInformationByName;
#if _WIN32_WINNT < 0x0602 /* _WIN32_WINNT_WIN8 */
sGetSystemTimePreciseAsFileTime pGetSystemTimePreciseAsFileTime;
sWaitOnAddress pWaitOnAddress;
sWakeByAddressSingle pWakeByAddressSingle;
static VOID WINAPI uv__WaitOnAddress(volatile VOID* a, PVOID b, SIZE_T sz,
DWORD timeoutMS)
{
static DWORD const waitMS = 1;
DWORD waitedMS = 0;
for (;;) {
switch (sz) {
case 1:
if (*(volatile uint8_t*)a != *(uint8_t*)b) return;
break;
case 2:
if (*(volatile uint16_t*)a != *(uint16_t*)b) return;
break;
case 4:
if (*(volatile uint32_t*)a != *(uint32_t*)b) return;
break;
case 8:
if (*(volatile uint64_t*)a != *(uint64_t*)b) return;
break;
default:
return;
}
if (timeoutMS != INFINITE) {
if (waitedMS >= timeoutMS) {
return;
}
waitedMS += waitMS;
}
Sleep(waitMS);
}
}
static VOID WINAPI uv__WakeByAddressSingle(PVOID address)
{
(void)address;
}
#endif
void uv__winapi_init(void) {
@@ -64,6 +103,7 @@ void uv__winapi_init(void) {
HMODULE api_win_core_file_module;
#if _WIN32_WINNT < 0x0602 /* _WIN32_WINNT_WIN8 */
HMODULE kernel32_module;
HMODULE api_win_core_synch_module;
#endif
union {
@@ -84,6 +124,8 @@ void uv__winapi_init(void) {
sGetFileInformationByName pGetFileInformationByName;
#if _WIN32_WINNT < 0x0602 /* _WIN32_WINNT_WIN8 */
sGetSystemTimePreciseAsFileTime pGetSystemTimePreciseAsFileTime;
sWaitOnAddress pWaitOnAddress;
sWakeByAddressSingle pWakeByAddressSingle;
#endif
} u;
@@ -191,5 +233,22 @@ void uv__winapi_init(void) {
pGetSystemTimePreciseAsFileTime = GetSystemTimeAsFileTime;
}
}
api_win_core_synch_module =
GetModuleHandleW(L"api-ms-win-core-synch-l1-2-0.dll");
if (api_win_core_synch_module != NULL) {
u.proc = GetProcAddress(api_win_core_synch_module,
"WaitOnAddress");
pWaitOnAddress = u.pWaitOnAddress;
u.proc = GetProcAddress(api_win_core_synch_module,
"WakeByAddressSingle");
pWakeByAddressSingle = u.pWakeByAddressSingle;
}
if (!pWaitOnAddress || !pWakeByAddressSingle) {
pWaitOnAddress = uv__WaitOnAddress;
pWakeByAddressSingle = uv__WakeByAddressSingle;
}
#endif
}
+10
View File
@@ -4848,6 +4848,16 @@ typedef VOID (WINAPI *sGetSystemTimePreciseAsFileTime)
(LPFILETIME lpSystemTimeAsFileTime);
extern sGetSystemTimePreciseAsFileTime pGetSystemTimePreciseAsFileTime;
#define GetSystemTimePreciseAsFileTime pGetSystemTimePreciseAsFileTime
typedef VOID (WINAPI *sWaitOnAddress)
(volatile VOID*, PVOID, SIZE_T, DWORD);
extern sWaitOnAddress pWaitOnAddress;
#define WaitOnAddress pWaitOnAddress
typedef VOID (WINAPI *sWakeByAddressSingle)
(PVOID);
extern sWakeByAddressSingle pWakeByAddressSingle;
#define WakeByAddressSingle pWakeByAddressSingle
#endif
#endif /* UV_WIN_WINAPI_H_ */