Skip to content

Adds FreeBSD CMSG helpers and resolve MemberImportVisibility errors#3594

Draft
rafaelcepeda wants to merge 14 commits into
apple:mainfrom
rafaelcepeda:freebsd-bsdsocketapi
Draft

Adds FreeBSD CMSG helpers and resolve MemberImportVisibility errors#3594
rafaelcepeda wants to merge 14 commits into
apple:mainfrom
rafaelcepeda:freebsd-bsdsocketapi

Conversation

@rafaelcepeda
Copy link
Copy Markdown
Contributor

Adds FreeBSD CMSG function bindings in BSDSocketAPIPosix.swift and add import CNIOFreeBSD across all NIOPosix files that access struct members defined by FreeBSD system headers.

Motivation:

After wiring CNIOFreeBSD in System.swift, the remaining build errors on FreeBSD were: (1) BSDSocketAPIPosix.swift referencing CNIOLinux_CMSG_* functions that don't exist on FreeBSD, (2) dozens of MemberImportVisibility errors where files access struct members (msg_hdr, msg_len, sin_addr, sa_family, iov_base, etc.) without importing the defining module, and (3) F_SETNOSIGPIPE not existing on FreeBSD.

Modifications:

  • Added #elseif os(FreeBSD) case in BSDSocketAPIPosix.swift wiring all 6 CMSG helpers to CNIOFreeBSD_CMSG_* functions.
  • Added import CNIOFreeBSD to: BaseSocket.swift, DatagramVectorReadManager.swift, PendingDatagramWritesManager.swift, PendingWritesManager.swift, Socket.swift, SocketChannel.swift.
  • Changed ControlMessage.swift to import CNIOFreeBSD instead of CNIOLinux on FreeBSD.
  • Added os(FreeBSD) to the global SIGPIPE-ignoring path in SocketProtocols.swift (FreeBSD doesn't have F_SETNOSIGPIPE).

Result:

NIOPosix error count on FreeBSD drops from 75 to 12. Remaining errors are: Vsock support (FreeBSD doesn't have AF_VSOCK), missing in_pktinfo type, and globallyIgnoredSIGPIPE not being defined for FreeBSD.

@rafaelcepeda rafaelcepeda force-pushed the freebsd-bsdsocketapi branch from f9abceb to efbfccd Compare May 12, 2026 17:30
@rafaelcepeda rafaelcepeda added the 🔨 semver/patch No public API change. label May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant