Skip to content

Commit ce51d6e

Browse files
committed
hurd: Fix l_type and l_whence types
on hurd x86, they are set to int types: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mach/hurd/i386/bits/types/struct_flock.h
1 parent 3832726 commit ce51d6e

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

src/process/types.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,25 @@ pub struct Flock {
3030
#[cfg(not(target_os = "horizon"))]
3131
impl Flock {
3232
pub(crate) const unsafe fn from_raw_unchecked(raw_fl: c::flock) -> Self {
33-
Self {
34-
start: raw_fl.l_start as _,
35-
length: raw_fl.l_len as _,
36-
pid: Pid::from_raw(raw_fl.l_pid),
37-
typ: transmute::<i16, FlockType>(raw_fl.l_type),
38-
offset_type: transmute::<i16, FlockOffsetType>(raw_fl.l_whence),
33+
#[cfg(not(all(target_os = "hurd", target_arch = "x86")))]
34+
{
35+
Self {
36+
start: raw_fl.l_start as _,
37+
length: raw_fl.l_len as _,
38+
pid: Pid::from_raw(raw_fl.l_pid),
39+
typ: transmute::<i16, FlockType>(raw_fl.l_type),
40+
offset_type: transmute::<i16, FlockOffsetType>(raw_fl.l_whence),
41+
}
42+
}
43+
#[cfg(all(target_os = "hurd", target_arch = "x86"))]
44+
{
45+
Self {
46+
start: raw_fl.l_start as _,
47+
length: raw_fl.l_len as _,
48+
pid: Pid::from_raw(raw_fl.l_pid),
49+
typ: transmute::<i32, FlockType>(raw_fl.l_type),
50+
offset_type: transmute::<i32, FlockOffsetType>(raw_fl.l_whence),
51+
}
3952
}
4053
}
4154

@@ -68,7 +81,8 @@ impl From<FlockType> for Flock {
6881
/// [`fcntl_getlk`]: crate::process::fcntl_getlk()
6982
#[cfg(not(target_os = "horizon"))]
7083
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
71-
#[repr(i16)]
84+
#[cfg_attr(not(all(target_os = "hurd", target_arch = "x86")), repr(i16))]
85+
#[cfg_attr(all(target_os = "hurd", target_arch = "x86"), repr(i32))]
7286
pub enum FlockType {
7387
/// `F_RDLCK`
7488
ReadLock = c::F_RDLCK as _,
@@ -83,7 +97,8 @@ pub enum FlockType {
8397
/// [`fcntl_getlk`]: crate::process::fcntl_getlk()
8498
#[cfg(not(target_os = "horizon"))]
8599
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
86-
#[repr(i16)]
100+
#[cfg_attr(not(all(target_os = "hurd", target_arch = "x86")), repr(i16))]
101+
#[cfg_attr(all(target_os = "hurd", target_arch = "x86"), repr(i32))]
87102
pub enum FlockOffsetType {
88103
/// `F_SEEK_SET`
89104
Set = c::SEEK_SET as _,

0 commit comments

Comments
 (0)