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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BSD support

3 participants