[ntpsec commit] Forward-port util/jitter.c and build it.

Eric S. Raymond esr at ntpsec.org
Wed Sep 30 16:00:51 UTC 2015


Module:    ntpsec
Branch:    master
Commit:    ed16e613232f479a9a6f8a8c532f9de45cf4e1d5
Changeset: http://git.ntpsec.org/ntpsec/commit/?id=ed16e613232f479a9a6f8a8c532f9de45cf4e1d5

Author:    Eric S. Raymond <esr at thyrsus.com>
Date:      Wed Sep 30 11:48:58 2015 -0400

Forward-port util/jitter.c and build it.

---

 util/jitter.c | 72 +++++++++++++++++++++++++++++------------------------------
 util/wscript  |  2 +-
 2 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/util/jitter.c b/util/jitter.c
index aed107f..933044e 100644
--- a/util/jitter.c
+++ b/util/jitter.c
@@ -20,7 +20,40 @@
 char progname[10];
 double sys_residual;
 double average;
-void sys_gettime(l_fp *);
+
+/*
+ * get_clocktime - return system time in NTP timestamp format.
+ */
+void
+get_clocktime(
+	l_fp *now		/* system time */
+	)
+{
+	double dtemp;
+
+	struct timespec ts;	/* seconds and nanoseconds */
+
+	/*
+	 * Convert Unix clock from seconds and nanoseconds to seconds.
+	 */
+	clock_gettime(CLOCK_REALTIME, &ts);
+	now->l_i = ts.tv_sec + JAN_1970;
+	dtemp = ts.tv_nsec / 1e9;
+
+	/*
+	 * Renormalize to seconds past 1900 and fraction.
+	 */
+	dtemp += sys_residual;
+	if (dtemp >= 1) {
+		dtemp -= 1;
+		now->l_i++;
+	} else if (dtemp < -1) {
+		dtemp += 1;
+		now->l_i--;
+	}
+	dtemp *= FRAC;
+	now->l_uf = (uint32_t)dtemp;
+}
 
 int
 main(
@@ -42,7 +75,7 @@ main(
 	 * Construct gtod array
 	 */
 	for (i = 0; i < NBUF; i ++) {
-		get_systime(&tr);
+		get_clocktime(&tr);
 		LFPTOD(&tr, gtod[i]);
 	}
 
@@ -79,37 +112,4 @@ main(
 	exit(0);
 }
 
-
-/*
- * get_systime - return system time in NTP timestamp format.
- */
-void
-get_systime(
-	l_fp *now		/* system time */
-	)
-{
-	double dtemp;
-
-	struct timespec ts;	/* seconds and nanoseconds */
-
-	/*
-	 * Convert Unix clock from seconds and nanoseconds to seconds.
-	 */
-	clock_gettime(CLOCK_REALTIME, &ts);
-	now->l_i = ts.tv_sec + JAN_1970;
-	dtemp = ts.tv_nsec / 1e9;
-
-	/*
-	 * Renormalize to seconds past 1900 and fraction.
-	 */
-	dtemp += sys_residual;
-	if (dtemp >= 1) {
-		dtemp -= 1;
-		now->l_i++;
-	} else if (dtemp < -1) {
-		dtemp += 1;
-		now->l_i--;
-	}
-	dtemp *= FRAC;
-	now->l_uf = (uint32_t)dtemp;
-}
+/* end */
diff --git a/util/wscript b/util/wscript
index 614980c..c20d908 100644
--- a/util/wscript
+++ b/util/wscript
@@ -26,7 +26,7 @@ def build(ctx):
 		install_path= "${PREFIX}/sbin/"
 	)
 
-	for name in ['hist', 'precision', 'sht', 'testrs6000']:
+	for name in ['hist', 'jitter', 'precision', 'sht', 'testrs6000']:
 		ctx(
 			target		= name,
 			features	= "c cprogram bld_include src_include libisc_include",



More information about the vc mailing list