From f9dff981b317f3f50ac314f2c4e6b396864fb7b4 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 9 May 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-05-09 --- port/devcons.c | 37 +++++++++++++++++++++++++++++++++++++ port/tod.c | 2 -- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/port/devcons.c b/port/devcons.c index 4bc6304822b5e54404b03c99d62871066894fec5..1531ea4081543359c4d7c1c748c9335c0fc0f83e 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -340,6 +340,7 @@ enum{ Qauth, Qauthcheck, Qauthent, + Qtiming, Qclock, Qcons, Qconsctl, @@ -391,6 +392,7 @@ static Dirtab consdir[]={ "sysname", {Qsysname}, 0, 0664, "sysstat", {Qsysstat}, 0, 0666, "time", {Qtime}, NUMSIZE, 0664, + "timing", {Qtiming}, 3*8, 0664, "user", {Quser}, NAMELEN, 0666, }; @@ -528,6 +530,21 @@ consclose(Chan *c) } } + +uvlong order = 0x0001020304050607ULL; + +void +vlong2le(char *t, vlong from) +{ + uchar *f, *o; + int i; + + f = (uchar*)&from; + o = (uchar*)ℴ + for(i = 0; i < 8; i++) + t[i] = f[o[i]]; +} + static long consread(Chan *c, void *buf, long n, vlong off) { @@ -655,6 +672,26 @@ consread(Chan *c, void *buf, long n, vlong off) memmove(buf, tmp+k, n); return n; + case Qtiming: + k = 0; + if(n >= 3*8){ + ticks = fastticks((uvlong*)&fasthz); + vlong2le(cbuf+16, fasthz); + vlong2le(cbuf+8, ticks); + k += 2*8; + } else if(n >= 2*8){ + ticks = fastticks(nil); + vlong2le(cbuf+8, ticks); + k += 8; + } + if(n >= 8){ + ticks = todget(); + vlong2le(cbuf, ticks); + k += 8; + } + return k; + + case Qkey: return keyread(buf, n, offset); diff --git a/port/tod.c b/port/tod.c index 2690e4e60253cd53736e38b57ae8e0d7572dc613..c98310cb3611792b96e582cbb367bb83e03e9a88 100644 --- a/port/tod.c +++ b/port/tod.c @@ -55,8 +55,6 @@ todinit(void) void todsetfreq(vlong f) { - int lf; - // the shift is an attempt to maintain precision // during the caculations. the number of bits in // the multiplier should be log(TODFREQ) + 31 - log(f).