-
Notifications
You must be signed in to change notification settings - Fork 673
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
Fix the style for bitflags! #503
Conversation
This compiles for me on as many targets as master, though I have not run any tests locally. Can I assume that Travis does a sufficient job for testing? It does not compile on the following targets (and neither does master):
I will try to do follow-up PRs to fix that. |
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.
Great work. Is there a reason why some of the bitflags!
instances were not converted to libc_bitflags!
?
Yes, I used I also might have missed a few of the definitions, but I think I got most of them. |
This is great!
How are you deciding what the correct types are? |
@kamalmarhubi: This PR did not change any of the types. I meant "correct types" as being the same ones as currently used in nix. For instance |
☔ The latest upstream changes (presumably #515) made this pull request unmergeable. Please resolve the merge conflicts. |
8d9d072
to
4bb6640
Compare
Rebased on top of current master. |
0387331
to
3433d9b
Compare
☔ The latest upstream changes (presumably #508) made this pull request unmergeable. Please resolve the merge conflicts. |
Prefer libc_bitflags! over bitflags!. Prefer libc::CONSTANTS over writing the constant manually.
3433d9b
to
7435cb6
Compare
Rebased again. Is there any chance that you could get this merged soon, so I won't have to keep rebasing it? This is not only a style fix, but actually fixes at least one constant ( |
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.
Only one change required: changing the representation type of EpollFlags
.
The rest are just thoughts on more stuff we can do in the same vein after changing libc.
const O_CLOEXEC = 0o02000000, | ||
const O_SYNC = 0o04000000, | ||
const O_CLOEXEC = libc::O_CLOEXEC, | ||
const O_SYNC = libc::O_SYNC, | ||
const O_PATH = 0o10000000, |
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.
not blocking this PR, but if these are missing in libc would you be up for adding them there? Then we could have a followup PR here to use only libc-defined constants.
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 agree that it would be a good idea to get more constants upstream and to fix their types. I've already filed rust-lang/libc#503 and rust-lang/libc#504 which is progress towards this goal.
That being said, my main interest in this was to fix the value of O_TMPFILE
in a non-hacky way. I might do more at a later stage, but I have less motivation to do so now that my use-case has been fixed.
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 and rust-lang/libc#506 as well.
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.
Yeah no pressure to do it, and certainly not on this PR. I'll probably do a few myself over the coming days.
const O_CLOEXEC = libc::O_CLOEXEC, | ||
const O_SYNC = libc::O_SYNC, | ||
const O_NDELAY = libc::O_NDELAY, | ||
const O_FSYNC = libc::O_FSYNC, | ||
const O_SHLOCK = 0x0000080, | ||
const O_EXLOCK = 0x0000020, | ||
const O_DIRECT = 0x0010000, |
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.
same here re non-libc constants & defining them upstream
const MS_RELATIME = libc::MS_RELATIME, | ||
const MS_KERNMOUNT = libc::MS_KERNMOUNT, | ||
const MS_I_VERSION = libc::MS_I_VERSION, | ||
const MS_STRICTATIME = libc::MS_STRICTATIME, | ||
const MS_NOSEC = 1 << 28, | ||
const MS_BORN = 1 << 29, |
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.
again :-)
src/sys/epoll.rs
Outdated
const EPOLLMSG = libc::EPOLLMSG as u32, | ||
const EPOLLERR = libc::EPOLLERR as u32, | ||
const EPOLLHUP = libc::EPOLLHUP as u32, | ||
const EPOLLRDHUP = libc::EPOLLRDHUP as u32, | ||
const EPOLLEXCLUSIVE = 1 << 28, |
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.
once more!
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.
forgot to actually include the comment on the requested change!
src/sys/epoll.rs
Outdated
@@ -8,21 +8,21 @@ use ::Error; | |||
bitflags!( | |||
#[repr(C)] | |||
pub flags EpollFlags: u32 { |
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.
let's change this to libc::c_int
.
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.
Done.
This is basically done modulo changing the type of |
Argh. I am failing at GitHub today... |
📌 Commit 716f216 has been approved by |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit 716f216 has been approved by |
💡 This pull request was already approved, no need to approve it again.
|
I'm guessing it probably will. |
716f216
to
4447d78
Compare
4447d78
to
51b5eac
Compare
Yep, it did not build locally. I've pushed a fixed commit now. |
Can I tell homu to retry, or do you need privileges for that? @homu retry |
@homu retry |
@homu r+ |
📌 Commit 51b5eac has been approved by |
Fix the style for bitflags! Prefer `libc_bitflags!` over `bitflags!`. Prefer `libc::CONSTANTS` over writing the constant manually. This makes #501 unnecessary, since upstream now contains the `O_TMPFILE` constant.
I guess I can't either. I think retry only applies to the same commit. Anyway, thanks again! |
💥 Test timed out |
@homu retry |
Fix the style for bitflags! Prefer `libc_bitflags!` over `bitflags!`. Prefer `libc::CONSTANTS` over writing the constant manually. This makes #501 unnecessary, since upstream now contains the `O_TMPFILE` constant.
☀️ Test successful - status |
Prefer
libc_bitflags!
overbitflags!
. Preferlibc::CONSTANTS
overwriting the constant manually.
This makes #501 unnecessary, since upstream now contains the
O_TMPFILE
constant.