Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions src/process/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,25 @@ pub struct Flock {
#[cfg(not(target_os = "horizon"))]
impl Flock {
pub(crate) const unsafe fn from_raw_unchecked(raw_fl: c::flock) -> Self {
Self {
start: raw_fl.l_start as _,
length: raw_fl.l_len as _,
pid: Pid::from_raw(raw_fl.l_pid),
typ: transmute::<i16, FlockType>(raw_fl.l_type),
offset_type: transmute::<i16, FlockOffsetType>(raw_fl.l_whence),
#[cfg(not(all(target_os = "hurd", target_arch = "x86")))]
{
Self {
start: raw_fl.l_start as _,
length: raw_fl.l_len as _,
pid: Pid::from_raw(raw_fl.l_pid),
typ: transmute::<i16, FlockType>(raw_fl.l_type),
offset_type: transmute::<i16, FlockOffsetType>(raw_fl.l_whence),
}
}
#[cfg(all(target_os = "hurd", target_arch = "x86"))]
{
Self {
start: raw_fl.l_start as _,
length: raw_fl.l_len as _,
pid: Pid::from_raw(raw_fl.l_pid),
typ: transmute::<i32, FlockType>(raw_fl.l_type),
offset_type: transmute::<i32, FlockOffsetType>(raw_fl.l_whence),
}
}
}

Expand Down Expand Up @@ -68,7 +81,8 @@ impl From<FlockType> for Flock {
/// [`fcntl_getlk`]: crate::process::fcntl_getlk()
#[cfg(not(target_os = "horizon"))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(i16)]
#[cfg_attr(not(all(target_os = "hurd", target_arch = "x86")), repr(i16))]
#[cfg_attr(all(target_os = "hurd", target_arch = "x86"), repr(i32))]
pub enum FlockType {
/// `F_RDLCK`
ReadLock = c::F_RDLCK as _,
Expand All @@ -83,7 +97,8 @@ pub enum FlockType {
/// [`fcntl_getlk`]: crate::process::fcntl_getlk()
#[cfg(not(target_os = "horizon"))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(i16)]
#[cfg_attr(not(all(target_os = "hurd", target_arch = "x86")), repr(i16))]
#[cfg_attr(all(target_os = "hurd", target_arch = "x86"), repr(i32))]
pub enum FlockOffsetType {
/// `F_SEEK_SET`
Set = c::SEEK_SET as _,
Expand Down
Loading