2812 Commits
Author SHA1 Message Date
Klaas Pieter AnnemaandCory Benfield 1c30f0f205 Support options on AsyncTestingChannel and EmbeddedChannel (#3308)
Support options on AsyncTestingChannel and EmbeddedChannel

Fixes #3305 

### Motivation:

The channels are intended for testing purposes so while most options
have no practical use setting and getting them can be useful for
testing.

For example a traceroute implementation will set TTL to the current hop
number. Testing such an implementation requires the channels to pretend
to support the TTL option.

### Modifications:

Added option storage to AsyncTestingChannel and EmbedededChannel and
made `getOptionSync` and `setOptionSync` read and write from that
storage.

### Result:

EmbeddedChannel and AsyncTestingChannel support changing their options.

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2.86.0
2025-08-05 11:37:04 +01:00
Yuta Saito a114cfb471 [wasm][1/2] Add reusable WebAssembly workflow (#3331)
Add build check CI for WebAssembly SDK

### Motivation:

Add build check CI for WebAssembly SDK

### Modifications:

Add only reusable GHA workflow from
https://github.com/apple/swift-nio/pull/3159 to gracefully merge changes
without breaking CI.

After this change being merged into main branch, we can merge the actual
PR checks: https://github.com/apple/swift-nio/pull/3331

### Result:

Setting up the CI job makes it easier to detect such incompatibility
before merging.
2025-08-04 14:10:02 +00:00
Cory Benfield 41b126283c Don't double-initialize Pipe Bootstraps (#3330)
Motivation:

In #3309 I fixed an issue where the channel initializer would not be
called in some PipeBootstrap paths. Unfortunately, that introduced a new
bug where the initializer was now called twice on some other paths.

Modifications:

Get the number of calls back to 1 on the non-async paths. Add some tests

Result:

Better pipe bootstrap behaviour.
2025-08-01 10:11:41 +00:00
Cory Benfield 6719917e49 Add bpftrace support to stackdiff (#3329)
Motivation:

I had need of it, so I did it.

Modifications:

bpftrace output parses now

Result:

Better support
2025-08-01 09:45:59 +00:00
aryan-25andGeorge Barnett 96fbe40aae Add a new file path type, NIOFilePath, backed by SystemPackage's FilePath type (#3322)
Motivation:

Two separate types for representing file paths currently exist:
[`SystemPackage`'s
`FilePath`](https://swiftpackageindex.com/apple/swift-system/1.6.0/documentation/systempackage/filepath)
type and [`System`'s
`FilePath`](https://developer.apple.com/documentation/system/filepath)
type.

`NIOFileSystem` currently uses `SystemPackage`'s `FilePath`. However,
the lack of an API for converting between the two representations means
that users whose application also uses `System.FilePath` may find
interacting with `NIOFileSystem` difficult.

Modifications:

- Added `NIOFilePath`, and its subcomponents `NIOFilePath.Root`,
`NIOFilePath.Component`, and `NIOFilePath.ComponentView`.
- These types mirror the API of `SystemPackage`'s `FilePath` and are
internally backed by it.
- `NIOFilePath` can be initialized from either an instance of
`SystemPackage.FilePath` or `System.FilePath`.

Result:

Reduces the friction of interacting with `NIOFileSystem` by providing a
bridge between `SystemPackage.FilePath` and `System.FilePath`.

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-07-30 15:13:50 +01:00
Rafael Cepeda 02be63c7f4 Fixes all warnings when -require-explicit-sendable flag is enabled (#3320)
Fixes all warnings when `-require-explicit-sendable` flag is enabled and
enables the flag on macOS CI.

### Motivation:

We want to ensure our public API is either explicitly marked as
`Sendable` or not.

### Modifications:

Marked appropriate public types as `Sendable`, or explicitly defined
their conformance to the `Sendable` protocol as unavailable.

### Result:

We can now enable `-require-explicit-sendable` compiler flag in our
codebase.
2025-07-30 11:50:28 +01:00
Raphael 95c91a42a9 Enable release mode builds (#3327)
### Motivation:

Some errors do not show up in debug builds. Enabling release mode builds
improves the CI coverage.

### Modifications:

Enable release mode builds for pull requests and scheduled builds on
main.

### Result:

Improved CI coverage.
2025-07-30 08:59:02 +01:00
Raphael e0ef60bb98 Do not run windows nightly CI by default (#3325)
### Motivation:

Not everything that relies on these workflows builds on windows. Unit
tests and release builds should be explicitly enabled for windows
builds.

### Modifications:

Change default of windows nightly to false. Fix flag checks that enable
nightly builds.

### Result:

Easier to use CI workflows.
2025-07-29 14:49:04 +01:00
Raphael 6b48b36c7e Add workflow for release mode builds(#3321)
Add a new workflow file for release mode builds

### Motivation:

Some errors do not show up in debug builds. Running release mode builds
improves the CI coverage.

### Modifications:

Add a new workflow for release mode builds.

### Result:

Projects can build on this workflow to enable release mode builds.
2025-07-29 10:35:10 +01:00
Fabian Fett 4205ccaf1c [Windows] IOVector is WSABUF on Windows (#3324)
On Windows there is no iovec, because of this we need to make sure,
that:

1. We use the typealias `IOVector` as much as possible
2. We add platform specific code to `IOVector` extensions

Also adds some more Windows imports to fix some compiler errors.
2025-07-28 18:52:00 +02:00
Max Desiatov 175417d85c Fix typo in HTTPServerClientTest.swift comments (#3323)
`we read faster then we can write` -> `we read faster than we can write`
2025-07-28 12:46:19 +00:00
Fabian Fett 1d72f49390 [Windows] Ensure NIOEmbedded compiles (#3319)
Make NIOEmbedded compile.
2025-07-24 16:02:00 +00:00
Fabian Fett 06f236d37a [Windows] Windows has endianess too (#3317)
TIL there is an `endian.h` on Linux and macOS that is imported through
`<sys/types.h>` on Linux and Apple platforms. Apparently such a header
file does not exist in Windows land. For this reason we need to define
the macros that we need here ourselves.
2025-07-23 17:06:18 +01:00
Rafael Cepeda d6609623dd Fix docc (#3315)
This change fixes an example shown in the ServerBootstrap documentation.

### Motivation:

The current example given to users of ServerBootstrap will show a
Sendable conformance warning in Swift 6.0 or later.

### Modifications:

Changed the example to use `syncOperations`

### Result:

The new example doesn't contain any warnings.
2025-07-23 13:37:57 +01:00
Mike DrobandCory Benfield b8b1940bd5 Move conditional setup logic from bash to actions (#3313)
Instead of checking for a setup command in bash, we use GitHub Actions
to determine if there is anything to run

### Motivation:

Slightly cleaner output when looking at logs.

### Modifications:

Moved an if statement from bash to yaml.

### Result:

The setup commands step will generally be skipped instead of executing a
no-op

Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-07-22 14:38:38 +00:00
Evan Wilde f9b58f26ca CMake Updater: Output difference in expectations (#3314)
Teach the script to indicate what is different on failure rather than
keeping quiet. This helps when the script is failing in CI but not
locally.

### Motivation:

The script is reporting that there are missing changes in CI on
swift-crypto, but I am unable to reproduce them locally. This is to get
immediate insight on why the check fails rather than keeping quiet.

### Modifications:

Include the diff in the update-cmake-lists script.

### Result:

update-cmake-lists script outputs the difference between what is in a PR
vs what it expects to see instead of shrugging and leaving it as an
exercise to the user.
2025-07-22 13:55:46 +00:00
Rafael Cepeda a5fea865ba Fixes a small mistake in the NIOTCPEchoServer README file (#3311)
Fixes a small mistake in the NIOTCPEchoServer README file.
2.85.0
2025-07-21 08:16:51 +01:00
George Barnett cae0a353d1 Remove Foundation import (#3310)
Motivation:

The package manifest imports Foundation.ProcessInfo to read environment
variables ... but doesn't.

Modifications:

- Remove unused import

Result:

- Fewer Foundation imports
2025-07-18 14:46:40 +00:00
Cory Benfield ee67a96bcb Call channel initializer when using async methods on pipe bootstrap (#3309)
Motivation:

For our async initializers on bootstraps, it's imortant that _both_
channel initializers are called, not only the one that comes as an
argument on the bind function.

Modifications:

Fix the takeOwnershipOfDescriptor async functions to call the
initializer from the bootstrap, and add regression tests.

Result:

Better behaved code.
2025-07-18 09:13:00 +01:00
George Barnett 66483af202 Pick visionOS version for Xcode 16.2 (#3307)
Motivation:

The nightly visionOS tests are failing because there
are too many simulators matching the given destination 
selector.

Modifications:

- On Xcode 16.2 use visionOS 2.3

Result:

Nightly CI passes
2025-07-17 13:24:44 +01:00
Johannes Weiss 344db24aaa NIOThread: remove the detached threads functionality (#3304)
### Motivation:

Detached threads are a bad idea, their lifetime becomes random and NIO
doesn't need this functionality (except for in some tests that are
easily refactored)

### Modifications:

- Refactor tests to not use detached threads
- Remove detached threads functionality

### Result:

- Cleaner, less complex and more correct code
2025-07-15 15:20:20 +01:00
Ali AliandGeorge Barnett fe923bbbe6 Make file handle sendable (#3300)
Solve Issue-3295

### Motivation:

Solve https://github.com/apple/swift-nio/issues/3295

### Modifications:

Make a few objects send able. 

### Result:

WriteFileHandle will be sendable

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-07-15 12:43:22 +00:00
Johannes Weiss 933b9d738d Structured Concurrency compliant MTELG create/shutdown (#3296)
### Motivation:

Structured Concurrency is helpful but so far, MTELG was very difficult
to use with it mostly because Swift is still missing `async` in
`defer`s.

This builds on
- #3297 
- #3302
- #3304

### Modifications:

- Add MTELG.withELG { ... }

### Result:

MTELG + SC = <3
2025-07-15 12:14:04 +01:00
Johannes Weiss acca4e525c NIOThread refactor: pthread_t lifetimes (#3297)
### Motivation:

NIOThread assumed it can hold onto `pthread_t` forever. Unfortunately,
on Linux, `pthread_t` is dead when the thread got joined (if not
detached) or if it exits (if detached) _which is at a random point in
time_.

### Modifications:

- Only assume ownership owner the `pthread_t` if not detached
- `nil` out the `pthread_t` on `join()`

### Result:

- Fewer `pthread_t` lifecycle bugs.
2025-07-15 10:03:12 +01:00
George BarnettandCory Benfield 664032bdd6 Wrap closures stored in the CallbackList (#3303)
Motivation:

The compiler is better at optimising closures wrapped in nominal types
than raw closures when used as generic parameters. CallbackList is used
a lot and stores an optional closure as well as on optional array of
closures. Wrapping these internally should save some allocations.

Modifications:

- Wrap the element stored in the `CallbackList`.

Result:

Fewer allocs

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-07-14 16:48:26 +00:00
Johannes Weiss 0b65385fad improve inEventLoop checks (#3302)
### Motivation:

`inEventLoop` is very much in the performance path of SwiftNIO,
especially these days with Concurrency, `NIOLoopBound` and friends.
Previously, we relied on `pthread_equal(pthread_self(), myPthread)`,
however, this could cause a number of issues.

1. Holding onto a `pthread_t` after `.join` is actually illegal (fixed
in #3297)
2. Potential ABA issues when `pthread_t` pointer are re-used for new
pthreads
3. Fix would require a lock around `myPthread` which makes things (2x
slower, even without contention)

### Modifications:

- New type `SelectableEventLoopUniqueID` which can be packed into a
`UInt`
- Attach them into a C thread local

### Result:

- Even faster than the old, incorrect version
- old: `measuring: el_in_eventloop_100M: 0.257395375, 0.241049208,
0.243188792, 0.259125916, 0.24843225, 0.229690125, 0.244281541,
0.225078834, 0.236395, 0.233305167`
- new: `measuring: el_in_eventloop_100M: 0.175561125, 0.187225625,
0.199269375, 0.19740975, 0.1922695, 0.179850958, 0.177612458,
0.17665125, 0.17897475, 0.18038775`
- More correct
- Groundwork to make #3297 not make things slower
2025-07-14 17:15:10 +01:00
Johannes Weiss 57d65ddf9c inEventLoop benchmark (#3301)
### Motivation:

PR #3297 is changing `inEventLoop` and `inEventLoop` is very much on the
perf path. So let's add a benchmark

### Modifications:

- Add `(!)inEventLoop` benchmark
- Fix a guaranteed deadlock in `TCPThroughputBenchmark` to make the
benchmarks runnable

### Result:

- More benchmarks
- Fewer hangs
2025-07-14 10:50:58 +00:00
Jesse L. Zamora d09773bd4f ensure <stddef.h> is not imported within extern "C" (#3299)
Add patch for `<stddef.h>` being included inside of extern "C" section
which is invalid in C++.

### Motivation:

When building with C++ interop enabled on Linux, `<stddef.h>` fails to
import because the C++ module `_Builtin_stddef.max_align_t` (which it
includes) is re-imported with C language linkage.

```
<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "/home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/CNIOLLHTTP.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/CNIOLLHTTP.h:20:10: note: in file included from /home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/CNIOLLHTTP.h:20:
18 | #define C_NIO_LLHTTP_SWIFT
19 | 
20 | #include "c_nio_llhttp.h"
   |          `- note: in file included from /home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/CNIOLLHTTP.h:20:
21 | 
22 | static inline llhttp_errno_t c_nio_llhttp_execute_swift(llhttp_t *parser,

/home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/c_nio_llhttp.h:559:10: note: in file included from /home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/c_nio_llhttp.h:559:
557 | extern "C" { 
558 | #endif
559 | #include <stddef.h>
    |          `- note: in file included from /home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/c_nio_llhttp.h:559:
560 | 
561 | #if defined(__wasm__)

<unknown>:0: error: could not build C module 'CNIOLLHTTP'
/home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/recipe-sysroot-native/usr/lib/clang/17/include/stddef.h:128:1: error: import of C++ module '_Builtin_stddef.max_align_t' appears within extern "C" language linkage specification
126 | 
127 | #if defined(__need_max_align_t)
128 | #include <__stddef_max_align_t.h>
    | `- error: import of C++ module '_Builtin_stddef.max_align_t' appears within extern "C" language linkage specification
129 | #undef __need_max_align_t
130 | #endif /* defined(__need_max_align_t) */

/home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/c_nio_llhttp.h:557:1: note: extern "C" language linkage specification begins here
555 | #define INCLUDE_LLHTTP_API_H_
556 | #ifdef __cplusplus
557 | extern "C" { 
    | `- note: extern "C" language linkage specification begins here
558 | #endif
```

### Modifications:

Added a patch to the `update_and_patch_llhttp.sh` file to move this
include to the correct location, and ran the script to actually apply it
to the included `c_nio_llhttp.h` file in the `CNIOLLHTTP` target.

### Result:

swift-nio compiles properly on a package with C++ interop
(`.interoperabilityMode(.Cxx)`) enabled in Linux.

@lhoward @Lukasa
2025-07-14 07:08:19 +00:00
Jesse L. Zamora 2f322f1053 Run update_and_patch_llhttp.sh script to update to 9.3.0 (#3298)
Update llhttp dependency in `CNIOLLHTTP` target ahead of adding a new
patch to the `update_and_patch_llhttp.sh` script.

### Motivation:

We need to update the `update_and_patch_llhttp.sh` script to add an
additional patch to fix compiling swift-nio with C++ interop enabled in
Swift targets. It was recommended to update llhttp separately from the
patch update and ahead of time to keep the changes separate from each
other.

### Modifications:

Ran the `update_and_patch_llhttp.sh` script in the CNIOLLHTTP target to
update the llhttp dependency to the latest version (9.3.0). It appears
that the only changes from 9.2.1 (previous version) is a few new
includes, and the definition of the `UNREACHABLE` macro that is used
instead of the `abort()` call.

### Result:

Everything compiles locally and test suite passes with these changes.

@Lukasa
2025-07-12 14:22:15 +00:00
Cory Benfield 99ac8ec29c Add bpftrace allocations script (#3113)
Motivation:

When debugging allocations it is frequently helpful to be able to use
bpftrace instead of the more limited heaptrack.

Modifications:

Offer an equivalent of malloc-aggregation.d for bpftrace.

Result:

Allocation recording on Linux is available.
2025-07-11 11:58:05 +00:00
George Barnett 123887dc4d Add DocC docs for running alloc tests and debugging them (#3293)
Motivation:

Our docs for running alloc counting benchmarks are scattered between a
few places, and our info about debugging allocations is also a bit
outdated.

Modifiactions:

- Add a doc on running the two different flavours of allocation counting
test. Remove the entry about bencharks from the README.
- Add a doc on debugging allocations

Most of the content comes from the original
`docs/debugging-allocations.md` doc but has been updated a little and
includes info about the new stackdiff tool.

Result:

Better docs
2025-07-10 15:31:24 +01:00
Mike Drob 83bc5b5844 chore: avoid spurious xcodebuild warning (#3291)
Specify default macOS variant in non-catalyst builds.

https://developer.apple.com/forums/thread/737851

### Motivation:

macOS build has an extra warning:

```
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, name:Any Mac }
{ platform:macOS, variant:Mac Catalyst, name:Any Mac }
```

### Modifications:

Explicitly select the macOS variant.

### Result:

No warnings
2025-07-09 09:35:31 +01:00
George Barnett 086c93ba19 Add stackdiff merging (#3290)
Motivation:

When you diff two sets of alloc stacks there are often natural pairings
which aren't exact matches (e.g. the compiler inlined something in one
but not the other). These are tedious to pair up manually, we can make
that easier.

Modifications:

- Add a 'merge' which allows you to interactively pair up stacks across
the two different sets by using the levenshtein distance between them.
- After interactive merging is complete any remaining alloc stacks.

Result:

Easier to diff stacks
2025-07-08 16:06:55 +00:00
George Barnett 4d7097406f Add stackdiff dump (#3289)
Motivation:

Sometimes it's helpful to view the alloc stacks from a program.

Modifications:

- Add a 'dump' subcommand to stackdiff allowing you to dump the stack
diff from heaptrack/dtrace/bpftrace
- You can also filter the stacks so that only certain stacks are
included

Result:

Can dump filtered alloc stacks to stdout
2025-07-08 13:37:25 +00:00
George Barnett 7ea505e5bf Add dtrace parsing (#3288)
Motivation:

We often debug allocations on macOS, so being able to parse the output
from malloc-aggregation.d is valuable.

Modifications:

- Add a dtrace parser to stackdiff

Result:

Can diff outputs from dtrace
2025-07-08 11:18:42 +01:00
George Barnett 67df59a0fa Add diffing to the stackdiff tool (#3287)
Motivation:

When debugging allocs its helpful to get a diff between two programs.

Modification:

- Adds a 'diff' subcommand which is roughly equivalent to the existing
'stackdiff-dtrace.py' script.

Result:

Alloc stacks can be diffed
2025-07-07 15:43:46 +00:00
George Barnett e84b2ce05a Add internals for stackdiff tool (#3286)
Motivation:

Our alloc regression workflows are somewhat disparate: on macOS we have
dtrace and a script to diff two ouputs. On Linux we have heaptrack and
bpftrace but no way to analyze their outputs.

Diffing output from these tools can be quite tedious if the stacks vary
even a little (because the compiler decided to not inline a function,
for example).

Most of the tedium in this workflow is from pairing up equivalent stacks
across the two inputs. We can make this easier to do by ranking
suggestions based on how similar they are and letting the user decide
whether to accept the match or not.

Modifications:

- Add a subpackage with some internals for parsing heaptrack,
aggregating stacks, and measuring the similarity between them
- The CLI took is currently a no-op, it'll be added in subsequent PRs

Result:

Easier to diagnose alloc regressions
2025-07-07 14:04:55 +00:00
Rick Newton-Rogers 09030f291f Make use of symlink to latest Xcode beta (#3285)
### Motivation:

The macOS runners have a symlink to the latest released Xcode beta at
Xcode-latest.app, by making use of it we will always test against the
most recent version.

### Modifications:

Introduce new parameters for the latest Xcode beta and deprecate those
which mention Xcode 21 betas.

### Result:

Tests will move on to using Xcode 26 beta 2 via the symlink

Example of this working
https://github.com/apple/swift-nio/actions/runs/16075841548/job/45370760690?pr=3285
2025-07-04 16:12:08 +01:00
Rick Newton-Rogers c39d34d0b7 Update generate_matrix.sh for windows nightlies to 2022 images (#3284)
Update generate_matrix.sh for windows nightlies to 2022 images as the
2019 images are retired
2025-07-04 09:25:53 +01:00
Cory Benfield ed9e5760c6 Functions that return values should return those values (#3283)
Motivation:

The title really says it all.

Modifications:

Have the Android shim actually do what it should

Result:

Fewer horrifying memory safety bugs
2025-07-03 15:25:30 -07:00
Cory Benfield 70439feacd Widen the allocation limit on nightlies (#3280)
Nightly CI fails occasionally because the allocs on low-overhead lists
occasionally break 20. Give ourselves some breathing room here.
2025-07-01 11:45:13 -07:00
Cory Benfield ad6b5f1727 Work around Android nullability errors (#3279)
Motivation:

Android messed up their nullability annotations in fts_open. The
original change in
https://android.googlesource.com/platform/bionic/+/dec8efd72a6ad8b807a15a614ae1519487cfa456
asserted that fts_open's path argument took a non-null pointer to an
array of non-null pointers to strings. That's challenging, because the
_end_ of that array is indicated by a null pointer.

Regardless, this was eventually fixed in

https://android.googlesource.com/platform/bionic/+/da81ec4d1cbd0279014feb60535bf38defcd9346.
Unfortunately, that was more than a year after the offending change, so
we need to work around it.

Modifications:

Add a shim for Android that omits the nullability annotations. Use that
shim on Android.

Result:

Android works again.
Resolves #3273.
2.84.0
2025-07-01 08:11:16 +01:00
Luke HowardandCory Benfield 8d265e31fc Support for 64-bit timespec seconds on 32-bit platforms (#3277)
Modern 32-bit platforms (such as embedded Linux builds) support 64-bit
timestamps in `time_t` and `timespec`. Accommodate this.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-06-30 17:08:50 +00:00
Alex AzarovandRick Newton-Rogers 91a5eded13 Fix API documentation links in README.md (#3276)
Point API docs URLs to the latest stable version instead of the unstable
main branch.

### Motivation:

For most of developers this README.md is the main entry point when
searching online or installing the library, so pointing them to API docs
for the latest stable release makes more sense then the main branch,
which may contain not-yet-released API or breaking changes.

### Modifications:

This PR removes `main` branch name from API docs URLs, making them
always point to the latest stable release instead of the main branch.

### Result:

API docs URLs in README.md point to the latest stable release.

Co-authored-by: Rick Newton-Rogers <rnro@apple.com>
2025-06-30 09:43:01 +00:00
Fabrice de Gans f5339fbb21 Add assembly files for Windows (#3275)
Add assembly files for Windows

### Motivation:

These assembly files are now required to build on Windows Arm64.

### Modifications:

* The Windows assembly files are now handled in `update-cmake-lists.sh`.

### Result:

The assembly source files will be properly updated in `swift-crypto`.
2025-06-27 19:52:10 +00:00
scottmarchant 15dfe081a1 fix: Fix compiler error found on latest main that breaks wasip1 (wasm) compilation (#3271)
This is a quick simple fix for compiling NIOCore to wasm using the
command `swift build --swift-sdk wasm32-unknown-wasip1-threads --target
NIOCore`.

This fixes all errors for `wasip1`, however there are other errors
remaining in `main` when compiling for `wasi` using the command `swift
build --swift-sdk wasm32-unknown-wasi --target NIOCore`. Those issues
are out of scope for this PR.

### Motivation:

I am working to enable wasm compilation for a wide range of repositories
which depend on NIOCore. See
[here](https://github.com/PassiveLogic/swift-web-examples/issues/1) for
a sneak peak. This change is required to enable compiling several
respositories.

### Modifications:

`.multicastNotSupported` is elided for `os(WASI)` builds in
Channel.swift, however some new code referenced that case without proper
`WASI` guards.

This modification simply adds the appropriate elision guard to fix
wasip1 builds for NIOCore.

### Result:

After making this change, `swift build --swift-sdk
wasm32-unknown-wasip1-threads --target NIOCore` builds again (assuming
you have the appropriate wasm sdk installed).
2025-06-24 09:52:12 +00:00
Rafael Cepeda 89be322fe8 Fixed issue with macOS CI when overrides are being used. (#3270)
Fixed issue with macOS CI when overrides are being used.

### Motivation:

When we use Xcode_XX_X_build_arguments_override, the CI fails because of
an extra double quotes ("") making its way to the final command.

### Modifications:

Remove the extra double quote from the Yaml file defining macOS tests.

### Result:

We are able to run `swift build` with extra arguments.
2025-06-20 11:24:21 +01:00
Paul ToffoloniandFabian Fett 8d2347a56b Add scheduleCallback APIs to NIOIsolatedEventLoop (#3263)
Fixes #3262 by adding the missing APIs.

### Motivation:

As explained by the issue linked above, having a
non-`Sendable`-requiring variant of the new `scheduleCallback` APIs on
`NIOIsolatedEventLoop` can be useful since we're not always dealing with
`Sendable` types.

### Modifications:

This adds the required `scheduleCallback` APIs to `NIOIsolatedEventLoop`
by wrapping the non-`Sendable` `NIOScheduleCallbackHandler` in a
`NIOLoopBound`-based handler.
### Result:

The two `scheduleCallback`s can be used on `NIOIsolatedEventLoop` too.

---------

Co-authored-by: Fabian Fett <fabianfett@apple.com>
2025-06-18 14:54:33 +01:00
Orhan Yigit Yazicilar cddbde511a Adding RawSpan support to writeBytes in ByteBuffer (#3269)
Motivation:

With the new Swift version (6.2) we get access to spans for safely
interacting with the contiguous memory owned by other types. Allow users
write bytes to the ByteBuffer with RawSpans.

Modifications:

* ByteBuffer-core: Overload the setBytes, _setBytes, and
_setBytesAssumingUniqueBufferAccess to use RawSpan instead of
UnsafeRawBufferPointer
* ByteBuffer-aux: Overload the writeBytes to use RawSpan instead of
UnsafeRawBufferPointer

Result:

Users can now write the contiguous memory of other types into ByteBuffer
using the new RawSpan overloads, removing the need for unsafe pointer
handling.
2025-06-16 17:11:03 +00:00
RaphaelandGeorge Barnett 357955a8e6 Extend NIOEventLoopTickInfo with end-time and loop sleep time (#3268)
### Motivation

NIO’s event loop can emit metrics. Currently, this includes the start
time (i.e. when the loop started working) and the number of tasks which
were executed in that tick.

It would be useful to collect the time the loop tick ended and the
length of time the loop was asleep before starting the tick.

### Modifications

The event loop has a new property to track the time between runs. The
tick info collects two new values:

* The time the loop finished: the end-time.
* The time since the last run: the sleep time.

For the first run, the sleep time is the time since the event loop was
created.

### Result

The new metrics are available for collection.

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-06-16 15:34:56 +01:00