Skip to content

Commit 4db6c79

Browse files
fix: skiping ifconf and adding debug trait to ifconf
1 parent ca3ed0c commit 4db6c79

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4039,6 +4039,8 @@ fn test_linux(target: &str) {
40394039
(struct_ == "sockaddr_vm" && field == "svm_zero") ||
40404040
// the `ifr_ifru` field is an anonymous union
40414041
(struct_ == "ifreq" && field == "ifr_ifru") ||
4042+
// the `ifc_ifcu` field is an anonymous union
4043+
(struct_ == "ifconf" && field == "ifc_ifcu") ||
40424044
// glibc uses a single array `uregs` instead of individual fields.
40434045
(struct_ == "user_regs" && arm)
40444046
});

src/unix/linux_like/linux/mod.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -792,17 +792,21 @@ s_no_extra_traits! {
792792
pub ifr_ifru: ::sockaddr,
793793
}
794794

795+
#[cfg(libc_union)]
795796
pub union __c_anonymous_ifc_ifcu {
796-
ifcu_buf: *mut ::c_char,
797-
ifcu_req: *mut ::ifreq,
797+
pub ifcu_buf: *mut ::c_char,
798+
pub ifcu_req: *mut ::ifreq,
798799
}
799800

800801
/* Structure used in SIOCGIFCONF request. Used to retrieve interface
801-
configuration for machine (useful for programs which must know all
802-
networks accessible). */
802+
configuration for machine (useful for programs which must know all
803+
networks accessible). */
803804
pub struct ifconf {
804805
pub ifc_len: ::c_int, /* Size of buffer. */
806+
#[cfg(libc_union)]
805807
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
808+
#[cfg(not(libc_union))]
809+
pub ifc_ifcu: *mut ::ifreq,
806810
}
807811

808812
pub struct hwtstamp_config {
@@ -1241,7 +1245,23 @@ cfg_if! {
12411245
.finish()
12421246
}
12431247
}
1244-
1248+
#[cfg(libc_union)]
1249+
impl ::fmt::Debug for __c_anonymous_ifc_ifcu {
1250+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1251+
f.debug_struct("ifr_ifru")
1252+
.field("ifcu_buf", unsafe { &self.ifcu_buf })
1253+
.field("ifcu_req", unsafe { &self.ifcu_req })
1254+
.finish()
1255+
}
1256+
}
1257+
impl ::fmt::Debug for ifconf {
1258+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1259+
f.debug_struct("ifconf")
1260+
.field("ifc_len", &self.ifc_len)
1261+
.field("ifc_ifcu", &self.ifc_ifcu)
1262+
.finish()
1263+
}
1264+
}
12451265
impl ::fmt::Debug for hwtstamp_config {
12461266
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
12471267
f.debug_struct("hwtstamp_config")

0 commit comments

Comments
 (0)