summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid CARLIER <devnexen@gmail.com>2022-01-25 14:22:48 +0000
committerDavid CARLIER <devnexen@gmail.com>2022-01-25 14:42:45 +0000
commit619119e0e21c0964028a236dd7c23f3fecc4e044 (patch)
tree612aee6566fe606b100402671e183ec74bffb6c0
parent7f1da49dd4207d5a0bb28a5838fa21ff7befc4f7 (diff)
downloadrust-libc-619119e0e21c0964028a236dd7c23f3fecc4e044.tar.gz
freebsd add ifconf data.
-rw-r--r--libc-test/build.rs1
-rw-r--r--libc-test/semver/freebsd.txt2
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/mod.rs44
3 files changed, 47 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 19c5ddce70..4fd9e8b7f3 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -2316,6 +2316,7 @@ fn test_freebsd(target: &str) {
("if_data", "__ifi_epoch") => true,
("if_data", "__ifi_lastchange") => true,
("ifreq", "ifr_ifru") => true,
+ ("ifconf", "ifc_ifcu") => true,
// anonymous struct
("devstat", "dev_links") => true,
diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt
index 8aff0a5d6c..4772415cda 100644
--- a/libc-test/semver/freebsd.txt
+++ b/libc-test/semver/freebsd.txt
@@ -1536,6 +1536,8 @@ idtype_t
if_freenameindex
if_nameindex
ifaddrs
+ifconf
+ifreq
in6_pktinfo
initgroups
ip_mreqn
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index eeea87bd0b..251f236c58 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -960,6 +960,13 @@ s! {
pub sc_ngroups: ::c_int,
pub sc_groups: [::gid_t; 1],
}
+
+ pub struct ifconf {
+ pub ifc_len: ::c_int,
+ #[cfg(libc_union)]
+ pub ifc_ifcu: __c_anonymous_ifc_ifcu,
+ }
+
}
s_no_extra_traits! {
@@ -1142,6 +1149,12 @@ s_no_extra_traits! {
pub ifr_ifru: ::sockaddr,
}
+ #[cfg(libc_union)]
+ pub union __c_anonymous_ifc_ifcu {
+ pub ifcu_buf: ::caddr_t,
+ pub ifcu_req: *mut ifreq,
+ }
+
pub struct ifstat {
/// if name, e.g. "en0"
pub ifs_name: [::c_char; ::IFNAMSIZ as usize],
@@ -1549,6 +1562,37 @@ cfg_if! {
}
}
+ #[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) };
+ }
+ }
+
impl PartialEq for ifstat {
fn eq(&self, other: &ifstat) -> bool {
let self_ascii: &[::c_char] = &self.ascii;