Commit Graph
8 Commits
Author SHA1 Message Date
scottmarchant 5bf0267df4 build: Elide NIOPosix for WASI platforms only (#3485)
### Motivation:

Packages that consume NIOPosix should be able to compile to WASI
platforms without special configurations. This change elides the
NIOPosix source from WASI platforms to simplify configuration.

Without this change:

```swift
dependencies: [
    // Without this PR, downstream packages must maintain exhaustive platform list to exclude `.wasi`:
    .product(
        name: "NIOPosix",
        package: "swift-nio",
        condition: .when(platforms: [
            .macOS,
            .macCatalyst,
            .iOS,
            .tvOS,
            .watchOS,
            .visionOS,
            .driverKit,
            .linux,
            .windows,
            .android,
            .openbsd,
            // .wasi // <-- Need to exclude this, because there is no exclusion list api for SPM conditionals
        ])
    ),
]
```

With this change:

```swift
dependencies: [
    // Without this PR, downstream packages can consume NIOPosix simply:
    .product(name: "NIOPosix", package: "swift-nio"),
]
```

### Modifications:

- Add compiler directives (`#if !os(WASI)`) to all source files in
NIOPosix

### Result:

Downstream packages can compile to wasm without manually excluding the
NIOPosix dependency.

### Testing performed

- Verified `swift build --swift-sdk wasm32-unknown-wasip1 --target
NIOPosix` compiles, which demonstrates proper elision of source files in
NIOPosix that aren't wasm-ready.
- Confirmed GitHub [checks
pass](https://github.com/PassiveLogic/swift-nio/actions/runs/21151341738).
2026-01-23 16:39:32 +00:00
Fabian Fett e95d742160 [Windows] Reimplement pwrite (#3364)
Very much like #3361. Just for writing.

Result: NIOPosix compiles on Windows.
2025-09-01 16:12:41 +02:00
Fabian Fett 5bf5054a83 [Windows] Reimplement pread (#3361)
- pread does not exist in ucrt. We need to reimplement it using read and
lseek.
- `FileDescriptor.setNonBlocking` is currently not needed in Windows to
compile. Let's not compile it.
- Set up correct sys calls for lseek and ftruncate
2025-08-29 13:39:04 +01:00
Fabian Fett e8c1d6e09b [Windows] Disable Pipelines for now (fatalError) (#3358)
### Motivation

In Linux we can use `epoll` to observe sockets and pipes. WSAPoll sadly
only works for sockets. To observe pipes in Windows we can use
`WaitForMultipleObjects`. However we should try to get to a place where
we can start to fix tests first.

### Changes

- fatalError all pipe functions that do not compile right now.
2025-08-26 12:08:14 +00:00
Fabian Fett aff71b37f5 [Windows] Use recv instead of read (#3357) 2025-08-26 10:30:46 +00:00
Fabian Fett 148589720a [Windows] Add shims to make string from GetLastError using FormatMessage (#3353)
If we receive a functions error via `GetLastError`, we can stringify it
via `FormatMessage`. Sadly `FormatMessage` isn't auto imported into
Swift, which is why we need to use the shim layer.
2025-08-19 14:31:06 +00:00
Fabian Fett 5dca91e191 [Windows] Make SelectableEventLoop compile (#3344)
- Add overwrite for `write` method that calls undeprecated `_write`
- Add errno global readonly variable
2025-08-13 09:18:50 +00:00
Fabian Fett 357ff9f16e [Windows] Map naming conventions Windows -> Posix (ssize_t) (#3343)
`ssize_t` doesn't exist in Windows land. Windows loves uppercase naming.
Therefore we need a typealias.
2025-08-12 17:37:00 +00:00