[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 ]


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.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/