Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ifconf addition to apple. fixing freebsd's implementation while at it. #3388

Merged
merged 1 commit into from Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions libc-test/build.rs
Expand Up @@ -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,
}
});
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/apple.txt
Expand Up @@ -1957,6 +1957,7 @@ if_freenameindex
if_msghdr
if_nameindex
ifaddrs
ifconf
ifkpi
ifreq
image_offset
Expand Down
46 changes: 46 additions & 0 deletions src/unix/bsd/apple/mod.rs
Expand Up @@ -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! {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<H: ::hash::Hasher>(&self, state: &mut H) {
unsafe { self.ifcu_buf.hash(state) };
unsafe { self.ifcu_req.hash(state) };
}
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Expand Up @@ -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 {
Expand Down