Add option-taking pipe() implementation for Windows

This commit is contained in:
Guillaume Lessard committed 2026-06-09 16:27:18 -07:00
1 parent ebbbc31709
commit e59002fa14
6 files changed
+30 -7

No files matched your search

+8 -2
View File
@@ -619,10 +619,16 @@ internal var _O_DIRECTORY: CInt {
internal var _O_SYMLINK: CInt { O_SYMLINK }
#endif
#if !os(Windows)
@_alwaysEmitIntoClient
internal var _O_CLOEXEC: CInt { O_CLOEXEC }
internal var _O_CLOEXEC: CInt {
#if os(Windows)
O_NOINHERIT
#else
O_CLOEXEC
#endif
}
#if !os(Windows)
@_alwaysEmitIntoClient
internal var _O_CLOFORK: CInt {
#if !os(WASI) && !os(Linux) && !os(Android) && !canImport(Darwin)
@@ -206,6 +206,13 @@ internal func pipe(
return _pipe(fds, bytesReserved, _O_BINARY | _O_NOINHERIT);
}
@inline(__always)
internal func csystem_posix_pipe2(
_ fds: UnsafeMutablePointer<Int32>, bytesReserved: UInt32 = 0, _ oflag: Int32
) -> CInt {
return _pipe(fds, bytesReserved, _O_BINARY | oflag)
}
@inline(__always)
internal func ftruncate(_ fd: Int32, _ length: off_t) -> Int32 {
let handle: intptr_t = _get_osfhandle(fd)