-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,38 +137,38 @@ pub fn vmsplice(fd: RawFd, iov: &[IoVec<&[u8]>], flags: SpliceFFlags) -> Result< | |
mod consts { | ||
use libc::{self, c_int, c_uint}; | ||
|
||
bitflags! { | ||
libc_bitflags! { | ||
pub flags SpliceFFlags: c_uint { | ||
const SPLICE_F_MOVE = libc::SPLICE_F_MOVE, | ||
const SPLICE_F_NONBLOCK = libc::SPLICE_F_NONBLOCK, | ||
const SPLICE_F_MORE = libc::SPLICE_F_MORE, | ||
const SPLICE_F_GIFT = libc::SPLICE_F_GIFT, | ||
SPLICE_F_MOVE, | ||
SPLICE_F_NONBLOCK, | ||
SPLICE_F_MORE, | ||
SPLICE_F_GIFT, | ||
} | ||
} | ||
|
||
bitflags!( | ||
pub flags OFlag: c_int { | ||
const O_ACCMODE = 0o00000003, | ||
const O_RDONLY = 0o00000000, | ||
const O_WRONLY = 0o00000001, | ||
const O_RDWR = 0o00000002, | ||
const O_CREAT = 0o00000100, | ||
const O_EXCL = 0o00000200, | ||
const O_NOCTTY = 0o00000400, | ||
const O_TRUNC = 0o00001000, | ||
const O_APPEND = 0o00002000, | ||
const O_NONBLOCK = 0o00004000, | ||
const O_DSYNC = 0o00010000, | ||
const O_DIRECT = 0o00040000, | ||
const O_ACCMODE = libc::O_ACCMODE, | ||
const O_RDONLY = libc::O_RDONLY, | ||
const O_WRONLY = libc::O_WRONLY, | ||
const O_RDWR = libc::O_RDWR, | ||
const O_CREAT = libc::O_CREAT, | ||
const O_EXCL = libc::O_EXCL, | ||
const O_NOCTTY = libc::O_NOCTTY, | ||
const O_TRUNC = libc::O_TRUNC, | ||
const O_APPEND = libc::O_APPEND, | ||
const O_NONBLOCK = libc::O_NONBLOCK, | ||
const O_DSYNC = libc::O_DSYNC, | ||
const O_DIRECT = libc::O_DIRECT, | ||
const O_LARGEFILE = 0o00100000, | ||
const O_DIRECTORY = 0o00200000, | ||
const O_NOFOLLOW = 0o00400000, | ||
const O_DIRECTORY = libc::O_DIRECTORY, | ||
const O_NOFOLLOW = libc::O_NOFOLLOW, | ||
const O_NOATIME = 0o01000000, | ||
const O_CLOEXEC = 0o02000000, | ||
const O_SYNC = 0o04000000, | ||
const O_CLOEXEC = libc::O_CLOEXEC, | ||
const O_SYNC = libc::O_SYNC, | ||
const O_PATH = 0o10000000, | ||
const O_TMPFILE = 0o20000000, | ||
const O_NDELAY = O_NONBLOCK.bits | ||
const O_TMPFILE = libc::O_TMPFILE, | ||
const O_NDELAY = libc::O_NDELAY, | ||
} | ||
); | ||
|
||
|
@@ -191,27 +191,27 @@ mod consts { | |
|
||
#[cfg(any(target_os = "macos", target_os = "ios"))] | ||
mod consts { | ||
use libc::c_int; | ||
use libc::{self, c_int}; | ||
|
||
bitflags!( | ||
pub flags OFlag: c_int { | ||
const O_ACCMODE = 0x0000003, | ||
const O_RDONLY = 0x0000000, | ||
const O_WRONLY = 0x0000001, | ||
const O_RDWR = 0x0000002, | ||
const O_CREAT = 0x0000200, | ||
const O_EXCL = 0x0000800, | ||
const O_NOCTTY = 0x0020000, | ||
const O_TRUNC = 0x0000400, | ||
const O_APPEND = 0x0000008, | ||
const O_NONBLOCK = 0x0000004, | ||
const O_DSYNC = 0x0400000, | ||
const O_DIRECTORY = 0x0100000, | ||
const O_NOFOLLOW = 0x0000100, | ||
const O_CLOEXEC = 0x1000000, | ||
const O_SYNC = 0x0000080, | ||
const O_ACCMODE = libc::O_ACCMODE, | ||
const O_RDONLY = libc::O_RDONLY, | ||
const O_WRONLY = libc::O_WRONLY, | ||
const O_RDWR = libc::O_RDWR, | ||
const O_CREAT = libc::O_CREAT, | ||
const O_EXCL = libc::O_EXCL, | ||
const O_NOCTTY = libc::O_NOCTTY, | ||
const O_TRUNC = libc::O_TRUNC, | ||
const O_APPEND = libc::O_APPEND, | ||
const O_NONBLOCK = libc::O_NONBLOCK, | ||
const O_DSYNC = libc::O_DSYNC, | ||
const O_DIRECTORY = libc::O_DIRECTORY, | ||
const O_NOFOLLOW = libc::O_NOFOLLOW, | ||
const O_CLOEXEC = libc::O_CLOEXEC, | ||
const O_SYNC = libc::O_SYNC, | ||
const O_NDELAY = O_NONBLOCK.bits, | ||
const O_FSYNC = O_SYNC.bits | ||
const O_FSYNC = libc::O_FSYNC, | ||
} | ||
); | ||
|
||
|
@@ -224,26 +224,26 @@ mod consts { | |
|
||
#[cfg(any(target_os = "freebsd", target_os = "openbsd"))] | ||
mod consts { | ||
use libc::c_int; | ||
use libc::{self, c_int}; | ||
|
||
bitflags!( | ||
pub flags OFlag: c_int { | ||
const O_ACCMODE = 0x0000003, | ||
const O_RDONLY = 0x0000000, | ||
const O_WRONLY = 0x0000001, | ||
const O_RDWR = 0x0000002, | ||
const O_CREAT = 0x0000200, | ||
const O_EXCL = 0x0000800, | ||
const O_NOCTTY = 0x0008000, | ||
const O_TRUNC = 0x0000400, | ||
const O_APPEND = 0x0000008, | ||
const O_NONBLOCK = 0x0000004, | ||
const O_ACCMODE = libc::O_ACCMODE, | ||
const O_RDONLY = libc::O_RDONLY, | ||
const O_WRONLY = libc::O_WRONLY, | ||
const O_RDWR = libc::O_RDWR, | ||
const O_CREAT = libc::O_CREAT, | ||
const O_EXCL = libc::O_EXCL, | ||
const O_NOCTTY = libc::O_NOCTTY, | ||
const O_TRUNC = libc::O_TRUNC, | ||
const O_APPEND = libc::O_APPEND, | ||
const O_NONBLOCK = libc::O_NONBLOCK, | ||
const O_DIRECTORY = 0x0020000, | ||
const O_NOFOLLOW = 0x0000100, | ||
const O_CLOEXEC = 0x0100000, | ||
const O_SYNC = 0x0000080, | ||
const O_NDELAY = O_NONBLOCK.bits, | ||
const O_FSYNC = O_SYNC.bits, | ||
const O_NOFOLLOW = libc::O_NOFOLLOW, | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. same here re non-libc constants & defining them upstream |
||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,48 +4,45 @@ use {Errno, Result, NixPath}; | |
|
||
bitflags!( | ||
pub flags MsFlags: c_ulong { | ||
const MS_RDONLY = 1 << 0, // Mount read-only | ||
const MS_NOSUID = 1 << 1, // Ignore suid and sgid bits | ||
const MS_NODEV = 1 << 2, // Disallow access to device special files | ||
const MS_NOEXEC = 1 << 3, // Disallow program execution | ||
const MS_SYNCHRONOUS = 1 << 4, // Writes are synced at once | ||
const MS_REMOUNT = 1 << 5, // Alter flags of a mounted FS | ||
const MS_MANDLOCK = 1 << 6, // Allow mandatory locks on a FS | ||
const MS_DIRSYNC = 1 << 7, // Directory modifications are synchronous | ||
const MS_NOATIME = 1 << 10, // Do not update access times | ||
const MS_NODIRATIME = 1 << 11, // Do not update directory access times | ||
const MS_BIND = 1 << 12, // Linux 2.4.0 - Bind directory at different place | ||
const MS_MOVE = 1 << 13, | ||
const MS_REC = 1 << 14, | ||
const MS_VERBOSE = 1 << 15, // Deprecated | ||
const MS_SILENT = 1 << 15, | ||
const MS_POSIXACL = 1 << 16, | ||
const MS_UNBINDABLE = 1 << 17, | ||
const MS_PRIVATE = 1 << 18, | ||
const MS_SLAVE = 1 << 19, | ||
const MS_SHARED = 1 << 20, | ||
const MS_RELATIME = 1 << 21, | ||
const MS_KERNMOUNT = 1 << 22, | ||
const MS_I_VERSION = 1 << 23, | ||
const MS_STRICTATIME = 1 << 24, | ||
const MS_RDONLY = libc::MS_RDONLY, // Mount read-only | ||
const MS_NOSUID = libc::MS_NOSUID, // Ignore suid and sgid bits | ||
const MS_NODEV = libc::MS_NODEV, // Disallow access to device special files | ||
const MS_NOEXEC = libc::MS_NOEXEC, // Disallow program execution | ||
const MS_SYNCHRONOUS = libc::MS_SYNCHRONOUS, // Writes are synced at once | ||
const MS_REMOUNT = libc::MS_REMOUNT, // Alter flags of a mounted FS | ||
const MS_MANDLOCK = libc::MS_MANDLOCK, // Allow mandatory locks on a FS | ||
const MS_DIRSYNC = libc::MS_DIRSYNC, // Directory modifications are synchronous | ||
const MS_NOATIME = libc::MS_NOATIME, // Do not update access times | ||
const MS_NODIRATIME = libc::MS_NODIRATIME, // Do not update directory access times | ||
const MS_BIND = libc::MS_BIND, // Linux 2.4.0 - Bind directory at different place | ||
const MS_MOVE = libc::MS_MOVE, | ||
const MS_REC = libc::MS_REC, | ||
const MS_VERBOSE = 1 << 15, // Deprecated | ||
const MS_SILENT = libc::MS_SILENT, | ||
const MS_POSIXACL = libc::MS_POSIXACL, | ||
const MS_UNBINDABLE = libc::MS_UNBINDABLE, | ||
const MS_PRIVATE = libc::MS_PRIVATE, | ||
const MS_SLAVE = libc::MS_SLAVE, | ||
const MS_SHARED = libc::MS_SHARED, | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. again :-) |
||
const MS_ACTIVE = 1 << 30, | ||
const MS_NOUSER = 1 << 31, | ||
const MS_RMT_MASK = MS_RDONLY.bits | ||
| MS_SYNCHRONOUS.bits | ||
| MS_MANDLOCK.bits | ||
| MS_I_VERSION.bits, | ||
const MS_MGC_VAL = 0xC0ED0000, | ||
const MS_MGC_MSK = 0xffff0000 | ||
const MS_ACTIVE = libc::MS_ACTIVE, | ||
const MS_NOUSER = libc::MS_NOUSER, | ||
const MS_RMT_MASK = libc::MS_RMT_MASK, | ||
const MS_MGC_VAL = libc::MS_MGC_VAL, | ||
const MS_MGC_MSK = libc::MS_MGC_MSK, | ||
} | ||
); | ||
|
||
bitflags!( | ||
libc_bitflags!( | ||
pub flags MntFlags: c_int { | ||
const MNT_FORCE = 1 << 0, | ||
const MNT_DETACH = 1 << 1, | ||
const MNT_EXPIRE = 1 << 2 | ||
MNT_FORCE, | ||
MNT_DETACH, | ||
MNT_EXPIRE, | ||
} | ||
); | ||
|
||
|
This file contains 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
Oops, something went wrong.
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.
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.