From 1332f582f608f92b68e020071978146faf1f38a0 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 9 Nov 2017 23:06:54 +0000 Subject: [PATCH] netd: use the right clock 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 | 19 +++++++++++-------- Applications/netd/clock-arch.h | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Applications/netd/clock-arch.c b/Applications/netd/clock-arch.c index 9fc20a61..847f11cf 100644 --- a/Applications/netd/clock-arch.c +++ b/Applications/netd/clock-arch.c @@ -46,13 +46,16 @@ 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; } /*---------------------------------------------------------------------------*/ diff --git a/Applications/netd/clock-arch.h b/Applications/netd/clock-arch.h index 063b30f3..0bd3ced1 100644 --- a/Applications/netd/clock-arch.h +++ b/Applications/netd/clock-arch.h @@ -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__ */ -- 2.34.1