use super::super::c;
use bitflags::bitflags;
use core::marker::PhantomData;
bitflags! {
pub struct FdFlags: c::c_uint {
const CLOEXEC = linux_raw_sys::general::FD_CLOEXEC;
}
}
bitflags! {
pub struct ReadWriteFlags: c::c_uint {
const DSYNC = linux_raw_sys::general::RWF_DSYNC;
const HIPRI = linux_raw_sys::general::RWF_HIPRI;
const SYNC = linux_raw_sys::general::RWF_SYNC;
const NOWAIT = linux_raw_sys::general::RWF_NOWAIT;
const APPEND = linux_raw_sys::general::RWF_APPEND;
}
}
#[cfg(any(target_os = "android", target_os = "linux"))]
bitflags! {
pub struct SpliceFlags: c::c_uint {
const MOVE = linux_raw_sys::general::SPLICE_F_MOVE;
const NONBLOCK = linux_raw_sys::general::SPLICE_F_NONBLOCK;
const MORE = linux_raw_sys::general::SPLICE_F_MORE;
const GIFT = linux_raw_sys::general::SPLICE_F_GIFT;
}
}
bitflags! {
pub struct DupFlags: c::c_uint {
const CLOEXEC = linux_raw_sys::general::O_CLOEXEC;
}
}
bitflags! {
pub struct PipeFlags: c::c_uint {
const CLOEXEC = linux_raw_sys::general::O_CLOEXEC;
const DIRECT = linux_raw_sys::general::O_DIRECT;
const NONBLOCK = linux_raw_sys::general::O_NONBLOCK;
}
}
bitflags! {
pub struct EventfdFlags: c::c_uint {
const CLOEXEC = linux_raw_sys::general::EFD_CLOEXEC;
const NONBLOCK = linux_raw_sys::general::EFD_NONBLOCK;
const SEMAPHORE = linux_raw_sys::general::EFD_SEMAPHORE;
}
}
pub const PIPE_BUF: usize = linux_raw_sys::general::PIPE_BUF as usize;
pub(crate) const AT_FDCWD: c::c_int = linux_raw_sys::general::AT_FDCWD;
pub(crate) const STDIN_FILENO: c::c_uint = linux_raw_sys::general::STDIN_FILENO;
pub(crate) const STDOUT_FILENO: c::c_uint = linux_raw_sys::general::STDOUT_FILENO;
pub(crate) const STDERR_FILENO: c::c_uint = linux_raw_sys::general::STDERR_FILENO;
#[repr(transparent)]
pub struct IoSliceRaw<'a> {
_buf: c::iovec,
_lifetime: PhantomData<&'a ()>,
}
impl<'a> IoSliceRaw<'a> {
pub fn from_slice(buf: &'a [u8]) -> Self {
IoSliceRaw {
_buf: c::iovec {
iov_base: buf.as_ptr() as *mut u8 as *mut c::c_void,
iov_len: buf.len() as _,
},
_lifetime: PhantomData,
}
}
pub fn from_slice_mut(buf: &'a mut [u8]) -> Self {
IoSliceRaw {
_buf: c::iovec {
iov_base: buf.as_mut_ptr() as *mut c::c_void,
iov_len: buf.len() as _,
},
_lifetime: PhantomData,
}
}
}