Skip to content

Commit

Permalink
pushing for now original interfacing -- will see how to solve CI issues
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Jan 12, 2025
1 parent 4f428e0 commit a8ed135
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
12 changes: 5 additions & 7 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub type __u16 = c_ushort;
pub type __s16 = c_short;
pub type __u32 = c_uint;
pub type __s32 = c_int;
pub type __be16 = __u16;

// linux/elf.h

Expand Down Expand Up @@ -517,11 +518,6 @@ s! {
pub ifr6_prefixlen: u32,
pub ifr6_ifindex: c_int,
}

// is __be16 __bitwise __u16
pub struct __c_anonymous___be16 {
__priv: [crate::__u8; 2],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -646,11 +642,11 @@ s_no_extra_traits! {

// linux/if_ether.h

#[repr(C, align(1))]
#[repr(packed)]
pub struct ethhdr {
pub h_dest: [c_uchar; crate::ETH_ALEN as usize],
pub h_source: [c_uchar; crate::ETH_ALEN as usize],
pub h_proto: __c_anonymous___be16,
pub h_proto: crate::__be16,
}
}

Expand Down Expand Up @@ -1048,6 +1044,7 @@ cfg_if! {
.iter()
.zip(other.h_source.iter())
.all(|(a, b)| a == b)
&& self.h_proto == other.h_proto
}
}

Expand All @@ -1056,6 +1053,7 @@ cfg_if! {
f.debug_struct("ethhdr")
.field("h_dest", &self.h_dest)
.field("h_source", &self.h_source)
.field("h_proto", &{ self.h_proto })
.finish()
}
}
Expand Down
16 changes: 5 additions & 11 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub type __u16 = c_ushort;
pub type __s16 = c_short;
pub type __u32 = c_uint;
pub type __s32 = c_int;
pub type __be16 = __u16;

pub type Elf32_Half = u16;
pub type Elf32_Word = u32;
Expand Down Expand Up @@ -1319,11 +1320,6 @@ s! {
pub propagation: crate::__u64,
pub userns_fd: crate::__u64,
}

// is __be16 __bitwise __u16
pub struct __c_anonymous___be16 {
__priv: [crate::__u8; 2],
}
}

cfg_if! {
Expand Down Expand Up @@ -1792,12 +1788,11 @@ s_no_extra_traits! {

// linux/if_ether.h

#[cfg(not(target_arch = "loongarch64"))]
#[repr(C, align(1))]
#[repr(packed)]
pub struct ethhdr {
pub h_dest: [c_uchar; crate::ETH_ALEN as usize],
pub h_source: [c_uchar; crate::ETH_ALEN as usize],
pub h_proto: __c_anonymous___be16,
pub h_proto: crate::__be16,
}
}

Expand Down Expand Up @@ -2227,10 +2222,8 @@ cfg_if! {
}
}

#[cfg(not(target_arch = "loongarch64"))]
impl Eq for ethhdr {}

#[cfg(not(target_arch = "loongarch64"))]
impl PartialEq for ethhdr {
fn eq(&self, other: &ethhdr) -> bool {
self.h_dest
Expand All @@ -2242,15 +2235,16 @@ cfg_if! {
.iter()
.zip(other.h_source.iter())
.all(|(a, b)| a == b)
&& self.h_proto == other.h_proto
}
}

#[cfg(not(target_arch = "loongarch64"))]
impl fmt::Debug for ethhdr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("ethhdr")
.field("h_dest", &self.h_dest)
.field("h_source", &self.h_source)
.field("h_proto", &{ self.h_proto })
.finish()
}
}
Expand Down

0 comments on commit a8ed135

Please sign in to comment.