Skip to content

Commit

Permalink
Merge #625
Browse files Browse the repository at this point in the history
625: Use libc_bitflags! for BSD in fcntl.rs r=Susurrus
  • Loading branch information
bors[bot] committed Jul 5, 2017
2 parents 3912a20 + 551c86f commit e96de61
Showing 1 changed file with 45 additions and 172 deletions.
217 changes: 45 additions & 172 deletions src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ mod consts {
}
);

bitflags!(
pub struct FdFlag: c_int {
const FD_CLOEXEC = 1;
libc_bitflags!(
pub flags FdFlag: c_int {
FD_CLOEXEC
}
);

Expand All @@ -255,182 +255,55 @@ mod consts {

}

#[cfg(any(target_os = "macos", target_os = "ios"))]
mod consts {
use libc::{self, c_int};

bitflags!(
pub struct OFlag: c_int {
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 = libc::O_FSYNC;
}
);

bitflags!(
pub struct FdFlag: c_int {
const FD_CLOEXEC = 1;
}
);
}

#[cfg(target_os = "freebsd")]
#[cfg(any(target_os = "netbsd", target_os = "dragonfly", target_os = "openbsd",
target_os = "freebsd", target_os = "macos", target_os = "ios"))]
mod consts {
use libc::{self, c_int};
use libc::{self,c_int};

bitflags!(
pub struct OFlag: c_int {
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 = 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;
const O_EXEC = 0x0040000;
const O_TTY_INIT = 0x0080000;
}
);

bitflags!(
pub struct FdFlag: c_int {
const FD_CLOEXEC = 1;
}
);
}

#[cfg(target_os = "openbsd")]
mod consts {
use libc::{self, c_int};

bitflags!(
libc_bitflags!(
pub flags OFlag: c_int {
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 = 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,
O_ACCMODE,
O_RDONLY,
O_WRONLY,
O_RDWR,
O_NONBLOCK,
O_APPEND,
O_SHLOCK,
O_EXLOCK,
O_ASYNC,
O_SYNC,
O_NOFOLLOW,
O_CREAT,
O_TRUNC,
O_EXCL,
O_NOCTTY,
O_DIRECTORY,
O_CLOEXEC,
O_FSYNC,
O_NDELAY,
#[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "macos",
target_os = "ios"))]
O_DSYNC,
#[cfg(any(target_os = "netbsd", target_os = "dragonfly", target_os = "freebsd"))]
O_DIRECT,
#[cfg(any(target_os = "netbsd", target_os = "openbsd"))]
O_RSYNC,
#[cfg(target_os = "freebsd")]
O_EXEC,
#[cfg(target_os = "freebsd")]
O_TTY_INIT,
#[cfg(target_os = "netbsd")]
O_ALT_IO,
#[cfg(target_os = "netbsd")]
O_NOSIGPIPE,
#[cfg(target_os = "netbsd")]
O_SEARCH,
}
);

bitflags!(
libc_bitflags!(
pub flags FdFlag: c_int {
const FD_CLOEXEC = 1
}
);
}

#[cfg(target_os = "netbsd")]
mod consts {
use libc::c_int;

bitflags!(
pub struct OFlag: c_int {
const O_ACCMODE = 0x0000003;
const O_RDONLY = 0x0000000;
const O_WRONLY = 0x0000001;
const O_RDWR = 0x0000002;
const O_NONBLOCK = 0x0000004;
const O_APPEND = 0x0000008;
const O_SHLOCK = 0x0000010;
const O_EXLOCK = 0x0000020;
const O_ASYNC = 0x0000040;
const O_SYNC = 0x0000080;
const O_NOFOLLOW = 0x0000100;
const O_CREAT = 0x0000200;
const O_TRUNC = 0x0000400;
const O_EXCL = 0x0000800;
const O_NOCTTY = 0x0008000;
const O_DSYNC = 0x0010000;
const O_RSYNC = 0x0020000;
const O_ALT_IO = 0x0040000;
const O_DIRECT = 0x0080000;
const O_NOSIGPIPE = 0x0100000;
const O_DIRECTORY = 0x0200000;
const O_CLOEXEC = 0x0400000;
const O_SEARCH = 0x0800000;
const O_FSYNC = O_SYNC.bits;
const O_NDELAY = O_NONBLOCK.bits;
}
);

bitflags!(
pub struct FdFlag: c_int {
const FD_CLOEXEC = 1;
}
);
}

#[cfg(target_os = "dragonfly")]
mod consts {
use libc::c_int;

bitflags!(
pub struct 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_DIRECTORY = 0x8000000; // different from FreeBSD!
const O_NOFOLLOW = 0x0000100;
const O_CLOEXEC = 0x0020000; // different from FreeBSD!
const O_SYNC = 0x0000080;
const O_NDELAY = O_NONBLOCK.bits;
const O_FSYNC = O_SYNC.bits;
const O_SHLOCK = 0x0000010; // different from FreeBSD!
const O_EXLOCK = 0x0000020;
const O_DIRECT = 0x0010000;
}
);

bitflags!(
pub struct FdFlag: c_int {
const FD_CLOEXEC = 1;
FD_CLOEXEC
}
);
}

0 comments on commit e96de61

Please sign in to comment.