Build: qualify Windows runtime and fix MinGW portability (refs #38)

This commit is contained in:
faumaray committed 2026-12-03 17:07:16 +03:00
1 parent 1335fa86c3
commit 5d4589056a
8 files changed
+73 -27

No files matched your search

+9 -3
View File
@@ -315,9 +315,11 @@ Void::Testing::Test io_mock_stop_completion_races_and_clock_timeout()
}
}
#ifdef __linux__
Void::Testing::Test io_epoll_socketpair_fragmented_half_close_and_fd_reuse()
{
#ifndef __linux__
Void::Testing::skip("epoll backend is Linux-only");
#else
ManualExecutor exec;
auto drv_res = Driver::create(
exec,
@@ -453,10 +455,14 @@ Void::Testing::Test io_epoll_socketpair_fragmented_half_close_and_fd_reuse()
(reused->first.id().generation > a_orig_id.generation) ||
(reused->second.id().generation > a_orig_id.generation);
Void::Testing::expect(bumped);
#endif
}
Void::Testing::Test io_epoll_cross_thread_wake_poll_and_stop_tsan()
{
#ifndef __linux__
Void::Testing::skip("epoll backend is Linux-only");
#else
ManualExecutor exec;
auto drv_res = Driver::create(exec, BackendOptions{.preference = BackendPreference::epoll});
Void::Testing::require(drv_res.has_value());
@@ -505,5 +511,5 @@ Void::Testing::Test io_epoll_cross_thread_wake_poll_and_stop_tsan()
driver.wake();
poller.join();
(void)b.valid();
}
#endif // __linux__
#endif
}
+18 -2
View File
@@ -44,6 +44,20 @@ namespace
using namespace std::chrono_literals;
#if defined(_WIN32)
// The MinGW CRT has no O_CLOEXEC and no fcntl(F_GETFD); the POSIX-only
// descriptor assertions below are guarded separately.
int open_readonly(const std::filesystem::path& path)
{
return ::_wopen(path.c_str(), _O_RDONLY);
}
#else
int open_readonly(const std::filesystem::path& path)
{
return ::open(path.c_str(), O_RDONLY | O_CLOEXEC);
}
#endif
using Void::Async::ManualExecutor;
using Void::Async::OperationOptions;
using Void::Async::TaskScope;
@@ -535,7 +549,7 @@ Void::Testing::Test io_file_native_roundtrip_isolated_tmpdir()
expect_eq(drv->telemetry().active_descriptors, std::size_t{0});
// adopt_file_fd and a default (read-only) open of the same path.
auto ro = drv->adopt_file_fd(::open(path.c_str(), O_RDONLY | O_CLOEXEC));
auto ro = drv->adopt_file_fd(open_readonly(path));
require(ro.has_value());
File ro_file = std::move(*ro);
auto ro2 = drv->open_file(path);
@@ -1814,10 +1828,12 @@ Void::Testing::Test io_file_counts_against_max_descriptors()
expect(!std::filesystem::exists(third));
// adopt_file_fd takes ownership only on success.
const int fd = ::open(dir.file("first.bin").c_str(), O_RDONLY | O_CLOEXEC);
const int fd = open_readonly(dir.file("first.bin"));
require(fd >= 0);
expect(failed_with(drv->adopt_file_fd(fd), IoErrorCode::overloaded));
#if !defined(_WIN32)
expect(::fcntl(fd, F_GETFD) != -1);
#endif
spawn(scope, do_close(&file, {}, &c));
(void)exec.drain();