[ntpsec commit] Forward-port util/ rs6000.c and write a build recipe for it.

Eric S. Raymond esr at ntpsec.org
Wed Sep 30 15:40:47 UTC 2015


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

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

Forward-port util/rs6000.c and write a build recipe for it.

---

 util/testrs6000.c | 41 ++++++++++++++++++++++++-----------------
 util/wscript      | 22 ++++++++++++----------
 2 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/util/testrs6000.c b/util/testrs6000.c
index d8ef3be..7b5ae18 100644
--- a/util/testrs6000.c
+++ b/util/testrs6000.c
@@ -5,16 +5,32 @@
  * the program will print an occasional "result=nnnnnn" (the residual
  * slew from adjtime()).
  *
+ * This version is in modern ANSI C rather than the archaic dialect of
+ * the RS6000's day.
+ *
  * Run this as root!
  */
+#include <stdlib.h>
+#include <unistd.h>
 #include <signal.h>
 #include <sys/time.h>
 #include <time.h>
 #include <stdio.h>
 
-int timeout();
 struct timeval adjustment, result;
 
+static void
+timeout(int sig)
+{
+	if (adjtime(&adjustment, &result))
+	    printf("adjtime call failed\n");
+	if (result.tv_sec != 0 || result.tv_usec != 0) {
+		printf("result = %d.%6d  ",
+		       (int) result.tv_sec,
+		       (int) result.tv_usec);
+	}
+}
+
 int
 main (
 	int argc,
@@ -25,32 +41,23 @@ main (
 	int i;
 	time_t curtime;
 	char ascbuf[BUFSIZ];
+	struct sigaction sa;
 
 	curtime = time(0);
-	printf("Starting: %s", ctime_r(&curtime));
+	printf("Starting: %s", ctime_r(&curtime, ascbuf));
 	value.it_interval.tv_sec = value.it_value.tv_sec = 1;
 	value.it_interval.tv_usec = value.it_value.tv_usec = 0;
 	adjustment.tv_sec = 0;
 	adjustment.tv_usec = -2000;
+	sa.sa_handler = timeout;
+	sigemptyset(&sa.sa_mask);
+	sa.sa_flags = SA_RESTART;
 	signal(SIGALRM, timeout);
 	setitimer(ITIMER_REAL, &value, &oldvalue);
 	for (i=0; i<10; i++) {
 		pause();
 	}
-}
 
-int
-timeout(
-	int sig,
-	int code,
-	struct sigcontext *scp
-	)
-{
-	signal (SIGALRM, timeout);
-	if (adjtime(&adjustment, &result)) 
-	    printf("adjtime call failed\n");
-	if (result.tv_sec != 0 || result.tv_usec != 0) {
-		printf("result.u = %d.%06.6d  ", (int) result.tv_sec,
-		       (int) result.tv_usec);
-	}
+	exit(0);
 }
+
diff --git a/util/wscript b/util/wscript
index b4abd02..7ef6ebb 100644
--- a/util/wscript
+++ b/util/wscript
@@ -26,14 +26,16 @@ def build(ctx):
 		install_path= "${PREFIX}/sbin/"
 	)
 
-	ctx(
-		target		= "precision",
-		features	= "c cprogram bld_include src_include libisc_include",
-		source		= ["precision.c"],
-		includes	= [
-					"%s/precision/" % bldnode
-				],
-		use		= "ntp opts isc M RT PTHREAD",
-		install_path= "${PREFIX}/sbin/"
-	)
+	for name in ['precision', 'sht', 'testrs6000']:
+		ctx(
+			target		= name,
+			features	= "c cprogram bld_include src_include libisc_include",
+			source		= [name + ".c"],
+			includes	= [
+						"%s/%s/" % (bldnode, name)
+					],
+			use		= "ntp opts isc M RT PTHREAD",
+			install_path= False
+		)
+
 



More information about the vc mailing list