From eb7f309aef0b0928f69af8076b29a212b0af60c7 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 31 May 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-05-31 --- pc/devlml.c | 2 +- port/devcons.c | 20 +++++++++----------- port/portfns.h | 2 +- port/tod.c | 9 ++++++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/pc/devlml.c b/pc/devlml.c index 8b983595c78ed4e5b7bdf05a909c3db8f4bd09b7..3ccdcec6007d343da461827a2950793d4d88c09f 100644 --- a/pc/devlml.c +++ b/pc/devlml.c @@ -120,7 +120,7 @@ vread(Chan *, void *va, long nbytes, vlong) { break; } // Fill in APP marker fields here - thetime = todget(); + thetime = todget(nil); frameHeader.sec = (ulong)(thetime / 1000000000LL); frameHeader.usec = (ulong)(thetime % 1000000000LL) / 1000; frameHeader.frameSize = fragsize - 2 + sizeof(FrameHeader); diff --git a/port/devcons.c b/port/devcons.c index 1531ea4081543359c4d7c1c748c9335c0fc0f83e..05d230a3a24246e44c51ae0c0b37991dfeb15c85 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -555,7 +555,7 @@ consread(Chan *c, void *buf, long n, vlong off) char *cbuf = buf; int ch, i, k, id, eol; vlong offset = off, x; - uvlong ticks; + vlong ticks, nsec; if(n <= 0) return n; @@ -674,19 +674,17 @@ consread(Chan *c, void *buf, long n, vlong off) case Qtiming: k = 0; + nsec = todget(&ticks); 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); + k += 8; + } + if(n >= 2*8){ vlong2le(cbuf+8, ticks); k += 8; } if(n >= 8){ - ticks = todget(); - vlong2le(cbuf, ticks); + vlong2le(cbuf, nsec); k += 8; } return k; @@ -717,17 +715,17 @@ consread(Chan *c, void *buf, long n, vlong off) return 0; case Qnsec: - x = todget(); + x = todget(nil); return readvlnum((ulong)offset, buf, n, x, 2*NUMSIZE); case Qmsec: - x = todget(); + x = todget(nil); x /= 1000000LL; i = x; return readnum((ulong)offset, buf, n, i, NUMSIZE); case Qtime: - x = todget(); + x = todget(nil); x /= 1000000000LL; i = x; return readnum((ulong)offset, buf, n, i, NUMSIZE); diff --git a/port/portfns.h b/port/portfns.h index 95ee514d8757a07378de73f34939741a9fd1795f..0921bb6d942d5307d3d92d44c2fe9f7bf7be989a 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -304,7 +304,7 @@ void srvrecover(Chan*, Chan*); int swapcount(ulong); int swapfull(void); void swapinit(void); -vlong todget(void); +vlong todget(vlong*); void todfix(void); void todsetfreq(vlong); void todinit(void); diff --git a/port/tod.c b/port/tod.c index 441f13b1dc9e085944448d45720a1e859b037a25..0b4536fffb527c1aa518a268872ef27b0b33531d 100644 --- a/port/tod.c +++ b/port/tod.c @@ -92,7 +92,7 @@ todset(vlong t, vlong delta, int n) // get time of day // vlong -todget(void) +todget(vlong *ticksp) { uvlong x; vlong ticks, diff; @@ -130,6 +130,9 @@ todget(void) x = tod.lasttime; tod.lasttime = x; + if(ticksp != nil) + *ticksp = ticks; + iunlock(&tod); return x; } @@ -145,7 +148,7 @@ todfix(void) // once a second, make sure we don't overflow if(MACHP(0)->ticks - last >= HZ){ last = MACHP(0)->ticks; - todget(); + todget(nil); } } @@ -155,7 +158,7 @@ seconds(void) vlong x; int i; - x = todget(); + x = todget(nil); x /= TODFREQ; i = x; return i;