Skip to content

Commit 5ac4d4f

Browse files
davidv1992folkertdev
authored andcommitted
Added all definitions from linux/ptp-clock.h
1 parent b56e4b3 commit 5ac4d4f

File tree

3 files changed

+195
-2
lines changed

3 files changed

+195
-2
lines changed

libc-test/build.rs

+25-2
Original file line numberDiff line numberDiff line change
@@ -3457,6 +3457,8 @@ fn test_linux(target: &str) {
34573457
"linux/netlink.h",
34583458
// FIXME: requires Linux >= 5.6:
34593459
[!musl]: "linux/openat2.h",
3460+
"linux/ptp_clock.h",
3461+
// FIXME: requires Linux >= 5.6:
34603462
[!musl]: "linux/ptrace.h",
34613463
"linux/quota.h",
34623464
"linux/random.h",
@@ -3594,6 +3596,9 @@ fn test_linux(target: &str) {
35943596
if musl && ty == "seccomp_notif_sizes" {
35953597
return true;
35963598
}
3599+
if musl && ty == "ptp_sys_offset_extended" {
3600+
return true;
3601+
}
35973602

35983603
// LFS64 types have been removed in musl 1.2.4+
35993604
if musl && (ty.ends_with("64") || ty.ends_with("64_t")) {
@@ -3757,6 +3762,7 @@ fn test_linux(target: &str) {
37573762
if name == "SECCOMP_GET_NOTIF_SIZES"
37583763
|| name == "SECCOMP_FILTER_FLAG_NEW_LISTENER"
37593764
|| name == "SECCOMP_FILTER_FLAG_TSYNC_ESRCH"
3765+
|| name == "PTP_SYS_OFFSET_EXTENDED"
37603766
|| name == "SECCOMP_USER_NOTIF_FLAG_CONTINUE" // requires >= 5.5
37613767
|| name == "SECCOMP_ADDFD_FLAG_SETFD" // requires >= 5.9
37623768
|| name == "SECCOMP_ADDFD_FLAG_SEND" // requires >= 5.9
@@ -3769,6 +3775,15 @@ fn test_linux(target: &str) {
37693775
|| name.starts_with("RTEXT_FILTER_")
37703776
|| name.starts_with("SO_J1939")
37713777
|| name.starts_with("SCM_J1939")
3778+
|| name == "PTP_CLOCK_GETCAPS2"
3779+
|| name == "PTP_EXTTS_REQUEST2"
3780+
|| name == "PTP_PEROUT_REQUEST2"
3781+
|| name == "PTP_ENABLE_PPS2"
3782+
|| name == "PTP_SYS_OFFSET2"
3783+
|| name == "PTP_PIN_GETFUNC2"
3784+
|| name == "PTP_PIN_SETFUNC2"
3785+
|| name == "PTP_SYS_OFFSET_PRECISE2"
3786+
|| name == "PTP_SYS_OFFSET_EXTENDED2"
37723787
{
37733788
return true;
37743789
}
@@ -4264,7 +4279,11 @@ fn test_linux(target: &str) {
42644279
// `__exit_status` type is a patch which is absent in musl
42654280
(struct_ == "utmpx" && field == "ut_exit" && musl) ||
42664281
// `can_addr` is an anonymous union
4267-
(struct_ == "sockaddr_can" && field == "can_addr")
4282+
(struct_ == "sockaddr_can" && field == "can_addr") ||
4283+
// `anonymous_1` is an anonymous union
4284+
(struct_ == "ptp_perout_request" && field == "anonymous_1") ||
4285+
// `anonymous_2` is an anonymous union
4286+
(struct_ == "ptp_perout_request" && field == "anonymous_2")
42684287
});
42694288

42704289
cfg.volatile_item(|i| {
@@ -4322,7 +4341,11 @@ fn test_linux(target: &str) {
43224341
// the `ifc_ifcu` field is an anonymous union
43234342
(struct_ == "ifconf" && field == "ifc_ifcu") ||
43244343
// glibc uses a single array `uregs` instead of individual fields.
4325-
(struct_ == "user_regs" && arm)
4344+
(struct_ == "user_regs" && arm) ||
4345+
// `anonymous_1` is an anonymous union
4346+
(struct_ == "ptp_perout_request" && field == "anonymous_1") ||
4347+
// `anonymous_2` is an anonymous union
4348+
(struct_ == "ptp_perout_request" && field == "anonymous_2")
43264349
});
43274350

43284351
cfg.skip_roundtrip(move |s| match s {

libc-test/semver/linux.txt

+23
Original file line numberDiff line numberDiff line change
@@ -1990,6 +1990,29 @@ PTHREAD_INHERIT_SCHED
19901990
PTHREAD_EXPLICIT_SCHED
19911991
PTHREAD_STACK_MIN
19921992
PTHREAD_ONCE_INIT
1993+
PTP_CLOCK_GETCAPS
1994+
PTP_CLOCK_GETCAPS2
1995+
PTP_ENABLE_PPS
1996+
PTP_ENABLE_PPS2
1997+
PTP_EXTTS_REQUEST
1998+
PTP_EXTTS_REQUEST2
1999+
PTP_MAX_SAMPLES
2000+
PTP_PEROUT_REQUEST
2001+
PTP_PEROUT_REQUEST2
2002+
PTP_PF_EXTTS
2003+
PTP_PF_NONE
2004+
PTP_PF_PEROUT
2005+
PTP_PF_PHYSYNC
2006+
PTP_PIN_GETFUNC
2007+
PTP_PIN_GETFUNC2
2008+
PTP_PIN_SETFUNC
2009+
PTP_PIN_SETFUNC2
2010+
PTP_SYS_OFFSET
2011+
PTP_SYS_OFFSET2
2012+
PTP_SYS_OFFSET_EXTENDED
2013+
PTP_SYS_OFFSET_EXTENDED2
2014+
PTP_SYS_OFFSET_PRECISE
2015+
PTP_SYS_OFFSET_PRECISE2
19932016
PTRACE_ATTACH
19942017
PTRACE_CONT
19952018
PTRACE_DETACH

src/unix/linux_like/linux/mod.rs

+147
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,72 @@ s! {
650650
pub val: ::c_int,
651651
}
652652

653+
// linux/ptp_clock.h
654+
pub struct ptp_clock_time {
655+
pub sec: ::__s64,
656+
pub nsec: ::__u32,
657+
pub reserved: ::__u32,
658+
}
659+
660+
pub struct ptp_clock_caps {
661+
pub max_adj: ::c_int,
662+
pub n_alarm: ::c_int,
663+
pub n_ext_ts: ::c_int,
664+
pub n_per_out: ::c_int,
665+
pub pps: ::c_int,
666+
pub n_pins: ::c_int,
667+
pub cross_timestamping: ::c_int,
668+
#[cfg(target_env = "gnu")]
669+
pub adjust_phase: ::c_int,
670+
#[cfg(target_env = "gnu")]
671+
pub max_phase_adj: ::c_int,
672+
#[cfg(target_env = "gnu")]
673+
pub rsv: [::c_int; 11],
674+
#[cfg(any(target_env = "musl", target_env = "ohos"))]
675+
pub rsv: [::c_int; 13],
676+
}
677+
678+
pub struct ptp_extts_request {
679+
pub index: ::c_uint,
680+
pub flags: ::c_uint,
681+
pub rsv: [::c_uint; 2],
682+
}
683+
684+
685+
pub struct ptp_sys_offset {
686+
pub n_samples: ::c_uint,
687+
pub rsv: [::c_uint; 3],
688+
pub ts: [ptp_clock_time; 51],
689+
}
690+
691+
pub struct ptp_sys_offset_extended {
692+
pub n_samples: ::c_uint,
693+
pub rsv: [::c_uint; 3],
694+
pub ts: [[ptp_clock_time; 3]; 25],
695+
}
696+
697+
pub struct ptp_sys_offset_precise {
698+
pub device: ptp_clock_time,
699+
pub sys_realtime: ptp_clock_time,
700+
pub sys_monoraw: ptp_clock_time,
701+
pub rsv: [::c_uint; 4],
702+
}
703+
704+
pub struct ptp_pin_desc {
705+
pub name: [::c_char; 64],
706+
pub index: ::c_uint,
707+
pub func: ::c_uint,
708+
pub chan: ::c_uint,
709+
pub rsv: [::c_uint; 5],
710+
}
711+
712+
pub struct ptp_extts_event {
713+
pub t: ptp_clock_time,
714+
index: ::c_uint,
715+
flags: ::c_uint,
716+
rsv: [::c_uint; 2],
717+
}
718+
653719
// linux/sctp.h
654720

655721
pub struct sctp_initmsg {
@@ -889,6 +955,7 @@ s_no_extra_traits! {
889955
pub sched_deadline: ::__u64,
890956
pub sched_period: ::__u64,
891957
}
958+
892959
}
893960

894961
s_no_extra_traits! {
@@ -920,6 +987,34 @@ cfg_if! {
920987
}
921988
}
922989

990+
cfg_if! {
991+
if #[cfg(libc_union)] {
992+
s_no_extra_traits! {
993+
// linux/ptp_clock.h
994+
#[allow(missing_debug_implementations)]
995+
pub union __c_anonymous_ptp_perout_request_1 {
996+
pub start: ptp_clock_time,
997+
pub phase: ptp_clock_time,
998+
}
999+
1000+
#[allow(missing_debug_implementations)]
1001+
pub union __c_anonymous_ptp_perout_request_2 {
1002+
pub on: ptp_clock_time,
1003+
pub rsv: [::c_uint; 4],
1004+
}
1005+
1006+
#[allow(missing_debug_implementations)]
1007+
pub struct ptp_perout_request {
1008+
pub anonymous_1: __c_anonymous_ptp_perout_request_1,
1009+
pub period: ptp_clock_time,
1010+
pub index: ::c_uint,
1011+
pub flags: ::c_uint,
1012+
pub anonymous_2: __c_anonymous_ptp_perout_request_2,
1013+
}
1014+
}
1015+
}
1016+
}
1017+
9231018
cfg_if! {
9241019
if #[cfg(feature = "extra_traits")] {
9251020
impl PartialEq for sockaddr_nl {
@@ -3638,6 +3733,58 @@ pub const HWTSTAMP_FILTER_PTP_V2_SYNC: ::c_uint = 13;
36383733
pub const HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: ::c_uint = 14;
36393734
pub const HWTSTAMP_FILTER_NTP_ALL: ::c_uint = 15;
36403735

3736+
// linux/ptp_clock.h
3737+
pub const PTP_MAX_SAMPLES: ::c_uint = 25;
3738+
3739+
cfg_if! {
3740+
if #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] {
3741+
pub const PTP_CLOCK_GETCAPS: ::c_uint = 0x40503d01;
3742+
pub const PTP_EXTTS_REQUEST: ::c_uint = 0x80103d02;
3743+
pub const PTP_PEROUT_REQUEST: ::c_uint = 0x80383d03;
3744+
pub const PTP_ENABLE_PPS: ::c_uint = 0x80043d04;
3745+
pub const PTP_SYS_OFFSET: ::c_uint = 0x83403d05;
3746+
pub const PTP_PIN_GETFUNC: ::c_uint = 0xc0603d06;
3747+
pub const PTP_PIN_SETFUNC: ::c_uint = 0x80603d07;
3748+
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = 0xc0403d08;
3749+
pub const PTP_SYS_OFFSET_EXTENDED: ::c_uint = 0xc4c03d09;
3750+
3751+
pub const PTP_CLOCK_GETCAPS2: ::c_uint = 0x40503d0a;
3752+
pub const PTP_EXTTS_REQUEST2: ::c_uint = 0x80103d0b;
3753+
pub const PTP_PEROUT_REQUEST2: ::c_uint = 0x80383d0c;
3754+
pub const PTP_ENABLE_PPS2: ::c_uint = 0x80043d0d;
3755+
pub const PTP_SYS_OFFSET2: ::c_uint = 0x83403d0e;
3756+
pub const PTP_PIN_GETFUNC2: ::c_uint = 0xc0603d0f;
3757+
pub const PTP_PIN_SETFUNC2: ::c_uint = 0x80603d10;
3758+
pub const PTP_SYS_OFFSET_PRECISE2: ::c_uint = 0xc0403d11;
3759+
pub const PTP_SYS_OFFSET_EXTENDED2: ::c_uint = 0xc4c03d12;
3760+
} else {
3761+
pub const PTP_CLOCK_GETCAPS: ::c_uint = 0x80503d01;
3762+
pub const PTP_EXTTS_REQUEST: ::c_uint = 0x40103d02;
3763+
pub const PTP_PEROUT_REQUEST: ::c_uint = 0x40383d03;
3764+
pub const PTP_ENABLE_PPS: ::c_uint = 0x40043d04;
3765+
pub const PTP_SYS_OFFSET: ::c_uint = 0x43403d05;
3766+
pub const PTP_PIN_GETFUNC: ::c_uint = 0xc0603d06;
3767+
pub const PTP_PIN_SETFUNC: ::c_uint = 0x40603d07;
3768+
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = 0xc0403d08;
3769+
pub const PTP_SYS_OFFSET_EXTENDED: ::c_uint = 0xc4c03d09;
3770+
3771+
pub const PTP_CLOCK_GETCAPS2: ::c_uint = 0x80503d0a;
3772+
pub const PTP_EXTTS_REQUEST2: ::c_uint = 0x40103d0b;
3773+
pub const PTP_PEROUT_REQUEST2: ::c_uint = 0x40383d0c;
3774+
pub const PTP_ENABLE_PPS2: ::c_uint = 0x40043d0d;
3775+
pub const PTP_SYS_OFFSET2: ::c_uint = 0x43403d0e;
3776+
pub const PTP_PIN_GETFUNC2: ::c_uint = 0xc0603d0f;
3777+
pub const PTP_PIN_SETFUNC2: ::c_uint = 0x40603d10;
3778+
pub const PTP_SYS_OFFSET_PRECISE2: ::c_uint = 0xc0403d11;
3779+
pub const PTP_SYS_OFFSET_EXTENDED2: ::c_uint = 0xc4c03d12;
3780+
}
3781+
}
3782+
3783+
pub const PTP_PF_NONE: ::c_uint = 0;
3784+
pub const PTP_PF_EXTTS: ::c_uint = 1;
3785+
pub const PTP_PF_PEROUT: ::c_uint = 2;
3786+
pub const PTP_PF_PHYSYNC: ::c_uint = 3;
3787+
36413788
// linux/tls.h
36423789
pub const TLS_TX: ::c_int = 1;
36433790
pub const TLS_RX: ::c_int = 2;

0 commit comments

Comments
 (0)