Skip to content

Commit 3c77dba

Browse files
committed
pushing for now original interfacing -- will see how to solve CI issues
1 parent 1801b84 commit 3c77dba

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

src/unix/linux_like/android/mod.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub type __u16 = c_ushort;
3434
pub type __s16 = c_short;
3535
pub type __u32 = c_uint;
3636
pub type __s32 = c_int;
37+
pub type __be16 = __u16;
3738

3839
// linux/elf.h
3940

@@ -517,11 +518,6 @@ s! {
517518
pub ifr6_prefixlen: u32,
518519
pub ifr6_ifindex: c_int,
519520
}
520-
521-
// is __be16 __bitwise __u16
522-
pub struct __c_anonymous___be16 {
523-
__priv: [crate::__u8; 2],
524-
}
525521
}
526522

527523
s_no_extra_traits! {
@@ -646,11 +642,11 @@ s_no_extra_traits! {
646642

647643
// linux/if_ether.h
648644

649-
#[repr(C, align(1))]
645+
#[repr(C, packed)]
650646
pub struct ethhdr {
651647
pub h_dest: [c_uchar; crate::ETH_ALEN as usize],
652648
pub h_source: [c_uchar; crate::ETH_ALEN as usize],
653-
pub h_proto: __c_anonymous___be16,
649+
pub h_proto: crate::__be16,
654650
}
655651
}
656652

@@ -1048,6 +1044,7 @@ cfg_if! {
10481044
.iter()
10491045
.zip(other.h_source.iter())
10501046
.all(|(a, b)| a == b)
1047+
&& self.h_proto == other.h_proto
10511048
}
10521049
}
10531050

@@ -1056,6 +1053,7 @@ cfg_if! {
10561053
f.debug_struct("ethhdr")
10571054
.field("h_dest", &self.h_dest)
10581055
.field("h_source", &self.h_source)
1056+
.field("h_proto", &{ self.h_proto })
10591057
.finish()
10601058
}
10611059
}

src/unix/linux_like/linux/mod.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub type __u16 = c_ushort;
2828
pub type __s16 = c_short;
2929
pub type __u32 = c_uint;
3030
pub type __s32 = c_int;
31+
pub type __be16 = __u16;
3132

3233
pub type Elf32_Half = u16;
3334
pub type Elf32_Word = u32;
@@ -1319,11 +1320,6 @@ s! {
13191320
pub propagation: crate::__u64,
13201321
pub userns_fd: crate::__u64,
13211322
}
1322-
1323-
// is __be16 __bitwise __u16
1324-
pub struct __c_anonymous___be16 {
1325-
__priv: [crate::__u8; 2],
1326-
}
13271323
}
13281324

13291325
cfg_if! {
@@ -1792,12 +1788,11 @@ s_no_extra_traits! {
17921788

17931789
// linux/if_ether.h
17941790

1795-
#[cfg(not(target_arch = "loongarch64"))]
1796-
#[repr(C, align(1))]
1791+
#[repr(C, packed)]
17971792
pub struct ethhdr {
17981793
pub h_dest: [c_uchar; crate::ETH_ALEN as usize],
17991794
pub h_source: [c_uchar; crate::ETH_ALEN as usize],
1800-
pub h_proto: __c_anonymous___be16,
1795+
pub h_proto: crate::__be16,
18011796
}
18021797
}
18031798

@@ -2227,10 +2222,8 @@ cfg_if! {
22272222
}
22282223
}
22292224

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

2233-
#[cfg(not(target_arch = "loongarch64"))]
22342227
impl PartialEq for ethhdr {
22352228
fn eq(&self, other: &ethhdr) -> bool {
22362229
self.h_dest
@@ -2242,15 +2235,16 @@ cfg_if! {
22422235
.iter()
22432236
.zip(other.h_source.iter())
22442237
.all(|(a, b)| a == b)
2238+
&& self.h_proto == other.h_proto
22452239
}
22462240
}
22472241

2248-
#[cfg(not(target_arch = "loongarch64"))]
22492242
impl fmt::Debug for ethhdr {
22502243
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22512244
f.debug_struct("ethhdr")
22522245
.field("h_dest", &self.h_dest)
22532246
.field("h_source", &self.h_source)
2247+
.field("h_proto", &{ self.h_proto })
22542248
.finish()
22552249
}
22562250
}

0 commit comments

Comments
 (0)