-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add CMSG macros for unix/bsd and unix/notbsd #1098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Any feedback? |
Thanks for the PR and sorry for the delay! These look good to me though, thanks! @bors: r+ |
📌 Commit 2701f62 has been approved by |
Add CMSG macros for unix/bsd and unix/notbsd This adds the ["Ancillary Data Object Macros" from RFC 2292](https://tools.ietf.org/html/rfc2292#section-4.3). My C's weak but I think I've translated them faithfully. Tested on macOS and Linux/glibc.
if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() { | ||
(*mhdr).msg_control as *mut cmsghdr | ||
} else { | ||
0 as *mut cmsghdr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: use ptr::null()
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed the crate's convention was to not use that (it's not used anywhere that I've seen)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duh, indeed, libc might predate https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#zero_ptr we can always do a cargo fix for these later
💥 Test timed out |
@bors: r+ |
@gnzlbg: 🔑 Insufficient privileges: Not in reviewers |
r? me |
@bors: retry |
Add CMSG macros for unix/bsd and unix/notbsd This adds the ["Ancillary Data Object Macros" from RFC 2292](https://tools.ietf.org/html/rfc2292#section-4.3). My C's weak but I think I've translated them faithfully. Tested on macOS and Linux/glibc.
☀️ Test successful - status-appveyor, status-travis |
@alexcrichton thanks! |
PR rust-lang#1098 added the CMSG_DATA(3) family of functions into libc. Because they're defined as macros in C, they had to be rewritten as Rust functions for libc. Also, they can't be tested in CI for the same reason. But that PR erroneously used the same definitions in BSD as in Linux. This commit corrects the definitions for OSX, FreeBSD, DragonflyBSD, OpenBSD, and NetBSD. I renamed a few variables and collapsed a few macros in order to combine the definitions where possible. Fixes rust-lang#1210
PR rust-lang#1098 added the CMSG_DATA(3) family of functions into libc. Because they're defined as macros in C, they had to be rewritten as Rust functions for libc. Also, they can't be tested in CI for the same reason. But that PR erroneously used the same definitions in BSD as in Linux. This commit corrects the definitions for OSX, FreeBSD, DragonflyBSD, OpenBSD, and NetBSD. I renamed a few variables and collapsed a few macros in order to combine the definitions where possible. Fixes rust-lang#1210
Fix CMSG_DATA(3) and friends on BSD PR #1098 added the CMSG_DATA(3) family of functions into libc. Because they're defined as macros in C, they had to be rewritten as Rust functions for libc. Also, they can't be tested in CI for the same reason. But that PR erroneously used the same definitions in BSD as in Linux. This commit corrects the definitions for OSX, FreeBSD, DragonflyBSD, OpenBSD, and NetBSD. I renamed a few variables and collapsed a few macros in order to combine the definitions where possible. Fixes #1210
This is an error from PR rust-lang#1098. The wrong definition coincidentally works on Linux/glibc, but it fails on Linux/musl.
This is an error from PR rust-lang#1098. The wrong definitions coincidentally work on Linux/glibc, but fail on Linux/musl. fixup
This is an error from PR rust-lang#1098. The wrong definitions coincidentally work on Linux/glibc, but fail on Linux/musl.
This is an error from PR rust-lang#1098. The wrong definitions coincidentally work on Linux/glibc, but fail on Linux/musl.
This is an error from PR rust-lang#1098. The wrong definitions coincidentally work on Linux/glibc, but fail on Linux/musl.
This is an error from PR rust-lang#1098. The wrong definitions coincidentally work on Linux/glibc, but fail on Linux/musl.
This adds the "Ancillary Data Object Macros" from RFC 2292. My C's weak but I think I've translated them faithfully. Tested on macOS and Linux/glibc.