Skip to content

Commit

Permalink
try to make cfg work for ptp_perout_request
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Jan 25, 2024
1 parent c927a1b commit b8f48dc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
6 changes: 5 additions & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4266,7 +4266,11 @@ fn test_linux(target: &str) {
// `__exit_status` type is a patch which is absent in musl
(struct_ == "utmpx" && field == "ut_exit" && musl) ||
// `can_addr` is an anonymous union
(struct_ == "sockaddr_can" && field == "can_addr")
(struct_ == "sockaddr_can" && field == "can_addr") ||
// `anonymous_1` is an anonymous union
(struct_ == "ptp_perout_request" && field == "anonymous_1") ||
// `anonymous_2` is an anonymous union
(struct_ == "ptp_perout_request" && field == "anonymous_2")
});

cfg.volatile_item(|i| {
Expand Down
48 changes: 29 additions & 19 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,13 +676,6 @@ s! {
pub rsv: [::c_uint; 2],
}

pub struct ptp_perout_request {
pub anonymous_1: __c_anonymous_ptp_perout_request_1,
pub period: ptp_clock_time,
pub index: ::c_uint,
pub flags: ::c_uint,
pub anonymous_2: __c_anonymous_ptp_perout_request_2,
}

pub struct ptp_sys_offset {
pub n_samples: ::c_uint,
Expand Down Expand Up @@ -958,18 +951,6 @@ s_no_extra_traits! {
pub sched_period: ::__u64,
}

// linux/ptp_clock.h
#[cfg(libc_union)]
pub union __c_anonymous_ptp_perout_request_1 {
pub start: ptp_clock_time,
pub phase: ptp_clock_time,
}

#[cfg(libc_union)]
pub union __c_anonymous_ptp_perout_request_2 {
pub on: ptp_clock_time,
pub rsv: [::c_uint; 4],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -997,6 +978,35 @@ cfg_if! {
pub can_ifindex: ::c_int,
pub can_addr: __c_anonymous_sockaddr_can_can_addr,
}

}
}
}

cfg_if! {
if #[cfg(libc_union)] {
s_no_extra_traits! {
// linux/ptp_clock.h
#[allow(missing_debug_implementations)]
pub union __c_anonymous_ptp_perout_request_1 {
pub start: ptp_clock_time,
pub phase: ptp_clock_time,
}

#[allow(missing_debug_implementations)]
pub union __c_anonymous_ptp_perout_request_2 {
pub on: ptp_clock_time,
pub rsv: [::c_uint; 4],
}

#[allow(missing_debug_implementations)]
pub struct ptp_perout_request {
pub anonymous_1: __c_anonymous_ptp_perout_request_1,
pub period: ptp_clock_time,
pub index: ::c_uint,
pub flags: ::c_uint,
pub anonymous_2: __c_anonymous_ptp_perout_request_2,
}
}
}
}
Expand Down

0 comments on commit b8f48dc

Please sign in to comment.