~kris/9p

9hist

eb7f309aef0b0928f69af8076b29a212b0af60c7 — David du Colombier 27 years ago b204deb
Plan 9 from Bell Labs 1999-05-31
4 files changed, 17 insertions(+), 16 deletions(-)

M pc/devlml.c
M port/devcons.c
M port/portfns.h
M port/tod.c
M pc/devlml.c => pc/devlml.c +1 -1
@@ 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);

M port/devcons.c => port/devcons.c +9 -11
@@ 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);

M port/portfns.h => port/portfns.h +1 -1
@@ 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);

M port/tod.c => port/tod.c +6 -3
@@ 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;