Skip to content

Commit 9a3842f

Browse files
committed
Auto merge of #3388 - devnexen:ifconf_bsd_upd, r=JohnTitor
ifconf addition to apple. fixing freebsd's implementation while at it.
2 parents 1bb3be5 + 79d1b56 commit 9a3842f

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

libc-test/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ fn test_apple(target: &str) {
374374
("vnode_info_path", "vip_path") => true,
375375
("ifreq", "ifr_ifru") => true,
376376
("ifkpi", "ifk_data") => true,
377+
("ifconf", "ifc_ifcu") => true,
377378
_ => false,
378379
}
379380
});

libc-test/semver/apple.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,7 @@ if_freenameindex
19571957
if_msghdr
19581958
if_nameindex
19591959
ifaddrs
1960+
ifconf
19601961
ifkpi
19611962
ifreq
19621963
image_offset

src/unix/bsd/apple/mod.rs

+46
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,15 @@ s! {
11291129
pub validattr: attribute_set_t,
11301130
pub nativeattr: attribute_set_t,
11311131
}
1132+
1133+
#[cfg_attr(libc_packedN, repr(packed(4)))]
1134+
pub struct ifconf {
1135+
pub ifc_len: ::c_int,
1136+
#[cfg(libc_union)]
1137+
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
1138+
#[cfg(not(libc_union))]
1139+
pub ifc_ifcu: *mut ifreq,
1140+
}
11321141
}
11331142

11341143
s_no_extra_traits! {
@@ -1467,6 +1476,12 @@ s_no_extra_traits! {
14671476
#[cfg(not(libc_union))]
14681477
pub ifr_ifru: ::sockaddr,
14691478
}
1479+
1480+
#[cfg(libc_union)]
1481+
pub union __c_anonymous_ifc_ifcu {
1482+
pub ifcu_buf: *mut ::c_char,
1483+
pub ifcu_req: *mut ifreq,
1484+
}
14701485
}
14711486

14721487
impl siginfo_t {
@@ -3000,6 +3015,37 @@ cfg_if! {
30003015
self.ifr_ifru.hash(state);
30013016
}
30023017
}
3018+
3019+
#[cfg(libc_union)]
3020+
impl Eq for __c_anonymous_ifc_ifcu {}
3021+
3022+
#[cfg(libc_union)]
3023+
impl PartialEq for __c_anonymous_ifc_ifcu {
3024+
fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool {
3025+
unsafe {
3026+
self.ifcu_buf == other.ifcu_buf &&
3027+
self.ifcu_req == other.ifcu_req
3028+
}
3029+
}
3030+
}
3031+
3032+
#[cfg(libc_union)]
3033+
impl ::fmt::Debug for __c_anonymous_ifc_ifcu {
3034+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
3035+
f.debug_struct("ifc_ifcu")
3036+
.field("ifcu_buf", unsafe { &self.ifcu_buf })
3037+
.field("ifcu_req", unsafe { &self.ifcu_req })
3038+
.finish()
3039+
}
3040+
}
3041+
3042+
#[cfg(libc_union)]
3043+
impl ::hash::Hash for __c_anonymous_ifc_ifcu {
3044+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
3045+
unsafe { self.ifcu_buf.hash(state) };
3046+
unsafe { self.ifcu_req.hash(state) };
3047+
}
3048+
}
30033049
}
30043050
}
30053051

src/unix/bsd/freebsdlike/freebsd/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,8 @@ s! {
967967
pub ifc_len: ::c_int,
968968
#[cfg(libc_union)]
969969
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
970+
#[cfg(not(libc_union))]
971+
pub ifc_ifcu: *mut ifreq,
970972
}
971973

972974
pub struct au_mask_t {

0 commit comments

Comments
 (0)