From c6ba2f42b5d4045e0891124e164f49d84ebcba0c Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Sun, 6 Dec 2026 02:41:08 +0300 Subject: [PATCH] Windows: portability fixes for IPC, SystemAsync and MCP tests - IPC: map poll() onto WSAPoll and link ws2_32 on Windows (the module's remaining POSIX socket surface still needs a dedicated port). - SystemAsync: define the non-ANSI SIGTERM/SIGKILL values the Windows process backend interprets itself. - MCP tests: stdio transport cases skip on Windows instead of being compiled out (the scanner cannot evaluate #if guards). - SystemAsync tests: mark the POSIX process-helper suite with @requires-posix. Refs #65 --- src/IPC/Transport.cpp | 12 ++++++++++++ src/IPC/module.cmake | 1 + src/SystemAsync/AsyncProcess.cpp | 9 +++++++++ tests/standalone/MCP/Transport.cpp | 10 ++++++++-- tests/standalone/SystemAsync/SystemAsync.cpp | 1 + tests/standalone/SystemAsync/SystemAsyncShutdown.cpp | 3 +++ 6 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/IPC/Transport.cpp b/src/IPC/Transport.cpp index 9603b0b..af4fbfd 100644 --- a/src/IPC/Transport.cpp +++ b/src/IPC/Transport.cpp @@ -1,12 +1,24 @@ #include #include +#ifdef _WIN32 +#include +// MinGW's winsock2.h defines struct pollfd and the POLL* flags; WSAPoll is +// the Windows equivalent of poll(2). +inline int poll(struct pollfd* descriptors, + unsigned long count, + int timeout) +{ + return ::WSAPoll(descriptors, count, timeout); +} +#else #include #include #include #include #include #include +#endif #include #include diff --git a/src/IPC/module.cmake b/src/IPC/module.cmake index 1211b24..60d4eec 100644 --- a/src/IPC/module.cmake +++ b/src/IPC/module.cmake @@ -1,3 +1,4 @@ void_add_module(IPC INTERNAL_DEPS Core Functional Memory Time Binary Async IO Resilience + DEPS_WIN32 ws2_32 ) diff --git a/src/SystemAsync/AsyncProcess.cpp b/src/SystemAsync/AsyncProcess.cpp index 7ff29e0..ca2b438 100644 --- a/src/SystemAsync/AsyncProcess.cpp +++ b/src/SystemAsync/AsyncProcess.cpp @@ -5,6 +5,15 @@ #include +// MinGW's only defines the ANSI signals; the Windows process +// backend interprets these values itself. +#ifndef SIGTERM +#define SIGTERM 15 +#endif +#ifndef SIGKILL +#define SIGKILL 9 +#endif + #include #include #include diff --git a/tests/standalone/MCP/Transport.cpp b/tests/standalone/MCP/Transport.cpp index 1b9bbaa..dff54ff 100644 --- a/tests/standalone/MCP/Transport.cpp +++ b/tests/standalone/MCP/Transport.cpp @@ -292,9 +292,11 @@ Void::Testing::Test mcp_line_framer_bounds_and_crlf() std::string{"first\nsecond"}); } -#if !defined(_WIN32) Void::Testing::Test mcp_stdio_framing_dispatch_and_parse_error() { +#ifdef _WIN32 + Void::Testing::skip("POSIX pipe-based stdio transport"); +#else int input[2]{}; int output[2]{}; Void::Testing::require(::pipe(input) == 0); @@ -344,10 +346,14 @@ Void::Testing::Test mcp_stdio_framing_dispatch_and_parse_error() Void::Testing::require(error_response->error.has_value()); Void::Testing::expect_eq(error_response->error->code, std::int32_t{-32700}); +#endif } Void::Testing::Test mcp_stdio_cancellation_and_slow_reader() { +#ifdef _WIN32 + Void::Testing::skip("POSIX pipe-based stdio transport"); +#else // Cancellation while waiting on an empty, non-blocking input pipe. { int input[2]{}; @@ -408,8 +414,8 @@ Void::Testing::Test mcp_stdio_cancellation_and_slow_reader() ::close(output[0]); ::close(output[1]); } -} #endif +} Void::Testing::Test mcp_legacy_session_fixtures() { diff --git a/tests/standalone/SystemAsync/SystemAsync.cpp b/tests/standalone/SystemAsync/SystemAsync.cpp index ad5179c..5d5ec3d 100644 --- a/tests/standalone/SystemAsync/SystemAsync.cpp +++ b/tests/standalone/SystemAsync/SystemAsync.cpp @@ -1,3 +1,4 @@ +// @requires-posix: drives the POSIX process helper and descriptor semantics. #include #include #include diff --git a/tests/standalone/SystemAsync/SystemAsyncShutdown.cpp b/tests/standalone/SystemAsync/SystemAsyncShutdown.cpp index c155e3c..237b071 100644 --- a/tests/standalone/SystemAsync/SystemAsyncShutdown.cpp +++ b/tests/standalone/SystemAsync/SystemAsyncShutdown.cpp @@ -224,6 +224,9 @@ Void::Testing::Test systemasync_driver_shutdown_pending_pipe_read_retains_and_de // Unblock file worker and kill child -> Driver shutdown completes and delivers once. sys.gate.open(); +#ifndef SIGKILL +#define SIGKILL 9 +#endif (void)child.child().send_signal(SIGKILL); auto rep2 = drv.shutdown( Void::Async::OperationOptions{