Skip to content

Commit ac6ec0b

Browse files
committed
SystemInternals: make WindowsSyscallAdapters build
Correct some type errors, missing return type. Add a FIXME comment regarding large file access.
1 parent bf90fed commit ac6ec0b

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Sources/SystemInternals/Exports.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ import Glibc
2121

2222
public typealias COffT = off_t
2323

24+
#if os(Windows)
25+
public typealias CModeT = CInt
26+
#else
27+
public typealias CModeT = mode_t
28+
#endif
29+
2430
// MARK: syscalls and variables
2531

2632
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)

Sources/SystemInternals/WindowsSyscallAdapters.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99

1010
#if os(Windows)
1111

12+
import ucrt
13+
import WinSDK
14+
1215
@inline(__always)
13-
internal func open(_ path: UnsafePointer<CChar>, _ oflag: Int32) {
16+
internal func open(_ path: UnsafePointer<CChar>, _ oflag: Int32) -> CInt {
1417
var fh: CInt = -1
1518
_ = _sopen_s(&fh, path, oflag, _SH_DENYNO, _S_IREAD | _S_IWRITE)
1619
return fh
1720
}
1821

1922
@inline(__always)
2023
internal func open(
21-
_ path: UnsafePointer<CChar>, _ oflag: Int32, _ mode: mode_t
24+
_ path: UnsafePointer<CChar>, _ oflag: Int32, _ mode: CModeT
2225
) -> CInt {
2326
// TODO(compnerd): Apply read/write permissions
2427
var fh: CInt = -1
@@ -33,9 +36,9 @@ internal func close(_ fd: Int32) -> Int32 {
3336

3437
@inline(__always)
3538
internal func lseek(
36-
_ fd: Int32, _ off: off_t, _ whence: Int32
37-
) -> off_t {
38-
_lseek(fd, off, whence)
39+
_ fd: Int32, _ off: Int64, _ whence: Int32
40+
) -> Int64 {
41+
_lseeki64(fd, off, whence)
3942
}
4043

4144
@inline(__always)

0 commit comments

Comments
 (0)