Skip to content

Conversation

Ayush-Raj-Chourasia
Copy link

This PR adds conditional compilation guards for Linux-specific features in unix.rs, such as IP_RECVTOS and mmsghdr, which are not available on BSD or other non-Linux platforms.

  • Uses #[cfg(target_os = "linux")] to restrict usage of these features to Linux only.
  • Prevents build errors on BSD and other platforms by disabling or providing compile-time errors for unsupported features.
  • Verified by building and running all tests successfully.

This improves cross-platform compatibility and ensures the crate builds cleanly on non-Linux systems.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you describe why these changes are necessary?

Copy link
Member

Choose a reason for hiding this comment

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

More specifically: what platform(s) are you trying to build for?

// mac and ios do not support IP_RECVTOS on dual-stack sockets :(
// older macos versions also don't have the flag and will error out if we don't ignore it
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", solarish)))]
#[cfg(target_os = "linux")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment on lines +509 to +513
#[cfg(all(
not(any(apple, target_os = "openbsd", target_os = "netbsd", solarish)),
not(target_os = "linux")
))]
fn recv(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Which target_os is not excluded above?

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.

3 participants