Skip to content

Conversation

@3405691582
Copy link

@3405691582 3405691582 commented Oct 2, 2025

Motivation:

Additional partial platform support.

Modifications:

  • Create a new CNIOBSD module for OpenBSD, for general cleanliness, and make use of it throughout. Some of the changes are borrowed directly from CNIOLinux; some may technically be unnecessary; I am erring somewhat on expediency to functionality.

  • Since malloc_size is unavailable on OpenBSD, and some of the helpers make use of ManagedBufferPointer which makes use of it, mark some of this as unavailable as well.

  • Usual pthread optional typing changes, since pthread types are pointers on this platform.

  • Add conditionals to exclude other functionality not available here, like IP_RECVPKTINFO or IP_PKTINFO.

  • d_ino is a backwards-compatibility macro valued token for dirent, so instead, just expand with a conditional.

  • Use kqueue on OpenBSD. This necessitates adding some conditionals for type and feature compatibility.

  • The vsock API is unavailable on OpenBSD.

Result:

Tested the NIOTCPEchoClient and NIOTCPEchoServer appears to work and that swift-nio-ssh (hopefully wlog) builds with a local repository with these changes.

Because NIOFS/_NIOFileSystem depend on some non-portable components, such as extended attributes, sendfile, non-portable linkat flags, and renameat2, this is only just partial OpenBSD support, which means that swift build on the full swift-nio project won't build cleanly, but at least the portable parts can be used to build servers and clients. This commit will mark the linked bug as fixed; I will open a new bug for file system support.

Fixes #3383.

@rnro
Copy link
Contributor

rnro commented Oct 2, 2025

Thanks for contributing this and tackling the issue yourself.

@rnro
Copy link
Contributor

rnro commented Oct 2, 2025

I haven't performed a full review yet but I think having some very brief documentation of the current status of BSD support would probably be useful.

3405691582 and others added 5 commits October 2, 2025 18:05
Additional partial platform support.

* Create a new CNIOBSD module for OpenBSD, for general cleanliness, and
  make use of it throughout. Some of the changes are borrowed directly
  from CNIOLinux; some may technically be unnecessary; I am erring
  somewhat on expediency to functionality.

* Since `malloc_size` is unavailable on OpenBSD, and some of the helpers
  make use of ManagedBufferPointer which makes use of it, mark some of
  this as unavailable as well.

* Usual pthread optional typing changes, since pthread types are pointers
  on this platform.

* Add conditionals to exclude other functionality not available here,
  like IP_RECVPKTINFO or IP_PKTINFO.

* d_ino is a backwards-compatibility macro valued token for dirent, so
  instead, just expand with a conditional.

* Use kqueue on OpenBSD. This necessitates adding some conditionals for
  type and feature compatibility.

* The vsock API is unavailable on OpenBSD.

Tested the NIOTCPEchoClient and NIOTCPEchoServer appears to work and that
swift-nio-ssh (hopefully wlog) builds with a local repository with these
changes.

Because NIOFS/_NIOFileSystem depend on some non-portable components, such
as extended attributes, sendfile, non-portable linkat flags, and
renameat2, this is only just partial OpenBSD support, which means that
`swift build` on the full swift-nio project won't build cleanly, but at
least the portable parts can be used to build servers and clients. This
commit will mark the linked bug as fixed; I will open a new bug for file
system support.

Fixes apple#3383.
Co-authored-by: Rick Newton-Rogers <[email protected]>
@3405691582
Copy link
Author

I haven't performed a full review yet but I think having some very brief documentation of the current status of BSD support would probably be useful.

I added a line in README.md in the section describing platform support.

@3405691582 3405691582 requested a review from rnro October 3, 2025 15:12
@3405691582 3405691582 mentioned this pull request Oct 7, 2025
@3405691582
Copy link
Author

Anything else necessary here?

Copy link
Contributor

@rnro rnro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks

@Lukasa
Copy link
Contributor

Lukasa commented Oct 22, 2025

Hmm, sorry @3405691582 this seems to have gotten stuck. If you can fix up the conflicts we can try to shepherd this through.

@3405691582
Copy link
Author

Hmm, sorry @3405691582 this seems to have gotten stuck. If you can fix up the conflicts we can try to shepherd this through.

I reviewed the conflicting files from the incoming merge and resolved them.

@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Oct 22, 2025
@3405691582 3405691582 force-pushed the openbsd branch 3 times, most recently from db5c279 to 919d3d9 Compare October 22, 2025 15:33
@3405691582 3405691582 requested a review from Lukasa October 22, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BSD support

4 participants