Skip to content

Commit b087c94

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

File tree

3 files changed

+250
-2
lines changed

3 files changed

+250
-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

+202
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,57 @@ 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+
pub struct ptp_sys_offset_extended {
685+
pub n_samples: ::c_uint,
686+
pub rsv: [::c_uint; 3],
687+
pub ts: [[ptp_clock_time; 3]; 25],
688+
}
689+
690+
pub struct ptp_sys_offset_precise {
691+
pub device: ptp_clock_time,
692+
pub sys_realtime: ptp_clock_time,
693+
pub sys_monoraw: ptp_clock_time,
694+
pub rsv: [::c_uint; 4],
695+
}
696+
697+
pub struct ptp_extts_event {
698+
pub t: ptp_clock_time,
699+
index: ::c_uint,
700+
flags: ::c_uint,
701+
rsv: [::c_uint; 2],
702+
}
703+
653704
// linux/sctp.h
654705

655706
pub struct sctp_initmsg {
@@ -889,6 +940,21 @@ s_no_extra_traits! {
889940
pub sched_deadline: ::__u64,
890941
pub sched_period: ::__u64,
891942
}
943+
944+
// linux/ptp_clock.h
945+
pub struct ptp_sys_offset {
946+
pub n_samples: ::c_uint,
947+
pub rsv: [::c_uint; 3],
948+
pub ts: [ptp_clock_time; 51],
949+
}
950+
951+
pub struct ptp_pin_desc {
952+
pub name: [::c_char; 64],
953+
pub index: ::c_uint,
954+
pub func: ::c_uint,
955+
pub chan: ::c_uint,
956+
pub rsv: [::c_uint; 5],
957+
}
892958
}
893959

894960
s_no_extra_traits! {
@@ -920,6 +986,34 @@ cfg_if! {
920986
}
921987
}
922988

989+
cfg_if! {
990+
if #[cfg(libc_union)] {
991+
s_no_extra_traits! {
992+
// linux/ptp_clock.h
993+
#[allow(missing_debug_implementations)]
994+
pub union __c_anonymous_ptp_perout_request_1 {
995+
pub start: ptp_clock_time,
996+
pub phase: ptp_clock_time,
997+
}
998+
999+
#[allow(missing_debug_implementations)]
1000+
pub union __c_anonymous_ptp_perout_request_2 {
1001+
pub on: ptp_clock_time,
1002+
pub rsv: [::c_uint; 4],
1003+
}
1004+
1005+
#[allow(missing_debug_implementations)]
1006+
pub struct ptp_perout_request {
1007+
pub anonymous_1: __c_anonymous_ptp_perout_request_1,
1008+
pub period: ptp_clock_time,
1009+
pub index: ::c_uint,
1010+
pub flags: ::c_uint,
1011+
pub anonymous_2: __c_anonymous_ptp_perout_request_2,
1012+
}
1013+
}
1014+
}
1015+
}
1016+
9231017
cfg_if! {
9241018
if #[cfg(feature = "extra_traits")] {
9251019
impl PartialEq for sockaddr_nl {
@@ -1394,6 +1488,62 @@ cfg_if! {
13941488
self.sched_period.hash(state);
13951489
}
13961490
}
1491+
1492+
impl PartialEq for ptp_sys_offset {
1493+
fn eq(&self, other: &ptp_sys_offset) -> bool {
1494+
self.n_samples == other.n_samples &&
1495+
self.rsv == other.rsv &&
1496+
self.ts[..] == other.ts[..]
1497+
}
1498+
}
1499+
impl Eq for ptp_sys_offset {}
1500+
impl ::fmt::Debug for ptp_sys_offset {
1501+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1502+
f.debug_struct("ptp_sys_offset")
1503+
.field("n_samples", &self.n_samples)
1504+
.field("rsv", &self.rsv)
1505+
.field("ts", &&self.ts[..])
1506+
.finish()
1507+
}
1508+
}
1509+
impl ::hash::Hash for ptp_sys_offset {
1510+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1511+
self.n_samples.hash(state);
1512+
self.rsv.hash(state);
1513+
self.ts[..].hash(state);
1514+
}
1515+
}
1516+
1517+
impl PartialEq for ptp_pin_desc {
1518+
fn eq(&self, other: &ptp_pin_desc) -> bool {
1519+
self.name[..] == other.name[..] &&
1520+
self.index == other.index &&
1521+
self.func == other.func &&
1522+
self.chan == other.chan &&
1523+
self.rsv == other.rsv
1524+
}
1525+
}
1526+
impl Eq for ptp_pin_desc {}
1527+
impl ::fmt::Debug for ptp_pin_desc {
1528+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1529+
f.debug_struct("ptp_pin_desc")
1530+
.field("name", &&self.name[..])
1531+
.field("index", &self.index)
1532+
.field("func", &self.func)
1533+
.field("chan", &self.chan)
1534+
.field("rsv", &self.rsv)
1535+
.finish()
1536+
}
1537+
}
1538+
impl ::hash::Hash for ptp_pin_desc {
1539+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1540+
self.name[..].hash(state);
1541+
self.index.hash(state);
1542+
self.func.hash(state);
1543+
self.chan.hash(state);
1544+
self.rsv.hash(state);
1545+
}
1546+
}
13971547
}
13981548
}
13991549

@@ -3638,6 +3788,58 @@ pub const HWTSTAMP_FILTER_PTP_V2_SYNC: ::c_uint = 13;
36383788
pub const HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: ::c_uint = 14;
36393789
pub const HWTSTAMP_FILTER_NTP_ALL: ::c_uint = 15;
36403790

3791+
// linux/ptp_clock.h
3792+
pub const PTP_MAX_SAMPLES: ::c_uint = 25;
3793+
3794+
cfg_if! {
3795+
if #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64", target_arch = "sparc64"))] {
3796+
pub const PTP_CLOCK_GETCAPS: ::c_uint = 0x40503d01;
3797+
pub const PTP_EXTTS_REQUEST: ::c_uint = 0x80103d02;
3798+
pub const PTP_PEROUT_REQUEST: ::c_uint = 0x80383d03;
3799+
pub const PTP_ENABLE_PPS: ::c_uint = 0x80043d04;
3800+
pub const PTP_SYS_OFFSET: ::c_uint = 0x83403d05;
3801+
pub const PTP_PIN_GETFUNC: ::c_uint = 0xc0603d06;
3802+
pub const PTP_PIN_SETFUNC: ::c_uint = 0x80603d07;
3803+
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = 0xc0403d08;
3804+
pub const PTP_SYS_OFFSET_EXTENDED: ::c_uint = 0xc4c03d09;
3805+
3806+
pub const PTP_CLOCK_GETCAPS2: ::c_uint = 0x40503d0a;
3807+
pub const PTP_EXTTS_REQUEST2: ::c_uint = 0x80103d0b;
3808+
pub const PTP_PEROUT_REQUEST2: ::c_uint = 0x80383d0c;
3809+
pub const PTP_ENABLE_PPS2: ::c_uint = 0x80043d0d;
3810+
pub const PTP_SYS_OFFSET2: ::c_uint = 0x83403d0e;
3811+
pub const PTP_PIN_GETFUNC2: ::c_uint = 0xc0603d0f;
3812+
pub const PTP_PIN_SETFUNC2: ::c_uint = 0x80603d10;
3813+
pub const PTP_SYS_OFFSET_PRECISE2: ::c_uint = 0xc0403d11;
3814+
pub const PTP_SYS_OFFSET_EXTENDED2: ::c_uint = 0xc4c03d12;
3815+
} else {
3816+
pub const PTP_CLOCK_GETCAPS: ::c_uint = 0x80503d01;
3817+
pub const PTP_EXTTS_REQUEST: ::c_uint = 0x40103d02;
3818+
pub const PTP_PEROUT_REQUEST: ::c_uint = 0x40383d03;
3819+
pub const PTP_ENABLE_PPS: ::c_uint = 0x40043d04;
3820+
pub const PTP_SYS_OFFSET: ::c_uint = 0x43403d05;
3821+
pub const PTP_PIN_GETFUNC: ::c_uint = 0xc0603d06;
3822+
pub const PTP_PIN_SETFUNC: ::c_uint = 0x40603d07;
3823+
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = 0xc0403d08;
3824+
pub const PTP_SYS_OFFSET_EXTENDED: ::c_uint = 0xc4c03d09;
3825+
3826+
pub const PTP_CLOCK_GETCAPS2: ::c_uint = 0x80503d0a;
3827+
pub const PTP_EXTTS_REQUEST2: ::c_uint = 0x40103d0b;
3828+
pub const PTP_PEROUT_REQUEST2: ::c_uint = 0x40383d0c;
3829+
pub const PTP_ENABLE_PPS2: ::c_uint = 0x40043d0d;
3830+
pub const PTP_SYS_OFFSET2: ::c_uint = 0x43403d0e;
3831+
pub const PTP_PIN_GETFUNC2: ::c_uint = 0xc0603d0f;
3832+
pub const PTP_PIN_SETFUNC2: ::c_uint = 0x40603d10;
3833+
pub const PTP_SYS_OFFSET_PRECISE2: ::c_uint = 0xc0403d11;
3834+
pub const PTP_SYS_OFFSET_EXTENDED2: ::c_uint = 0xc4c03d12;
3835+
}
3836+
}
3837+
3838+
pub const PTP_PF_NONE: ::c_uint = 0;
3839+
pub const PTP_PF_EXTTS: ::c_uint = 1;
3840+
pub const PTP_PF_PEROUT: ::c_uint = 2;
3841+
pub const PTP_PF_PHYSYNC: ::c_uint = 3;
3842+
36413843
// linux/tls.h
36423844
pub const TLS_TX: ::c_int = 1;
36433845
pub const TLS_RX: ::c_int = 2;

0 commit comments

Comments
 (0)