Skip to content

Commit 01c7a63

Browse files
authored
Merge pull request #4128 from folkertdev/ptp-clock-caps
add `ptp_clock_caps`
2 parents 0a8f04a + 38318cd commit 01c7a63

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

libc-test/build.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -3885,7 +3885,8 @@ fn test_linux(target: &str) {
38853885
return true;
38863886
}
38873887
// FIXME: Requires >= 5.4 kernel headers
3888-
if name == "PTP_ENABLE_PPS2"
3888+
if name == "PTP_CLOCK_GETCAPS2"
3889+
|| name == "PTP_ENABLE_PPS2"
38893890
|| name == "PTP_EXTTS_REQUEST2"
38903891
|| name == "PTP_PEROUT_REQUEST2"
38913892
|| name == "PTP_PIN_GETFUNC2"
@@ -4333,7 +4334,11 @@ fn test_linux(target: &str) {
43334334
// `anonymous_1` is an anonymous union
43344335
(struct_ == "ptp_perout_request" && field == "anonymous_1") ||
43354336
// `anonymous_2` is an anonymous union
4336-
(struct_ == "ptp_perout_request" && field == "anonymous_2")
4337+
(struct_ == "ptp_perout_request" && field == "anonymous_2") ||
4338+
// FIXME(linux): `adjust_phase` requires >= 5.7 kernel headers
4339+
// FIXME(linux): `max_phase_adj` requires >= 5.19 kernel headers
4340+
// the rsv field shrunk when those fields got added, so is omitted too
4341+
(struct_ == "ptp_clock_caps" && (loongarch64 || sparc64) && (["adjust_phase", "max_phase_adj", "rsv"].contains(&field)))
43374342
});
43384343

43394344
cfg.volatile_item(|i| {
@@ -4410,6 +4415,10 @@ fn test_linux(target: &str) {
44104415
(struct_ == "ptp_perout_request" && field == "anonymous_1") ||
44114416
// `anonymous_2` is an anonymous union
44124417
(struct_ == "ptp_perout_request" && field == "anonymous_2") ||
4418+
// FIXME(linux): `adjust_phase` requires >= 5.7 kernel headers
4419+
// FIXME(linux): `max_phase_adj` requires >= 5.19 kernel headers
4420+
// the rsv field shrunk when those fields got added, so is omitted too
4421+
(struct_ == "ptp_clock_caps" && (loongarch64 || sparc64) && (["adjust_phase", "max_phase_adj", "rsv"].contains(&field))) ||
44134422
// invalid application of 'sizeof' to incomplete type 'long unsigned int[]'
44144423
(musl && struct_ == "mcontext_t" && field == "__extcontext" && loongarch64) ||
44154424
// FIXME(#4121): a new field was added from `f_spare`

libc-test/semver/linux.txt

+2
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
@@ -3945,6 +3946,7 @@ pthread_spin_lock
39453946
pthread_spin_trylock
39463947
pthread_spin_unlock
39473948
pthread_spinlock_t
3949+
ptp_clock_caps
39483950
ptp_clock_time
39493951
ptp_extts_event
39503952
ptp_extts_request

src/unix/linux_like/linux/mod.rs

+15-4
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,
@@ -4566,8 +4579,7 @@ pub const PTP_MAX_SAMPLES: ::c_uint = 25; // Maximum allowed offset measurement
45664579

45674580
const PTP_CLK_MAGIC: u32 = b'=' as u32;
45684581

4569-
// FIXME: needs the ptp_clock_caps struct
4570-
// pub const PTP_CLOCK_GETCAPS: ::c_uint = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 1);
4582+
pub const PTP_CLOCK_GETCAPS: ::c_uint = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 1);
45714583
pub const PTP_EXTTS_REQUEST: ::c_uint = _IOW::<ptp_extts_request>(PTP_CLK_MAGIC, 2);
45724584
pub const PTP_PEROUT_REQUEST: ::c_uint = _IOW::<ptp_perout_request>(PTP_CLK_MAGIC, 3);
45734585
pub const PTP_ENABLE_PPS: ::c_uint = _IOW::<::c_int>(PTP_CLK_MAGIC, 4);
@@ -4577,8 +4589,7 @@ pub const PTP_PIN_SETFUNC: ::c_uint = _IOW::<ptp_pin_desc>(PTP_CLK_MAGIC, 7);
45774589
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = _IOWR::<ptp_sys_offset_precise>(PTP_CLK_MAGIC, 8);
45784590
pub const PTP_SYS_OFFSET_EXTENDED: ::c_uint = _IOWR::<ptp_sys_offset_extended>(PTP_CLK_MAGIC, 9);
45794591

4580-
// FIXME: needs the ptp_clock_caps struct
4581-
// pub const PTP_CLOCK_GETCAPS2: ::c_uint = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 10);
4592+
pub const PTP_CLOCK_GETCAPS2: ::c_uint = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 10);
45824593
pub const PTP_EXTTS_REQUEST2: ::c_uint = _IOW::<ptp_extts_request>(PTP_CLK_MAGIC, 11);
45834594
pub const PTP_PEROUT_REQUEST2: ::c_uint = _IOW::<ptp_perout_request>(PTP_CLK_MAGIC, 12);
45844595
pub const PTP_ENABLE_PPS2: ::c_uint = _IOW::<::c_int>(PTP_CLK_MAGIC, 13);

0 commit comments

Comments
 (0)