-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add all definitions from linux/ptp-clock.h #3559
Conversation
r? @JohnTitor (rustbot has picked a reviewer for you, use r? to override) |
b8f48dc
to
543faf9
Compare
(struct_ == "user_regs" && arm) || | ||
// `anonymous_1` is an anonymous union | ||
(struct_ == "ptp_perout_request" && field == "anonymous_1") || | ||
// `anonymous_2` is an anonymous union | ||
(struct_ == "ptp_perout_request" && field == "anonymous_2") |
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'm not sure why but both this and block and the block above excluding these fields seem required for CI to be satisfied?!
543faf9
to
c57f452
Compare
Could you resolve CI failure? |
b778e8f
to
5ac4d4f
Compare
well that was more work that expected. A bunch of the constants and one struct are defined only in newer kernel versions (this causes problems on the 0.2 branch on musl, which uses an older kernel version)
and then on powerpc a bunch of the constants have different values. |
src/unix/linux_like/linux/mod.rs
Outdated
pub const PTP_CLOCK_GETCAPS: ::c_uint = 0x40503d01; | ||
pub const PTP_EXTTS_REQUEST: ::c_uint = 0x80103d02; | ||
pub const PTP_PEROUT_REQUEST: ::c_uint = 0x80383d03; | ||
pub const PTP_ENABLE_PPS: ::c_uint = 0x80043d04; | ||
pub const PTP_SYS_OFFSET: ::c_uint = 0x83403d05; | ||
pub const PTP_PIN_GETFUNC: ::c_uint = 0xc0603d06; | ||
pub const PTP_PIN_SETFUNC: ::c_uint = 0x80603d07; | ||
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = 0xc0403d08; |
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.
these are defined with some macros. There are rust versions here https://github.com/torvalds/linux/blob/8a696a29c6905594e4abf78eaafcb62165ac61f1/rust/kernel/ioctl.rs#L13
should those be used instead?
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 think duplicating the macros from ioctl.h
would be better here - these numbers are kind of difficult to verify by hand as-is.
d9c8b36
to
b087c94
Compare
@JohnTitor this is actually waiting for review, but I don't think I can update the label? (not sure how this workflow is supposed to work?) |
ah, rustbot got more helpful in newer PRs @rustbot review |
@@ -3457,6 +3457,8 @@ fn test_linux(target: &str) { | |||
"linux/netlink.h", | |||
// FIXME: requires Linux >= 5.6: | |||
[!musl]: "linux/openat2.h", | |||
"linux/ptp_clock.h", | |||
// FIXME: requires Linux >= 5.6: |
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.
What is this referring to? uapi ptp_clock.h
has been around since at least 4.0, not sure if this is intended for ptrace.h
below but that doesn't make sense either.
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.
#3559 (comment) goes into why. it's not that the file doesn't exist before 5.6, but some of the constants are only added in this later version, so for the full functionality, 5.6 is required. I believe the same is true for netlink.h
above, a file that is also very old but its api changed over time, so that is why I copied over that comment too
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 was asking mostly about why the FIXME
is below ptp_clock.h
rather than above, looks like it is referring to ptrace.h
rather than ptp_clock.h
- but I guess this didn't show up well on the review UI. That context is probably helpful though, maybe change the comment to some fields require Linux >= 5.6
src/unix/linux_like/linux/mod.rs
Outdated
#[cfg(target_env = "gnu")] | ||
pub adjust_phase: ::c_int, | ||
#[cfg(target_env = "gnu")] | ||
pub max_phase_adj: ::c_int, | ||
#[cfg(target_env = "gnu")] | ||
pub rsv: [::c_int; 11], | ||
#[cfg(any(target_env = "musl", target_env = "ohos"))] | ||
pub rsv: [::c_int; 13], |
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.
Could you add a note about how this is a kernel version difference that happens to be exposed by glibc / musl supported versions?
Also if you have links to relevant sources or docs, please add them in the PR description. I haven't been able to find anything relevant.
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'm confused by this now. I suspect that I came to the above after some fighting with CI. Here // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/include/uapi/linux/ptp_clock.h#L94
the max_phase_adj
field clearly is defined. But then e.g. on godbolt, for both musl and gnu, that field does not exist. adjust_phase
does though. I'll change it back and see what CI says
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'm confused by this now.
At least that makes two of us :)
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.
Oh, I just realized this is targeting 0.2 rather than main
. I would prefer this target main
first since it uses some newer versions, then for the backport we can work around any kind of legacy weirdness.
Don't close this since it is still useful, but if it isn't too much trouble then it would be good if you could reapply this on top of main
and open a new PR with that.
(If it's a PITA don't worry about it and I'll figure out how to get things in sync after)
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.
worked out fine #3865
src/unix/linux_like/linux/mod.rs
Outdated
impl PartialEq for ptp_sys_offset { | ||
fn eq(&self, other: &ptp_sys_offset) -> bool { | ||
self.n_samples == other.n_samples && | ||
self.rsv == other.rsv && | ||
self.ts[..] == other.ts[..] | ||
} | ||
} | ||
impl Eq for ptp_sys_offset {} | ||
impl ::fmt::Debug for ptp_sys_offset { | ||
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { | ||
f.debug_struct("ptp_sys_offset") | ||
.field("n_samples", &self.n_samples) | ||
.field("rsv", &self.rsv) | ||
.field("ts", &&self.ts[..]) | ||
.finish() | ||
} | ||
} | ||
impl ::hash::Hash for ptp_sys_offset { | ||
fn hash<H: ::hash::Hasher>(&self, state: &mut H) { | ||
self.n_samples.hash(state); | ||
self.rsv.hash(state); | ||
self.ts[..].hash(state); | ||
} | ||
} |
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.
Why not just move this struct from s_no_extra_traits!
to s!
so it gets these derived? Same for ptp_pin_desc
src/unix/linux_like/linux/mod.rs
Outdated
pub const PTP_CLOCK_GETCAPS: ::c_uint = 0x40503d01; | ||
pub const PTP_EXTTS_REQUEST: ::c_uint = 0x80103d02; | ||
pub const PTP_PEROUT_REQUEST: ::c_uint = 0x80383d03; | ||
pub const PTP_ENABLE_PPS: ::c_uint = 0x80043d04; | ||
pub const PTP_SYS_OFFSET: ::c_uint = 0x83403d05; | ||
pub const PTP_PIN_GETFUNC: ::c_uint = 0xc0603d06; | ||
pub const PTP_PIN_SETFUNC: ::c_uint = 0x80603d07; | ||
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = 0xc0403d08; |
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 think duplicating the macros from ioctl.h
would be better here - these numbers are kind of difficult to verify by hand as-is.
Left a review above, mostly nits with some follow up questions. @rustbot author |
f74db2b
to
2773e96
Compare
Co-authored-by: Trevor Gross <t.gross35@gmail.com>
adopted from RFL
2773e96
to
e23acab
Compare
Considering there are some CI failures here and #3865 exists now, let's figure this out on |
I've taken over this change from @davidv1992 (who is my colleague). #3353 is the original PR which can now be closed.
I'm also assuming this can/should be merged into the libc-0.2 branch (and main will be rebased on top of that at some point?).