Skip to content

Make multicast-group helpers and vsock fallback portable to QNX#20

Merged
dallison merged 2 commits intomainfrom
qnx-port
May 1, 2026
Merged

Make multicast-group helpers and vsock fallback portable to QNX#20
dallison merged 2 commits intomainfrom
qnx-port

Conversation

@dallison
Copy link
Copy Markdown
Owner

Summary

Two small portability fixes that let cpp_toolbelt compile on QNX 8 (Neutrino) while staying buildable on Linux, macOS and BSDs. Pairs with the QNX port of subspace: dallison/subspace#62.

This PR is draft because it has only been reviewed statically — it has not yet been built on a real QNX target.

toolbelt/sockets.ccUDPSocket::JoinMulticastGroup / LeaveMulticastGroup

Previously used the Linux-only struct ip_mreqn (with imr_ifindex). On macOS, BSDs and QNX, only the POSIX-portable struct ip_mreq is available, so this code failed to compile there.

Switched to struct ip_mreq. Behaviour is unchanged on Linux: the previous code passed imr_ifindex = 0, which selects the default interface; ip_mreq.imr_interface = INADDR_ANY does the same.

toolbelt/sockets.hsockaddr_vm fallback

The fallback definition of struct sockaddr_vm (used when neither <linux/vm_sockets.h> nor <sys/vsock.h> is available, e.g. on QNX) had a typo defined(_APPLE__) (single leading underscore). This is harmless on Apple, where the system header is used instead, but on a system that actually hits the fallback a true __APPLE__ macro would never have inserted svm_len. Fixed the spelling.

Notes

  • Subspace doesn't currently call JoinMulticastGroup / LeaveMulticastGroup itself, so this is purely a "unblock the build" fix; no runtime behaviour change is observable from subspace.
  • VSOCK at runtime still cannot work on QNX (no AF_VSOCK socket family); the fallback sockaddr_vm definition only exists to keep code that references the type compilable.

Test plan

  • bazel test //... on Linux to confirm ip_mreq behaves identically to the previous ip_mreqn use (multicast join / leave still work).
  • bazel test //... on macOS to confirm the multicast helpers now compile (previously they would have failed to build there too).
  • On a host with a QNX toolchain: qcc build of sockets.cc succeeds.
  • If we have a multicast test, confirm a full round-trip of JoinsendtorecvfromLeave works on Linux.

Made with Cursor

Dave Allison added 2 commits April 27, 2026 18:29
Two small portability fixes so this builds on QNX (and stays building
on macOS / BSDs):

  * UDPSocket::JoinMulticastGroup / LeaveMulticastGroup used the
    Linux-only struct ip_mreqn (with imr_ifindex).  Switch to the
    POSIX-portable struct ip_mreq.  Behaviour is unchanged on Linux:
    the previous code passed imr_ifindex = 0, which is equivalent to
    INADDR_ANY in ip_mreq.imr_interface.

  * The fallback definition of struct sockaddr_vm in sockets.h had a
    typo `_APPLE__` (single leading underscore).  This is harmless on
    Apple, where <sys/vsock.h> is used instead, but on a system that
    actually hits the fallback (e.g. QNX) a true `__APPLE__` macro
    would never have inserted svm_len.  Fix the spelling.

Made-with: Cursor
@dallison dallison marked this pull request as ready for review May 1, 2026 23:47
@dallison dallison merged commit 7616ac7 into main May 1, 2026
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.

1 participant