Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small portability fixes that let
cpp_toolbeltcompile 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.cc—UDPSocket::JoinMulticastGroup/LeaveMulticastGroupPreviously used the Linux-only
struct ip_mreqn(withimr_ifindex). On macOS, BSDs and QNX, only the POSIX-portablestruct ip_mreqis available, so this code failed to compile there.Switched to
struct ip_mreq. Behaviour is unchanged on Linux: the previous code passedimr_ifindex = 0, which selects the default interface;ip_mreq.imr_interface = INADDR_ANYdoes the same.toolbelt/sockets.h—sockaddr_vmfallbackThe 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 typodefined(_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 insertedsvm_len. Fixed the spelling.Notes
JoinMulticastGroup/LeaveMulticastGroupitself, so this is purely a "unblock the build" fix; no runtime behaviour change is observable from subspace.AF_VSOCKsocket family); the fallbacksockaddr_vmdefinition only exists to keep code that references the type compilable.Test plan
bazel test //...on Linux to confirmip_mreqbehaves identically to the previousip_mreqnuse (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).qccbuild ofsockets.ccsucceeds.Join→sendto→recvfrom→Leaveworks on Linux.Made with Cursor