Skip to content

Commit

Permalink
Added all definitions from linux/ptp-clock.h
Browse files Browse the repository at this point in the history
  • Loading branch information
davidv1992 authored and folkertdev committed Jan 28, 2024
1 parent b56e4b3 commit 5ac4d4f
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 2 deletions.
27 changes: 25 additions & 2 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3457,6 +3457,8 @@ fn test_linux(target: &str) {
"linux/netlink.h",
// FIXME: requires Linux >= 5.6:
[!musl]: "linux/openat2.h",
"linux/ptp_clock.h",
// FIXME: requires Linux >= 5.6:
[!musl]: "linux/ptrace.h",
"linux/quota.h",
"linux/random.h",
Expand Down Expand Up @@ -3594,6 +3596,9 @@ fn test_linux(target: &str) {
if musl && ty == "seccomp_notif_sizes" {
return true;
}
if musl && 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")) {
Expand Down Expand Up @@ -3757,6 +3762,7 @@ fn test_linux(target: &str) {
if name == "SECCOMP_GET_NOTIF_SIZES"
|| name == "SECCOMP_FILTER_FLAG_NEW_LISTENER"
|| name == "SECCOMP_FILTER_FLAG_TSYNC_ESRCH"
|| name == "PTP_SYS_OFFSET_EXTENDED"
|| name == "SECCOMP_USER_NOTIF_FLAG_CONTINUE" // requires >= 5.5
|| name == "SECCOMP_ADDFD_FLAG_SETFD" // requires >= 5.9
|| name == "SECCOMP_ADDFD_FLAG_SEND" // requires >= 5.9
Expand All @@ -3769,6 +3775,15 @@ fn test_linux(target: &str) {
|| name.starts_with("RTEXT_FILTER_")
|| name.starts_with("SO_J1939")
|| name.starts_with("SCM_J1939")
|| name == "PTP_CLOCK_GETCAPS2"
|| name == "PTP_EXTTS_REQUEST2"
|| name == "PTP_PEROUT_REQUEST2"
|| name == "PTP_ENABLE_PPS2"
|| name == "PTP_SYS_OFFSET2"
|| name == "PTP_PIN_GETFUNC2"
|| name == "PTP_PIN_SETFUNC2"
|| name == "PTP_SYS_OFFSET_PRECISE2"
|| name == "PTP_SYS_OFFSET_EXTENDED2"
{
return true;
}
Expand Down Expand Up @@ -4264,7 +4279,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 Expand Up @@ -4322,7 +4341,11 @@ fn test_linux(target: &str) {
// the `ifc_ifcu` field is an anonymous union
(struct_ == "ifconf" && field == "ifc_ifcu") ||
// glibc uses a single array `uregs` instead of individual fields.
(struct_ == "user_regs" && arm)
(struct_ == "user_regs" && arm) ||
// `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.skip_roundtrip(move |s| match s {
Expand Down
23 changes: 23 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1990,6 +1990,29 @@ PTHREAD_INHERIT_SCHED
PTHREAD_EXPLICIT_SCHED
PTHREAD_STACK_MIN
PTHREAD_ONCE_INIT
PTP_CLOCK_GETCAPS
PTP_CLOCK_GETCAPS2
PTP_ENABLE_PPS
PTP_ENABLE_PPS2
PTP_EXTTS_REQUEST
PTP_EXTTS_REQUEST2
PTP_MAX_SAMPLES
PTP_PEROUT_REQUEST
PTP_PEROUT_REQUEST2
PTP_PF_EXTTS
PTP_PF_NONE
PTP_PF_PEROUT
PTP_PF_PHYSYNC
PTP_PIN_GETFUNC
PTP_PIN_GETFUNC2
PTP_PIN_SETFUNC
PTP_PIN_SETFUNC2
PTP_SYS_OFFSET
PTP_SYS_OFFSET2
PTP_SYS_OFFSET_EXTENDED
PTP_SYS_OFFSET_EXTENDED2
PTP_SYS_OFFSET_PRECISE
PTP_SYS_OFFSET_PRECISE2
PTRACE_ATTACH
PTRACE_CONT
PTRACE_DETACH
Expand Down
147 changes: 147 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,72 @@ s! {
pub val: ::c_int,
}

// linux/ptp_clock.h
pub struct ptp_clock_time {
pub sec: ::__s64,
pub nsec: ::__u32,
pub reserved: ::__u32,
}

pub struct ptp_clock_caps {
pub max_adj: ::c_int,
pub n_alarm: ::c_int,
pub n_ext_ts: ::c_int,
pub n_per_out: ::c_int,
pub pps: ::c_int,
pub n_pins: ::c_int,
pub cross_timestamping: ::c_int,
#[cfg(target_env = "gnu")]
pub adjust_phase: ::c_int,
#[cfg(target_env = "gnu")]
pub max_phase_adj: ::c_int,
#[cfg(target_env = "gnu")]
pub rsv: [::c_int; 11],
#[cfg(any(target_env = "musl", target_env = "ohos"))]
pub rsv: [::c_int; 13],
}

pub struct ptp_extts_request {
pub index: ::c_uint,
pub flags: ::c_uint,
pub rsv: [::c_uint; 2],
}


pub struct ptp_sys_offset {
pub n_samples: ::c_uint,
pub rsv: [::c_uint; 3],
pub ts: [ptp_clock_time; 51],
}

pub struct ptp_sys_offset_extended {
pub n_samples: ::c_uint,
pub rsv: [::c_uint; 3],
pub ts: [[ptp_clock_time; 3]; 25],
}

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_pin_desc {
pub name: [::c_char; 64],
pub index: ::c_uint,
pub func: ::c_uint,
pub chan: ::c_uint,
pub rsv: [::c_uint; 5],
}

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 {
Expand Down Expand Up @@ -889,6 +955,7 @@ s_no_extra_traits! {
pub sched_deadline: ::__u64,
pub sched_period: ::__u64,
}

}

s_no_extra_traits! {
Expand Down Expand Up @@ -920,6 +987,34 @@ cfg_if! {
}
}

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,
}
}
}
}

cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for sockaddr_nl {
Expand Down Expand Up @@ -3638,6 +3733,58 @@ 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;

cfg_if! {
if #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] {
pub const PTP_CLOCK_GETCAPS: ::c_uint = 0x40503d01;
pub const PTP_EXTTS_REQUEST: ::c_uint = 0x80103d02;
pub const PTP_PEROUT_REQUEST: ::c_uint = 0x80383d03;
pub const PTP_ENABLE_PPS: ::c_uint = 0x80043d04;
pub const PTP_SYS_OFFSET: ::c_uint = 0x83403d05;
pub const PTP_PIN_GETFUNC: ::c_uint = 0xc0603d06;
pub const PTP_PIN_SETFUNC: ::c_uint = 0x80603d07;
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = 0xc0403d08;
pub const PTP_SYS_OFFSET_EXTENDED: ::c_uint = 0xc4c03d09;

pub const PTP_CLOCK_GETCAPS2: ::c_uint = 0x40503d0a;
pub const PTP_EXTTS_REQUEST2: ::c_uint = 0x80103d0b;
pub const PTP_PEROUT_REQUEST2: ::c_uint = 0x80383d0c;
pub const PTP_ENABLE_PPS2: ::c_uint = 0x80043d0d;
pub const PTP_SYS_OFFSET2: ::c_uint = 0x83403d0e;
pub const PTP_PIN_GETFUNC2: ::c_uint = 0xc0603d0f;
pub const PTP_PIN_SETFUNC2: ::c_uint = 0x80603d10;
pub const PTP_SYS_OFFSET_PRECISE2: ::c_uint = 0xc0403d11;
pub const PTP_SYS_OFFSET_EXTENDED2: ::c_uint = 0xc4c03d12;
} else {
pub const PTP_CLOCK_GETCAPS: ::c_uint = 0x80503d01;
pub const PTP_EXTTS_REQUEST: ::c_uint = 0x40103d02;
pub const PTP_PEROUT_REQUEST: ::c_uint = 0x40383d03;
pub const PTP_ENABLE_PPS: ::c_uint = 0x40043d04;
pub const PTP_SYS_OFFSET: ::c_uint = 0x43403d05;
pub const PTP_PIN_GETFUNC: ::c_uint = 0xc0603d06;
pub const PTP_PIN_SETFUNC: ::c_uint = 0x40603d07;
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = 0xc0403d08;
pub const PTP_SYS_OFFSET_EXTENDED: ::c_uint = 0xc4c03d09;

pub const PTP_CLOCK_GETCAPS2: ::c_uint = 0x80503d0a;
pub const PTP_EXTTS_REQUEST2: ::c_uint = 0x40103d0b;
pub const PTP_PEROUT_REQUEST2: ::c_uint = 0x40383d0c;
pub const PTP_ENABLE_PPS2: ::c_uint = 0x40043d0d;
pub const PTP_SYS_OFFSET2: ::c_uint = 0x43403d0e;
pub const PTP_PIN_GETFUNC2: ::c_uint = 0xc0603d0f;
pub const PTP_PIN_SETFUNC2: ::c_uint = 0x40603d10;
pub const PTP_SYS_OFFSET_PRECISE2: ::c_uint = 0xc0403d11;
pub const PTP_SYS_OFFSET_EXTENDED2: ::c_uint = 0xc4c03d12;
}
}

pub const PTP_PF_NONE: ::c_uint = 0;
pub const PTP_PF_EXTTS: ::c_uint = 1;
pub const PTP_PF_PEROUT: ::c_uint = 2;
pub const PTP_PF_PHYSYNC: ::c_uint = 3;

// linux/tls.h
pub const TLS_TX: ::c_int = 1;
pub const TLS_RX: ::c_int = 2;
Expand Down

0 comments on commit 5ac4d4f

Please sign in to comment.