diff --git a/libc-test/build.rs b/libc-test/build.rs index c8b1297d691ad..87848b1a21ba1 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3617,6 +3617,8 @@ fn test_linux(target: &str) { "linux/netlink.h", // FIXME: requires Linux >= 5.6: [!musl]: "linux/openat2.h", + // FIXME: some items require Linux >= 5.6: + "linux/ptp_clock.h", [!musl]: "linux/ptrace.h", "linux/quota.h", "linux/random.h", @@ -3766,6 +3768,11 @@ fn test_linux(target: &str) { return true; } + // FIXME: CI has old headers + if ty == "ptp_sys_offset_extended" { + return true; + } + // LFS64 types have been removed in musl 1.2.4+ if musl && (ty.ends_with("64") || ty.ends_with("64_t")) { return true; @@ -4490,7 +4497,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| { @@ -4561,6 +4572,10 @@ fn test_linux(target: &str) { (struct_ == "fanotify_event_info_fid" && field == "fsid") || // `handle` is a VLA (struct_ == "fanotify_event_info_fid" && field == "handle") || + // `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") || // invalid application of 'sizeof' to incomplete type 'long unsigned int[]' (musl && struct_ == "mcontext_t" && field == "__extcontext" && loongarch64) || // FIXME(#4121): a new field was added from `f_spare` diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 5557664a1ab03..50f6537cdf930 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2252,6 +2252,7 @@ PTHREAD_PRIO_PROTECT PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_SHARED PTHREAD_STACK_MIN +PTP_MAX_SAMPLES PTRACE_ATTACH PTRACE_CONT PTRACE_DETACH @@ -3558,11 +3559,15 @@ __WNOTHREAD __c_anonymous_ifc_ifcu __c_anonymous_ifr_ifru __c_anonymous_ifru_map +__c_anonymous_ptp_perout_request_1 +__c_anonymous_ptp_perout_request_2 __c_anonymous_sockaddr_can_can_addr __c_anonymous_sockaddr_can_j1939 __c_anonymous_sockaddr_can_tp __errno_location __exit_status +__kernel_clockid_t +__kernel_fsid_t __s16 __s32 __u16 @@ -3916,6 +3921,14 @@ pthread_spin_lock pthread_spin_trylock pthread_spin_unlock pthread_spinlock_t +ptp_clock_time +ptp_extts_event +ptp_extts_request +ptp_perout_request +ptp_pin_desc +ptp_sys_offset +ptp_sys_offset_extended +ptp_sys_offset_precise ptrace ptsname_r pwrite64 diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index d14d4dd8766f1..46c925b818b51 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -19,6 +19,7 @@ pub type pthread_key_t = ::c_uint; pub type pthread_once_t = ::c_int; pub type pthread_spinlock_t = ::c_int; pub type __kernel_fsid_t = __c_anonymous__kernel_fsid_t; +pub type __kernel_clockid_t = ::c_int; pub type __u8 = ::c_uchar; pub type __u16 = ::c_ushort; @@ -829,6 +830,40 @@ s! { pub resolve: ::__u64, } + // linux/ptp_clock.h + pub struct ptp_clock_time { + pub sec: ::__s64, + pub nsec: ::__u32, + pub reserved: ::__u32, + } + + pub struct ptp_extts_request { + pub index: ::c_uint, + pub flags: ::c_uint, + pub rsv: [::c_uint; 2], + } + + pub struct ptp_sys_offset_extended { + pub n_samples: ::c_uint, + pub clockid: __kernel_clockid_t, + pub rsv: [::c_uint; 2], + pub ts: [[ptp_clock_time; 3]; PTP_MAX_SAMPLES as usize], + } + + pub struct ptp_sys_offset_precise { + pub device: ptp_clock_time, + pub sys_realtime: ptp_clock_time, + pub sys_monoraw: ptp_clock_time, + pub rsv: [::c_uint; 4], + } + + pub struct ptp_extts_event { + pub t: ptp_clock_time, + index: ::c_uint, + flags: ::c_uint, + rsv: [::c_uint; 2], + } + // linux/sctp.h pub struct sctp_initmsg { @@ -1142,6 +1177,23 @@ s! { pub fd: ::c_int, pub pid: ::c_int, } + + // linux/ptp_clock.h + + pub struct ptp_sys_offset { + pub n_samples: ::c_uint, + pub rsv: [::c_uint; 3], + // FIXME(garando): replace length with `2 * PTP_MAX_SAMPLES + 1` when supported + pub ts: [ptp_clock_time; 51], + } + + pub struct ptp_pin_desc { + pub name: [::c_char; 64], + pub index: ::c_uint, + pub func: ::c_uint, + pub chan: ::c_uint, + pub rsv: [::c_uint; 5], + } } cfg_if! { @@ -1580,6 +1632,28 @@ s_no_extra_traits! { pub ifr_ifrn: __c_anonymous_iwreq, pub u: iwreq_data, } + + // 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, + } } cfg_if! { @@ -4504,6 +4578,9 @@ pub const HWTSTAMP_FILTER_PTP_V2_SYNC: ::c_uint = 13; pub const HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: ::c_uint = 14; pub const HWTSTAMP_FILTER_NTP_ALL: ::c_uint = 15; +// linux/ptp_clock.h +pub const PTP_MAX_SAMPLES: ::c_uint = 25; // Maximum allowed offset measurement samples. + // linux/tls.h pub const TLS_TX: ::c_int = 1; pub const TLS_RX: ::c_int = 2;