Skip to content

Commit d330ee2

Browse files
folkertdevtgross35
authored andcommitted
add ptp_clock_caps
(backport <rust-lang#4128>) (cherry picked from commit 38318cd)
1 parent 8ffe0fa commit d330ee2

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

libc-test/build.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3956,7 +3956,8 @@ fn test_linux(target: &str) {
39563956
return true;
39573957
}
39583958
// FIXME: Requires >= 5.4 kernel headers
3959-
if name == "PTP_ENABLE_PPS2"
3959+
if name == "PTP_CLOCK_GETCAPS2"
3960+
|| name == "PTP_ENABLE_PPS2"
39603961
|| name == "PTP_EXTTS_REQUEST2"
39613962
|| name == "PTP_PEROUT_REQUEST2"
39623963
|| name == "PTP_PIN_GETFUNC2"
@@ -4410,7 +4411,11 @@ fn test_linux(target: &str) {
44104411
// `anonymous_1` is an anonymous union
44114412
(struct_ == "ptp_perout_request" && field == "anonymous_1") ||
44124413
// `anonymous_2` is an anonymous union
4413-
(struct_ == "ptp_perout_request" && field == "anonymous_2")
4414+
(struct_ == "ptp_perout_request" && field == "anonymous_2") ||
4415+
// FIXME(linux): `adjust_phase` requires >= 5.7 kernel headers
4416+
// FIXME(linux): `max_phase_adj` requires >= 5.19 kernel headers
4417+
// the rsv field shrunk when those fields got added, so is omitted too
4418+
(struct_ == "ptp_clock_caps" && (loongarch64 || sparc64) && (["adjust_phase", "max_phase_adj", "rsv"].contains(&field)))
44144419
});
44154420

44164421
cfg.volatile_item(|i| {
@@ -4485,6 +4490,10 @@ fn test_linux(target: &str) {
44854490
(struct_ == "ptp_perout_request" && field == "anonymous_1") ||
44864491
// `anonymous_2` is an anonymous union
44874492
(struct_ == "ptp_perout_request" && field == "anonymous_2") ||
4493+
// FIXME(linux): `adjust_phase` requires >= 5.7 kernel headers
4494+
// FIXME(linux): `max_phase_adj` requires >= 5.19 kernel headers
4495+
// the rsv field shrunk when those fields got added, so is omitted too
4496+
(struct_ == "ptp_clock_caps" && (loongarch64 || sparc64) && (["adjust_phase", "max_phase_adj", "rsv"].contains(&field))) ||
44884497
// invalid application of 'sizeof' to incomplete type 'long unsigned int[]'
44894498
(musl && struct_ == "mcontext_t" && field == "__extcontext" && loongarch64) ||
44904499
// FIXME(#4121): a new field was added from `f_spare`

libc-test/semver/linux.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,6 +2252,7 @@ PTHREAD_PRIO_PROTECT
22522252
PTHREAD_PROCESS_PRIVATE
22532253
PTHREAD_PROCESS_SHARED
22542254
PTHREAD_STACK_MIN
2255+
PTP_CLOCK_GETCAPS2
22552256
PTP_ENABLE_PPS
22562257
PTP_ENABLE_PPS2
22572258
PTP_EXTTS_REQUEST
@@ -3946,6 +3947,7 @@ pthread_spin_lock
39463947
pthread_spin_trylock
39473948
pthread_spin_unlock
39483949
pthread_spinlock_t
3950+
ptp_clock_caps
39493951
ptp_clock_time
39503952
ptp_extts_event
39513953
ptp_extts_request

src/unix/linux_like/linux/mod.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,19 @@ s! {
11951195
pub rsv: [::c_uint; 5],
11961196
}
11971197

1198+
pub struct ptp_clock_caps {
1199+
pub max_adj: ::c_int,
1200+
pub n_alarm: ::c_int,
1201+
pub n_ext_ts: ::c_int,
1202+
pub n_per_out: ::c_int,
1203+
pub pps: ::c_int,
1204+
pub n_pins: ::c_int,
1205+
pub cross_timestamping: ::c_int,
1206+
pub adjust_phase: ::c_int,
1207+
pub max_phase_adj: ::c_int,
1208+
pub rsv: [::c_int; 11],
1209+
}
1210+
11981211
// linux/if_xdp.h
11991212
pub struct xsk_tx_metadata_completion {
12001213
pub tx_timestamp: ::__u64,
@@ -4606,8 +4619,7 @@ pub const PTP_MAX_SAMPLES: ::c_uint = 25; // Maximum allowed offset measurement
46064619

46074620
const PTP_CLK_MAGIC: u32 = b'=' as u32;
46084621

4609-
// FIXME: needs the ptp_clock_caps struct
4610-
// pub const PTP_CLOCK_GETCAPS: ::c_uint = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 1);
4622+
pub const PTP_CLOCK_GETCAPS: ::c_uint = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 1);
46114623
pub const PTP_EXTTS_REQUEST: ::c_uint = _IOW::<ptp_extts_request>(PTP_CLK_MAGIC, 2);
46124624
pub const PTP_PEROUT_REQUEST: ::c_uint = _IOW::<ptp_perout_request>(PTP_CLK_MAGIC, 3);
46134625
pub const PTP_ENABLE_PPS: ::c_uint = _IOW::<::c_int>(PTP_CLK_MAGIC, 4);
@@ -4617,8 +4629,7 @@ pub const PTP_PIN_SETFUNC: ::c_uint = _IOW::<ptp_pin_desc>(PTP_CLK_MAGIC, 7);
46174629
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = _IOWR::<ptp_sys_offset_precise>(PTP_CLK_MAGIC, 8);
46184630
pub const PTP_SYS_OFFSET_EXTENDED: ::c_uint = _IOWR::<ptp_sys_offset_extended>(PTP_CLK_MAGIC, 9);
46194631

4620-
// FIXME: needs the ptp_clock_caps struct
4621-
// pub const PTP_CLOCK_GETCAPS2: ::c_uint = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 10);
4632+
pub const PTP_CLOCK_GETCAPS2: ::c_uint = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 10);
46224633
pub const PTP_EXTTS_REQUEST2: ::c_uint = _IOW::<ptp_extts_request>(PTP_CLK_MAGIC, 11);
46234634
pub const PTP_PEROUT_REQUEST2: ::c_uint = _IOW::<ptp_perout_request>(PTP_CLK_MAGIC, 12);
46244635
pub const PTP_ENABLE_PPS2: ::c_uint = _IOW::<::c_int>(PTP_CLK_MAGIC, 13);

0 commit comments

Comments
 (0)