netd: use the right clock
authorAlan Cox <alan@linux.intel.com>
Thu, 9 Nov 2017 23:06:54 +0000 (23:06 +0000)
committerAlan Cox <alan@linux.intel.com>
Thu, 9 Nov 2017 23:06:54 +0000 (23:06 +0000)
timer 1 is CPU time. That works by luck on a 6809 but on a Z80 clone at
lots of MHz it doesn't run very fast!

What we really need to do is expose the kernel 1/10th second raw tick clock
as timer 2

Applications/netd/clock-arch.c
Applications/netd/clock-arch.h

index 9fc20a6..847f11c 100644 (file)
 clock_time_t
 clock_time(void)
 {
-  struct{
-      uint32_t high;
-      uint32_t low;
-  }now;
-  _time((__ktime_t *)&now,1);
-  /* FIXME: needs a multiplier to turn into ms FIXME */
-  return now.low;
-  //  return tv.tv_sec * 1000 + tv.tv_usec / 1000;
+  static uint8_t init;
+  static time_t tbase;
+  time_t t;
+
+  if (!init) {
+    init = 1;
+    time(&tbase);
+  }
+  time(&t);
+  t -= tbase;
+  return t;
 }
 /*---------------------------------------------------------------------------*/
index 063b30f..0bd3ced 100644 (file)
@@ -35,6 +35,6 @@
 #define __CLOCK_ARCH_H__
 
 typedef int clock_time_t;
-#define CLOCK_CONF_SECOND 10
+#define CLOCK_CONF_SECOND 1
 
 #endif /* __CLOCK_ARCH_H__ */