| [chrony-dev] [RFC PATCH v1 11/17] sys_linux, configure: Add compile time check for updated ptp_sys_offset_extended struct |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] [RFC PATCH v1 11/17] sys_linux, configure: Add compile time check for updated ptp_sys_offset_extended struct
- From: Christopher S M Hall <christopher.s.hall@xxxxxxxxx>
- Date: Sat, 6 Dec 2025 06:10:57 +0000
- Cc: christopher.s.hall@xxxxxxxxx, david.zage@xxxxxxxxx, yoong.siang.song@xxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765002156; x=1796538156; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fIXRgxGjTFpS29+v70kgU1HPV43hiY9k2JorOwm3sOI=; b=SaVx36BOrbOz1E1V3ehDx2TdS4Z1JJZhmXEhSLpwS2ZCJQdNK4fEjdZs UBJrhestVNTUbCGFDKwd5V3ArNnOQ7Zx4PRZMZGv333+ntmPvLNUUtW0r TzxeHnNYC+/xfL9GqyWvogcRmsKs0vIYiDBArjzjmo4ExkfwCqg3JKGHc sZ4APTwjGoXHCz4Rxrqwqmveu+6GSJ4Bw1e7kNWzU/8OMq1orOGuVOal7 7kTXuzhJxDqNQ1PiWXFEAr/3/3fG2VgeR6nKdBEiyKJHtWXysDEHn3onx McXzcjMkWe04gPYmmsUAbcki7PUN+Yk6K0ETGFFH3mavjWLGMWMd7BFww w==;
To support additional system clocks including auxiliary clocks, the Linux kernel added a clockid field
to struct ptp_sys_offset_extended. Add a compile time check to make sure this field is present and return
an error at runtime if it is not.
This is purposefully an independent compile time check from FEAT_AUXCLOCK because the PHC method is not
known until runtime.
---
configure | 13 +++++++++++++
sys_linux.c | 7 +++++++
2 files changed, 20 insertions(+)
diff --git a/configure b/configure
index c1a7150..c6e3373 100755
--- a/configure
+++ b/configure
@@ -251,6 +251,8 @@ priv_ops=""
feat_ipv6=1
feat_phc=1
try_phc=0
+feat_phcext_clockid=1
+try_phcext_clockid=0
feat_pps=1
try_setsched=0
try_lockmem=0
@@ -443,6 +445,7 @@ case $OPERATINGSYSTEM in
try_setsched=1
try_lockmem=1
try_phc=1
+ try_phcext_clockid=1
try_arc4random=0
try_clockadjtime=1
try_auxclock=1
@@ -862,6 +865,16 @@ then
add_def FEAT_PHC
fi
+if [ $feat_phcext_clockid = "1" ] && [ $try_phcext_clockid = "1" ] && \
+ test_code 'PHC: PTP_SYS_OFFSET_EXTENDED accepts Clock ID' \
+ 'linux/ptp_clock.h linux/time.h' '' '' \
+ 'struct ptp_sys_offset_extended offset;
+ offset.clockid = CLOCK_REALTIME;
+ ioctl(1, PTP_SYS_OFFSET_EXTENDED, &offset);'
+then
+ add_def FEAT_PHCEXT_CLOCKID
+fi
+
if [ $try_setsched = "1" ] && \
test_code \
'pthread_setschedparam()' \
diff --git a/sys_linux.c b/sys_linux.c
index bc34184..9258143 100644
--- a/sys_linux.c
+++ b/sys_linux.c
@@ -818,6 +818,13 @@ get_extended_phc_readings(int phc_fd, int max_samples, struct timespec ts[][3])
memset(&sys_off, 0, sizeof (sys_off));
sys_off.n_samples = max_samples;
+#ifdef FEAT_PHCEXT_CLOCKID
+ sys_off.clockid = *clock_id;
+#else
+ if (clock_id != &realtime)
+ LOG_FATAL("Extended PHC offset request for non-default clock id, but "
+ "the kernel does not support it");
+#endif
if (ioctl(phc_fd, PTP_SYS_OFFSET_EXTENDED, &sys_off)) {
DEBUG_LOG("ioctl(%s) failed : %s", "PTP_SYS_OFFSET_EXTENDED", strerror(errno));
--
2.34.1
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.