Skip to content

Commit b9c6d8a

Browse files
committed
Move Apple struct ifconf to s_no_extra_traits!
Since this is packed [1] and we don't have `Copy`, we won't need the extra traits. Remove them here, which also helps lower the MSRV. Additionally, remove some implementations on a union and packed structs that could be unaligned. [1]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/net/if.h.auto.html
1 parent 5431bdb commit b9c6d8a

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

src/unix/bsd/apple/mod.rs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,12 +1089,6 @@ s! {
10891089
pub nativeattr: attribute_set_t,
10901090
}
10911091

1092-
#[repr(packed(4))]
1093-
pub struct ifconf {
1094-
pub ifc_len: ::c_int,
1095-
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
1096-
}
1097-
10981092
#[repr(align(8))]
10991093
pub struct tcp_connection_info {
11001094
pub tcpi_state: u8,
@@ -1211,6 +1205,12 @@ s! {
12111205
}
12121206

12131207
s_no_extra_traits! {
1208+
#[repr(packed(4))]
1209+
pub struct ifconf {
1210+
pub ifc_len: ::c_int,
1211+
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
1212+
}
1213+
12141214
#[repr(packed(4))]
12151215
pub struct kevent {
12161216
pub ident: ::uintptr_t,
@@ -3086,30 +3086,15 @@ cfg_if! {
30863086
}
30873087
}
30883088

3089-
impl Eq for __c_anonymous_ifc_ifcu {}
3090-
3091-
impl PartialEq for __c_anonymous_ifc_ifcu {
3092-
fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool {
3093-
unsafe {
3094-
self.ifcu_buf == other.ifcu_buf &&
3095-
self.ifcu_req == other.ifcu_req
3096-
}
3089+
impl ::fmt::Debug for ifconf{
3090+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
3091+
f.debug_struct("ifconf").finish_non_exhaustive()
30973092
}
30983093
}
30993094

31003095
impl ::fmt::Debug for __c_anonymous_ifc_ifcu {
31013096
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
3102-
f.debug_struct("ifc_ifcu")
3103-
.field("ifcu_buf", unsafe { &self.ifcu_buf })
3104-
.field("ifcu_req", unsafe { &self.ifcu_req })
3105-
.finish()
3106-
}
3107-
}
3108-
3109-
impl ::hash::Hash for __c_anonymous_ifc_ifcu {
3110-
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
3111-
unsafe { self.ifcu_buf.hash(state) };
3112-
unsafe { self.ifcu_req.hash(state) };
3097+
f.debug_struct("ifc_ifcu").finish_non_exhaustive()
31133098
}
31143099
}
31153100

0 commit comments

Comments
 (0)