diff --git a/libc-test/build.rs b/libc-test/build.rs index 2f7c469d7cf6a..b1760c4ae4d0b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -374,6 +374,7 @@ fn test_apple(target: &str) { ("vnode_info_path", "vip_path") => true, ("ifreq", "ifr_ifru") => true, ("ifkpi", "ifk_data") => true, + ("ifconf", "ifc_ifcu") => true, _ => false, } }); diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 98dcc4d4cdf1e..fcf4eb4b6743e 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1957,6 +1957,7 @@ if_freenameindex if_msghdr if_nameindex ifaddrs +ifconf ifkpi ifreq image_offset diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 10885dfa877e8..ef9cf2f1f034c 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -1129,6 +1129,15 @@ s! { pub validattr: attribute_set_t, pub nativeattr: attribute_set_t, } + + #[cfg_attr(libc_packedN, repr(packed(4)))] + pub struct ifconf { + pub ifc_len: ::c_int, + #[cfg(libc_union)] + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + #[cfg(not(libc_union))] + pub ifc_ifcu: *mut ifreq, + } } s_no_extra_traits! { @@ -1467,6 +1476,12 @@ s_no_extra_traits! { #[cfg(not(libc_union))] pub ifr_ifru: ::sockaddr, } + + #[cfg(libc_union)] + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut ::c_char, + pub ifcu_req: *mut ifreq, + } } impl siginfo_t { @@ -3000,6 +3015,37 @@ cfg_if! { self.ifr_ifru.hash(state); } } + + #[cfg(libc_union)] + impl Eq for __c_anonymous_ifc_ifcu {} + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ifc_ifcu { + fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { + unsafe { + self.ifcu_buf == other.ifcu_buf && + self.ifcu_req == other.ifcu_req + } + } + } + + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifc_ifcu { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifc_ifcu") + .field("ifcu_buf", unsafe { &self.ifcu_buf }) + .field("ifcu_req", unsafe { &self.ifcu_req }) + .finish() + } + } + + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ifc_ifcu { + fn hash(&self, state: &mut H) { + unsafe { self.ifcu_buf.hash(state) }; + unsafe { self.ifcu_req.hash(state) }; + } + } } } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 0f19a09ff4609..5fba1447d7baf 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -967,6 +967,8 @@ s! { pub ifc_len: ::c_int, #[cfg(libc_union)] pub ifc_ifcu: __c_anonymous_ifc_ifcu, + #[cfg(not(libc_union))] + pub ifc_ifcu: *mut ifreq, } pub struct au_mask_t {