Skip to content

Commit 3f9d5c1

Browse files
davidv1992folkertdev
authored andcommitted
Added all definitions from linux/ptp-clock.h
1 parent 72cb7aa commit 3f9d5c1

File tree

3 files changed

+250
-2
lines changed

3 files changed

+250
-2
lines changed

libc-test/build.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3464,6 +3464,8 @@ fn test_linux(target: &str) {
34643464
"linux/netlink.h",
34653465
// FIXME: requires Linux >= 5.6:
34663466
[!musl]: "linux/openat2.h",
3467+
"linux/ptp_clock.h",
3468+
// FIXME: requires Linux >= 5.6:
34673469
[!musl]: "linux/ptrace.h",
34683470
"linux/quota.h",
34693471
"linux/random.h",
@@ -3612,6 +3614,9 @@ fn test_linux(target: &str) {
36123614
if musl && ty == "seccomp_notif_sizes" {
36133615
return true;
36143616
}
3617+
if musl && ty == "ptp_sys_offset_extended" {
3618+
return true;
3619+
}
36153620

36163621
// LFS64 types have been removed in musl 1.2.4+
36173622
if musl && (ty.ends_with("64") || ty.ends_with("64_t")) {
@@ -3792,6 +3797,7 @@ fn test_linux(target: &str) {
37923797
if name == "SECCOMP_GET_NOTIF_SIZES"
37933798
|| name == "SECCOMP_FILTER_FLAG_NEW_LISTENER"
37943799
|| name == "SECCOMP_FILTER_FLAG_TSYNC_ESRCH"
3800+
|| name == "PTP_SYS_OFFSET_EXTENDED"
37953801
|| name == "SECCOMP_USER_NOTIF_FLAG_CONTINUE" // requires >= 5.5
37963802
|| name == "SECCOMP_ADDFD_FLAG_SETFD" // requires >= 5.9
37973803
|| name == "SECCOMP_ADDFD_FLAG_SEND" // requires >= 5.9
@@ -3804,6 +3810,15 @@ fn test_linux(target: &str) {
38043810
|| name.starts_with("RTEXT_FILTER_")
38053811
|| name.starts_with("SO_J1939")
38063812
|| name.starts_with("SCM_J1939")
3813+
|| name == "PTP_CLOCK_GETCAPS2"
3814+
|| name == "PTP_EXTTS_REQUEST2"
3815+
|| name == "PTP_PEROUT_REQUEST2"
3816+
|| name == "PTP_ENABLE_PPS2"
3817+
|| name == "PTP_SYS_OFFSET2"
3818+
|| name == "PTP_PIN_GETFUNC2"
3819+
|| name == "PTP_PIN_SETFUNC2"
3820+
|| name == "PTP_SYS_OFFSET_PRECISE2"
3821+
|| name == "PTP_SYS_OFFSET_EXTENDED2"
38073822
{
38083823
return true;
38093824
}
@@ -4311,7 +4326,11 @@ fn test_linux(target: &str) {
43114326
// `__exit_status` type is a patch which is absent in musl
43124327
(struct_ == "utmpx" && field == "ut_exit" && musl) ||
43134328
// `can_addr` is an anonymous union
4314-
(struct_ == "sockaddr_can" && field == "can_addr")
4329+
(struct_ == "sockaddr_can" && field == "can_addr") ||
4330+
// `anonymous_1` is an anonymous union
4331+
(struct_ == "ptp_perout_request" && field == "anonymous_1") ||
4332+
// `anonymous_2` is an anonymous union
4333+
(struct_ == "ptp_perout_request" && field == "anonymous_2")
43154334
});
43164335

43174336
cfg.volatile_item(|i| {
@@ -4375,7 +4394,11 @@ fn test_linux(target: &str) {
43754394
// the `ifr_ifrn` field is an anonymous union
43764395
(struct_ == "iwreq" && field == "ifr_ifrn") ||
43774396
// the `key` field is a zero-sized array
4378-
(struct_ == "iw_encode_ext" && field == "key")
4397+
(struct_ == "iw_encode_ext" && field == "key") ||
4398+
// `anonymous_1` is an anonymous union
4399+
(struct_ == "ptp_perout_request" && field == "anonymous_1") ||
4400+
// `anonymous_2` is an anonymous union
4401+
(struct_ == "ptp_perout_request" && field == "anonymous_2")
43794402
});
43804403

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

libc-test/semver/linux.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,29 @@ PTHREAD_INHERIT_SCHED
20582058
PTHREAD_EXPLICIT_SCHED
20592059
PTHREAD_STACK_MIN
20602060
PTHREAD_ONCE_INIT
2061+
PTP_CLOCK_GETCAPS
2062+
PTP_CLOCK_GETCAPS2
2063+
PTP_ENABLE_PPS
2064+
PTP_ENABLE_PPS2
2065+
PTP_EXTTS_REQUEST
2066+
PTP_EXTTS_REQUEST2
2067+
PTP_MAX_SAMPLES
2068+
PTP_PEROUT_REQUEST
2069+
PTP_PEROUT_REQUEST2
2070+
PTP_PF_EXTTS
2071+
PTP_PF_NONE
2072+
PTP_PF_PEROUT
2073+
PTP_PF_PHYSYNC
2074+
PTP_PIN_GETFUNC
2075+
PTP_PIN_GETFUNC2
2076+
PTP_PIN_SETFUNC
2077+
PTP_PIN_SETFUNC2
2078+
PTP_SYS_OFFSET
2079+
PTP_SYS_OFFSET2
2080+
PTP_SYS_OFFSET_EXTENDED
2081+
PTP_SYS_OFFSET_EXTENDED2
2082+
PTP_SYS_OFFSET_PRECISE
2083+
PTP_SYS_OFFSET_PRECISE2
20612084
PTRACE_ATTACH
20622085
PTRACE_CONT
20632086
PTRACE_DETACH

src/unix/linux_like/linux/mod.rs

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,57 @@ s! {
804804
pub val: ::c_int,
805805
}
806806

807+
// linux/ptp_clock.h
808+
pub struct ptp_clock_time {
809+
pub sec: ::__s64,
810+
pub nsec: ::__u32,
811+
pub reserved: ::__u32,
812+
}
813+
814+
pub struct ptp_clock_caps {
815+
pub max_adj: ::c_int,
816+
pub n_alarm: ::c_int,
817+
pub n_ext_ts: ::c_int,
818+
pub n_per_out: ::c_int,
819+
pub pps: ::c_int,
820+
pub n_pins: ::c_int,
821+
pub cross_timestamping: ::c_int,
822+
#[cfg(target_env = "gnu")]
823+
pub adjust_phase: ::c_int,
824+
#[cfg(target_env = "gnu")]
825+
pub max_phase_adj: ::c_int,
826+
#[cfg(target_env = "gnu")]
827+
pub rsv: [::c_int; 11],
828+
#[cfg(any(target_env = "musl", target_env = "ohos"))]
829+
pub rsv: [::c_int; 13],
830+
}
831+
832+
pub struct ptp_extts_request {
833+
pub index: ::c_uint,
834+
pub flags: ::c_uint,
835+
pub rsv: [::c_uint; 2],
836+
}
837+
838+
pub struct ptp_sys_offset_extended {
839+
pub n_samples: ::c_uint,
840+
pub rsv: [::c_uint; 3],
841+
pub ts: [[ptp_clock_time; 3]; 25],
842+
}
843+
844+
pub struct ptp_sys_offset_precise {
845+
pub device: ptp_clock_time,
846+
pub sys_realtime: ptp_clock_time,
847+
pub sys_monoraw: ptp_clock_time,
848+
pub rsv: [::c_uint; 4],
849+
}
850+
851+
pub struct ptp_extts_event {
852+
pub t: ptp_clock_time,
853+
index: ::c_uint,
854+
flags: ::c_uint,
855+
rsv: [::c_uint; 2],
856+
}
857+
807858
// linux/sctp.h
808859

809860
pub struct sctp_initmsg {
@@ -1200,6 +1251,21 @@ s_no_extra_traits! {
12001251
pub offset_to_priv: ::__u32,
12011252
pub hdr: ::tpacket_bd_header_u,
12021253
}
1254+
1255+
// linux/ptp_clock.h
1256+
pub struct ptp_sys_offset {
1257+
pub n_samples: ::c_uint,
1258+
pub rsv: [::c_uint; 3],
1259+
pub ts: [ptp_clock_time; 51],
1260+
}
1261+
1262+
pub struct ptp_pin_desc {
1263+
pub name: [::c_char; 64],
1264+
pub index: ::c_uint,
1265+
pub func: ::c_uint,
1266+
pub chan: ::c_uint,
1267+
pub rsv: [::c_uint; 5],
1268+
}
12031269
}
12041270

12051271
s_no_extra_traits! {
@@ -1266,6 +1332,34 @@ s_no_extra_traits! {
12661332
}
12671333
}
12681334

1335+
cfg_if! {
1336+
if #[cfg(libc_union)] {
1337+
s_no_extra_traits! {
1338+
// linux/ptp_clock.h
1339+
#[allow(missing_debug_implementations)]
1340+
pub union __c_anonymous_ptp_perout_request_1 {
1341+
pub start: ptp_clock_time,
1342+
pub phase: ptp_clock_time,
1343+
}
1344+
1345+
#[allow(missing_debug_implementations)]
1346+
pub union __c_anonymous_ptp_perout_request_2 {
1347+
pub on: ptp_clock_time,
1348+
pub rsv: [::c_uint; 4],
1349+
}
1350+
1351+
#[allow(missing_debug_implementations)]
1352+
pub struct ptp_perout_request {
1353+
pub anonymous_1: __c_anonymous_ptp_perout_request_1,
1354+
pub period: ptp_clock_time,
1355+
pub index: ::c_uint,
1356+
pub flags: ::c_uint,
1357+
pub anonymous_2: __c_anonymous_ptp_perout_request_2,
1358+
}
1359+
}
1360+
}
1361+
}
1362+
12691363
cfg_if! {
12701364
if #[cfg(feature = "extra_traits")] {
12711365
impl PartialEq for sockaddr_nl {
@@ -1751,6 +1845,62 @@ cfg_if! {
17511845
.finish()
17521846
}
17531847
}
1848+
1849+
impl PartialEq for ptp_sys_offset {
1850+
fn eq(&self, other: &ptp_sys_offset) -> bool {
1851+
self.n_samples == other.n_samples &&
1852+
self.rsv == other.rsv &&
1853+
self.ts[..] == other.ts[..]
1854+
}
1855+
}
1856+
impl Eq for ptp_sys_offset {}
1857+
impl ::fmt::Debug for ptp_sys_offset {
1858+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1859+
f.debug_struct("ptp_sys_offset")
1860+
.field("n_samples", &self.n_samples)
1861+
.field("rsv", &self.rsv)
1862+
.field("ts", &&self.ts[..])
1863+
.finish()
1864+
}
1865+
}
1866+
impl ::hash::Hash for ptp_sys_offset {
1867+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1868+
self.n_samples.hash(state);
1869+
self.rsv.hash(state);
1870+
self.ts[..].hash(state);
1871+
}
1872+
}
1873+
1874+
impl PartialEq for ptp_pin_desc {
1875+
fn eq(&self, other: &ptp_pin_desc) -> bool {
1876+
self.name[..] == other.name[..] &&
1877+
self.index == other.index &&
1878+
self.func == other.func &&
1879+
self.chan == other.chan &&
1880+
self.rsv == other.rsv
1881+
}
1882+
}
1883+
impl Eq for ptp_pin_desc {}
1884+
impl ::fmt::Debug for ptp_pin_desc {
1885+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1886+
f.debug_struct("ptp_pin_desc")
1887+
.field("name", &&self.name[..])
1888+
.field("index", &self.index)
1889+
.field("func", &self.func)
1890+
.field("chan", &self.chan)
1891+
.field("rsv", &self.rsv)
1892+
.finish()
1893+
}
1894+
}
1895+
impl ::hash::Hash for ptp_pin_desc {
1896+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1897+
self.name[..].hash(state);
1898+
self.index.hash(state);
1899+
self.func.hash(state);
1900+
self.chan.hash(state);
1901+
self.rsv.hash(state);
1902+
}
1903+
}
17541904
}
17551905
}
17561906

@@ -4092,6 +4242,58 @@ pub const HWTSTAMP_FILTER_PTP_V2_SYNC: ::c_uint = 13;
40924242
pub const HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: ::c_uint = 14;
40934243
pub const HWTSTAMP_FILTER_NTP_ALL: ::c_uint = 15;
40944244

4245+
// linux/ptp_clock.h
4246+
pub const PTP_MAX_SAMPLES: ::c_uint = 25;
4247+
4248+
cfg_if! {
4249+
if #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64", target_arch = "sparc64"))] {
4250+
pub const PTP_CLOCK_GETCAPS: ::c_uint = 0x40503d01;
4251+
pub const PTP_EXTTS_REQUEST: ::c_uint = 0x80103d02;
4252+
pub const PTP_PEROUT_REQUEST: ::c_uint = 0x80383d03;
4253+
pub const PTP_ENABLE_PPS: ::c_uint = 0x80043d04;
4254+
pub const PTP_SYS_OFFSET: ::c_uint = 0x83403d05;
4255+
pub const PTP_PIN_GETFUNC: ::c_uint = 0xc0603d06;
4256+
pub const PTP_PIN_SETFUNC: ::c_uint = 0x80603d07;
4257+
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = 0xc0403d08;
4258+
pub const PTP_SYS_OFFSET_EXTENDED: ::c_uint = 0xc4c03d09;
4259+
4260+
pub const PTP_CLOCK_GETCAPS2: ::c_uint = 0x40503d0a;
4261+
pub const PTP_EXTTS_REQUEST2: ::c_uint = 0x80103d0b;
4262+
pub const PTP_PEROUT_REQUEST2: ::c_uint = 0x80383d0c;
4263+
pub const PTP_ENABLE_PPS2: ::c_uint = 0x80043d0d;
4264+
pub const PTP_SYS_OFFSET2: ::c_uint = 0x83403d0e;
4265+
pub const PTP_PIN_GETFUNC2: ::c_uint = 0xc0603d0f;
4266+
pub const PTP_PIN_SETFUNC2: ::c_uint = 0x80603d10;
4267+
pub const PTP_SYS_OFFSET_PRECISE2: ::c_uint = 0xc0403d11;
4268+
pub const PTP_SYS_OFFSET_EXTENDED2: ::c_uint = 0xc4c03d12;
4269+
} else {
4270+
pub const PTP_CLOCK_GETCAPS: ::c_uint = 0x80503d01;
4271+
pub const PTP_EXTTS_REQUEST: ::c_uint = 0x40103d02;
4272+
pub const PTP_PEROUT_REQUEST: ::c_uint = 0x40383d03;
4273+
pub const PTP_ENABLE_PPS: ::c_uint = 0x40043d04;
4274+
pub const PTP_SYS_OFFSET: ::c_uint = 0x43403d05;
4275+
pub const PTP_PIN_GETFUNC: ::c_uint = 0xc0603d06;
4276+
pub const PTP_PIN_SETFUNC: ::c_uint = 0x40603d07;
4277+
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = 0xc0403d08;
4278+
pub const PTP_SYS_OFFSET_EXTENDED: ::c_uint = 0xc4c03d09;
4279+
4280+
pub const PTP_CLOCK_GETCAPS2: ::c_uint = 0x80503d0a;
4281+
pub const PTP_EXTTS_REQUEST2: ::c_uint = 0x40103d0b;
4282+
pub const PTP_PEROUT_REQUEST2: ::c_uint = 0x40383d0c;
4283+
pub const PTP_ENABLE_PPS2: ::c_uint = 0x40043d0d;
4284+
pub const PTP_SYS_OFFSET2: ::c_uint = 0x43403d0e;
4285+
pub const PTP_PIN_GETFUNC2: ::c_uint = 0xc0603d0f;
4286+
pub const PTP_PIN_SETFUNC2: ::c_uint = 0x40603d10;
4287+
pub const PTP_SYS_OFFSET_PRECISE2: ::c_uint = 0xc0403d11;
4288+
pub const PTP_SYS_OFFSET_EXTENDED2: ::c_uint = 0xc4c03d12;
4289+
}
4290+
}
4291+
4292+
pub const PTP_PF_NONE: ::c_uint = 0;
4293+
pub const PTP_PF_EXTTS: ::c_uint = 1;
4294+
pub const PTP_PF_PEROUT: ::c_uint = 2;
4295+
pub const PTP_PF_PHYSYNC: ::c_uint = 3;
4296+
40954297
// linux/tls.h
40964298
pub const TLS_TX: ::c_int = 1;
40974299
pub const TLS_RX: ::c_int = 2;

0 commit comments

Comments
 (0)