Build: qualify Windows runtime and fix MinGW portability (refs #38)
This commit is contained in:
1 parent
1335fa86c3
commit
5d4589056a
8 files changed
+73
-27
No files matched your search
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user