Skip to content

Commit

Permalink
Fix the style for bitflags!
Browse files Browse the repository at this point in the history
Prefer libc_bitflags! over bitflags!. Prefer libc::CONSTANTS over
writing the constant manually.
  • Loading branch information
Mathias Svensson committed Feb 17, 2017
1 parent 54e6197 commit 2a3d367
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 238 deletions.
112 changes: 56 additions & 56 deletions src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
);

Expand All @@ -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,
}
);

Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// warnings even though the macro expands into something with allow(dead_code)
#![allow(dead_code)]
#![cfg_attr(test, deny(warnings))]
#![recursion_limit = "500"]

#[macro_use]
extern crate bitflags;
Expand Down
69 changes: 33 additions & 36 deletions src/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
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,
}
);

Expand Down
28 changes: 14 additions & 14 deletions src/sys/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ use ::Error;
bitflags!(
#[repr(C)]
pub flags EpollFlags: u32 {
const EPOLLIN = 0x001,
const EPOLLPRI = 0x002,
const EPOLLOUT = 0x004,
const EPOLLRDNORM = 0x040,
const EPOLLRDBAND = 0x080,
const EPOLLWRNORM = 0x100,
const EPOLLWRBAND = 0x200,
const EPOLLMSG = 0x400,
const EPOLLERR = 0x008,
const EPOLLHUP = 0x010,
const EPOLLRDHUP = 0x2000,
const EPOLLIN = libc::EPOLLIN as u32,
const EPOLLPRI = libc::EPOLLPRI as u32,
const EPOLLOUT = libc::EPOLLOUT as u32,
const EPOLLRDNORM = libc::EPOLLRDNORM as u32,
const EPOLLRDBAND = libc::EPOLLRDBAND as u32,
const EPOLLWRNORM = libc::EPOLLWRNORM as u32,
const EPOLLWRBAND = libc::EPOLLWRBAND as u32,
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,
const EPOLLWAKEUP = 1 << 29,
const EPOLLONESHOT = 1 << 30,
const EPOLLET = 1 << 31
const EPOLLWAKEUP = libc::EPOLLWAKEUP as u32,
const EPOLLONESHOT = libc::EPOLLONESHOT as u32,
const EPOLLET = libc::EPOLLET as u32,
}
);

Expand Down
Loading

0 comments on commit 2a3d367

Please sign in to comment.