[time-nuts] Poor Man's IRIG-B Generator?

Chris Kuethe chris.kuethe at gmail.com
Sun Mar 18 00:11:47 EDT 2007


Reading through the list archives someone was asking about patches to
make ntp's "tg.c" compile, so here's the patch to make it compile on
OpenBSD (probably others too). It sounds plausible...

your OS may or may not have sys/audio.h or sys/audioio.h

--- tg.c.orig	Sat Mar 17 21:50:39 2007
+++ tg.c	Sat Mar 17 22:04:23 2007
@@ -49,15 +49,16 @@
  * 10, but not yet with other machines. It uses no special features and
  * should be readily portable to other hardware and operating systems.
  */
+#include <sys/types.h>
+#include <sys/audioio.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
-#include <sys/audio.h>
 #include <math.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
 #include <string.h>
 #include <unistd.h>

@@ -349,8 +350,8 @@
 	 * initialize the time.
 	 */
 	if (!utc) {
-		gettimeofday(&tv, NULL);
-		tm = gmtime(&tv.tv_sec);
+		time_t t = time(NULL);
+		tm = gmtime(&t);
 		minute = tm->tm_min;
 		hour = tm->tm_hour;
 		day = tm->tm_yday + 1;

-- 
GDB has a 'break' feature; why doesn't it have 'fix' too?



More information about the time-nuts mailing list