| [chrony-dev] [RFC PATCH v1 03/17] local: Enable use of alternative clock ID for clock_gettime() |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] [RFC PATCH v1 03/17] local: Enable use of alternative clock ID for clock_gettime()
- From: Christopher S M Hall <christopher.s.hall@xxxxxxxxx>
- Date: Sat, 6 Dec 2025 06:10:49 +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=1765002153; x=1796538153; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Wyx7aTfyI9v16Ls+NjWQeCc/sM10twHX8ZPesUci6tQ=; b=ApJa12B/7eSxXwvZ1tw0P4XxNfnesvLYVVaInZ++z3VJurW1TAXdd3yE a1D0TMK8gxko/uYcsJQPTkzmpw4txMVnCDZsJngaCybKnm9TGkj/65DQ5 RkuK72eaOaOQcJR0ZbtGT7w8mgNJFWpH/1tk/sqI++NkovATt8TAU90Lb vZTvO89/7Jt2EZSpj/vqh3a0cqij8xKoHmP8yRG4QpB2YYLFOXbKwpzcp qVFoqhyiBXo1iYzsOqwYyLv86To5OUlZx72HEnB0LSW2JjEMv+DjdA9NJ 7Bh8psfD1v8mLKSFvXPOWz2RCwj04pyGCqorfi+oujB7spBaeALnFSLyY g==;
This patch enables specification of alternate clock ID for calls to clock_gettime(). This enables use of
auxiliary clocks for Linux builds and can be extended to other platforms as needed.
---
local.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/local.c b/local.c
index 1e004b5..d3725df 100644
--- a/local.c
+++ b/local.c
@@ -103,6 +103,12 @@ static double max_clock_error;
#define NSEC_PER_SEC 1000000000
+#ifdef HAVE_CLOCK_GETTIME
+static const int realtime = CLOCK_REALTIME;
+/* Clock ID used for clock_adjtime */
+static const int *clock_id = &realtime;
+#endif
+
/* ================================================== */
/* Ask the system for the resolution of the system clock. The Linux
@@ -504,7 +510,7 @@ void
LCL_ReadRawTime(struct timespec *ts)
{
#if HAVE_CLOCK_GETTIME
- if (clock_gettime(CLOCK_REALTIME, ts) < 0)
+ if (clock_gettime(*clock_id, ts) < 0)
LOG_FATAL("clock_gettime() failed : %s", strerror(errno));
#else
struct timeval tv;
--
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.