Browse Source

Plan 9 from Bell Labs 2014-05-15

David du Colombier 10 years ago
parent
commit
bd0c9332d5

+ 2 - 2
sys/doc/backup.ms

@@ -32,9 +32,9 @@ as the term is used by everyone but disk manufacturers.
 In the case of BDs,
 even that is an exaggeration, with the actual capacity being
 closer to $48.44 times 10 sup 9$ bytes,
-so the claimed capacity should be read as `50 VAX-gigabytes',
+so the claimed capacity should be read as `50 BD-gigabytes',
 where a
-.I VAX-gigabyte
+.I BD-gigabyte
 is 968,800,338 bytes.
 The default
 .I venti

BIN
sys/doc/backup.pdf


+ 30 - 30
sys/doc/backup.ps

@@ -3796,49 +3796,49 @@ mark
 (even) 2458 3452 w
 (that is an exaggeration, with the actual capacity) 2717 3452 w
 (being) 720 3572 w
-(closer) 1033 3572 w
-(to) 1363 3572 w
-(48.) 1502 3572 w
-(44) 1668 3572 w
-(\327) 1802 3572 w
-(10) 1890 3572 w
+(closer) 1038 3572 w
+(to) 1373 3572 w
+(48.) 1517 3572 w
+(44) 1683 3572 w
+(\327) 1817 3572 w
+(10) 1905 3572 w
 7 /LucidaSansUnicode00 f
-(9) 2021 3532 w
+(9) 2036 3532 w
 10 /LucidaSansUnicode00 f
-(bytes,) 2114 3572 w
-(so) 2446 3572 w
-(the) 2599 3572 w
-(claimed) 2796 3572 w
-(capacity) 3214 3572 w
-(should) 3649 3572 w
-(be) 4019 3572 w
-(read) 4180 3572 w
-(as) 4437 3572 w
+(bytes,) 2134 3572 w
+(so) 2471 3572 w
+(the) 2629 3572 w
+(claimed) 2830 3572 w
+(capacity) 3252 3572 w
+(should) 3691 3572 w
+(be) 4065 3572 w
+(read) 4230 3572 w
+(as) 4491 3572 w
 10 /LucidaSansUnicode20 f
-(\030) 4585 3572 w
+(\030) 4644 3572 w
 10 /LucidaSansUnicode00 f
-(50) 4617 3572 w
-(VAX-) 4785 3572 w
+(50) 4676 3572 w
+(BD-) 4849 3572 w
 (gigabytes) 720 3692 w
 10 /LucidaSansUnicode20 f
 (\031) 1187 3692 w
 10 /LucidaSansUnicode00 f
 (,) 1219 3692 w
-(where) 1287 3692 w
-(a) 1615 3692 w
+(where) 1293 3692 w
+(a) 1627 3692 w
 10 /LucidaSans-Italic f
-(VAX-gigabyte) 1706 3692 w
+(BD-gigabyte) 1724 3692 w
 10 /LucidaSansUnicode00 f
-(is) 2424 3692 w
-(968,800,338) 2540 3692 w
-(bytes.) 3207 3692 w
-(The) 3566 3692 w
-(default) 3783 3692 w
+(is) 2380 3692 w
+(968,800,338) 2501 3692 w
+(bytes.) 3173 3692 w
+(The) 3537 3692 w
+(default) 3759 3692 w
 10 /LucidaSans-Italic f
-(venti) 4157 3692 w
+(venti) 4139 3692 w
 10 /LucidaSansUnicode00 f
-(arena) 4428 3692 w
-(size) 4732 3692 w
+(arena) 4416 3692 w
+(size) 4726 3692 w
 (is) 4960 3692 w
 (512MB, but for some reason our server is configured with 1GB arenas, so we could fit 46) 720 3812 w
 (of) 720 3932 w

+ 14 - 5
sys/man/2/time

@@ -33,18 +33,27 @@ should be stored in and treated as
 .BR ulong s;
 this extends the range of valid times into the year 2106.
 .PP
-These functions work by reading
+.I Time
+simply calls
+.I nsec
+and returns the value divided by 1000000000.
+.PP
+.I Nsec
+is a system call.
+Previous implementations read
 .BR /dev/bintime ,
-opening that file when they are first called.
+opening that file when first called,
+and maintaining a static file descriptor;
+however,
+the maintenance of file descriptors in the face
+of process forks is overly complex and prone to error.
 .SH SOURCE
 .B /sys/src/libc/9sys/time.c
 .br
-.B /sys/src/libc/9sys/nsec.c
+.B /sys/src/libc/9syscall
 .SH SEE ALSO
 .IR cputime (2),
 .IR cons (3)
 .SH DIAGNOSTICS
 Sets
 .IR errstr .
-.SH BUGS
-These routines maintain a static file descriptor.

+ 1 - 1
sys/src/9/bcm/fns.h

@@ -95,11 +95,11 @@ extern int fpuemu(Ureg*);
 extern void delay(int);				/* only scheddump() */
 extern int islo(void);
 extern void microdelay(int);			/* only edf.c */
-extern void evenaddr(uintptr);
 extern void idlehands(void);
 extern void setkernur(Ureg*, Proc*);		/* only devproc.c */
 extern void* sysexecregs(uintptr, ulong, int);
 extern void sysprocsetup(Proc*);
+extern void validalign(uintptr, unsigned);
 
 extern void kexit(Ureg*);
 

+ 24 - 7
sys/src/9/kw/arch.c

@@ -28,15 +28,32 @@ setkernur(Ureg* ureg, Proc* p)
 }
 
 /*
- * called in sysfile.c
+ * called in syscallfmt.c, sysfile.c, sysproc.c
  */
 void
-evenaddr(uintptr addr)
-{
-	if(addr & 3){
-		postnote(up, 1, "sys: odd address", NDebug);
-		error(Ebadarg);
-	}
+validalign(uintptr addr, unsigned align)
+{
+	/*
+	 * Plan 9 is a 32-bit O/S, and the hardware it runs on
+	 * does not usually have instructions which move 64-bit
+	 * quantities directly, synthesizing the operations
+	 * with 32-bit move instructions. Therefore, the compiler
+	 * (and hardware) usually only enforce 32-bit alignment,
+	 * if at all.
+	 *
+	 * Take this out if the architecture warrants it.
+	 */
+	if(align == sizeof(vlong))
+		align = sizeof(long);
+
+	/*
+	 * Check align is a power of 2, then addr alignment.
+	 */
+	if((align != 0 && !(align & (align-1))) && !(addr & (align-1)))
+		return;
+	postnote(up, 1, "sys: odd address", NDebug);
+	error(Ebadarg);
+	/*NOTREACHED*/
 }
 
 /* go to user space */

+ 1 - 1
sys/src/9/kw/fns.h

@@ -128,13 +128,13 @@ extern Block* uciallocb(int);
 extern void delay(int);				/* only scheddump() */
 extern int islo(void);
 extern void microdelay(int);			/* only edf.c */
-extern void evenaddr(uintptr);
 extern void idlehands(void);
 extern void setkernur(Ureg*, Proc*);		/* only devproc.c */
 extern void spldone(void);
 extern int splfhi(void);
 extern int splflo(void);
 extern void sysprocsetup(Proc*);
+extern void validalign(uintptr, unsigned);
 
 /*
  * PCI

+ 1 - 1
sys/src/9/mtx/fns.h

@@ -15,7 +15,6 @@ void	delay(int);
 void	dumpregs(Ureg*);
 void	delayloopinit(void);
 void	eieio(void);
-void	evenaddr(ulong);
 void	faultpower(Ureg*, ulong addr, int read);
 void	fprestore(FPsave*);
 void	fpsave(FPsave*);
@@ -103,6 +102,7 @@ void	trapvec(void);
 void	tlbflush(ulong);
 void	tlbflushall(void);
 #define	userureg(ur) (((ur)->status & MSR_PR) != 0)
+void	validalign(uintptr, unsigned);
 void	watchreset(void);
 
 #define	waserror()	(up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))

+ 23 - 6
sys/src/9/mtx/trap.c

@@ -522,15 +522,32 @@ kprocchild(Proc *p, void (*func)(void*), void *arg)
 }
 
 /*
- * called in sysfile.c
+ * called in syscallfmt.c, sysfile.c, sysproc.c
  */
 void
-evenaddr(ulong addr)
+validalign(uintptr addr, unsigned align)
 {
-	if(addr & 3){
-		postnote(up, 1, "sys: odd address", NDebug);
-		error(Ebadarg);
-	}
+	/*
+	 * Plan 9 is a 32-bit O/S, and the hardware it runs on
+	 * does not usually have instructions which move 64-bit
+	 * quantities directly, synthesizing the operations
+	 * with 32-bit move instructions. Therefore, the compiler
+	 * (and hardware) usually only enforce 32-bit alignment,
+	 * if at all.
+	 *
+	 * Take this out if the architecture warrants it.
+	 */
+	if(align == sizeof(vlong))
+		align = sizeof(long);
+
+	/*
+	 * Check align is a power of 2, then addr alignment.
+	 */
+	if((align != 0 && !(align & (align-1))) && !(addr & (align-1)))
+		return;
+	postnote(up, 1, "sys: odd address", NDebug);
+	error(Ebadarg);
+	/*NOTREACHED*/
 }
 
 long

+ 24 - 7
sys/src/9/omap/arch.c

@@ -28,15 +28,32 @@ setkernur(Ureg* ureg, Proc* p)
 }
 
 /*
- * called in sysfile.c
+ * called in syscallfmt.c, sysfile.c, sysproc.c
  */
 void
-evenaddr(uintptr addr)
-{
-	if(addr & 3){
-		postnote(up, 1, "sys: odd address", NDebug);
-		error(Ebadarg);
-	}
+validalign(uintptr addr, unsigned align)
+{
+	/*
+	 * Plan 9 is a 32-bit O/S, and the hardware it runs on
+	 * does not usually have instructions which move 64-bit
+	 * quantities directly, synthesizing the operations
+	 * with 32-bit move instructions. Therefore, the compiler
+	 * (and hardware) usually only enforce 32-bit alignment,
+	 * if at all.
+	 *
+	 * Take this out if the architecture warrants it.
+	 */
+	if(align == sizeof(vlong))
+		align = sizeof(long);
+
+	/*
+	 * Check align is a power of 2, then addr alignment.
+	 */
+	if((align != 0 && !(align & (align-1))) && !(addr & (align-1)))
+		return;
+	postnote(up, 1, "sys: odd address", NDebug);
+	error(Ebadarg);
+	/*NOTREACHED*/
 }
 
 /* go to user space */

+ 1 - 1
sys/src/9/omap/fns.h

@@ -138,11 +138,11 @@ extern void ucfreeb(Block*);
 extern void delay(int);				/* only scheddump() */
 extern int islo(void);
 extern void microdelay(int);			/* only edf.c */
-extern void evenaddr(uintptr);
 extern void idlehands(void);
 extern void setkernur(Ureg*, Proc*);		/* only devproc.c */
 extern void* sysexecregs(uintptr, ulong, int);
 extern void sysprocsetup(Proc*);
+extern void validalign(uintptr, unsigned);
 
 /*
  * PCI stuff.

+ 4 - 1
sys/src/9/pc/fns.h

@@ -26,7 +26,6 @@ int	dmadone(int);
 void	dmaend(int);
 int	dmainit(int, int);
 long	dmasetup(int, void*, long, int);
-#define	evenaddr(x)				/* x86 doesn't care */
 void	fpclear(void);
 void	fpenv(FPsave*);
 void	fpinit(void);
@@ -182,6 +181,7 @@ ulong	upaalloc(int, int);
 void	upafree(ulong, int);
 void	upareserve(ulong, int);
 #define	userureg(ur) (((ur)->cs & 0xFFFF) == UESEL)
+void	validalign(uintptr, unsigned);
 void	vectortable(void);
 void*	vmap(ulong, int);
 int	vmapsync(ulong);
@@ -190,6 +190,9 @@ void	wbinvd(void);
 void	wrmsr(int, vlong);
 int	xchgw(ushort*, int);
 
+#define PTR2UINT(p)	((uintptr)(p))
+#define UINT2PTR(i)	((void*)(i))
+
 #define	waserror()	(up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
 #define	KADDR(a)	kaddr(a)
 #define PADDR(a)	paddr((void*)(a))

+ 26 - 0
sys/src/9/pc/trap.c

@@ -953,6 +953,32 @@ if(0) print("%s %lud: noted %.8lux %.8lux\n",
 	}
 }
 
+void
+validalign(uintptr addr, unsigned align)
+{
+	/*
+	 * Plan 9 is a 32-bit O/S, and the hardware it runs on
+	 * does not usually have instructions which move 64-bit
+	 * quantities directly, synthesizing the operations
+	 * with 32-bit move instructions. Therefore, the compiler
+	 * (and hardware) usually only enforce 32-bit alignment,
+	 * if at all.
+	 *
+	 * Take this out if the architecture warrants it.
+	 */
+	if(align == sizeof(vlong))
+		align = sizeof(long);
+
+	/*
+	 * Check align is a power of 2, then addr alignment.
+	 */
+	if((align != 0 && !(align & (align-1))) && !(addr & (align-1)))
+		return;
+	postnote(up, 1, "sys: odd address", NDebug);
+	error(Ebadarg);
+	/*NOTREACHED*/
+}
+
 long
 execregs(ulong entry, ulong ssize, ulong nargs)
 {

+ 8 - 1
sys/src/9/port/syscallfmt.c

@@ -113,7 +113,7 @@ syscallfmt(int syscallno, ulong pc, va_list list)
 		a = va_arg(list, char*);
 		fmtuserstring(&fmt, a, "");
 		argv = va_arg(list, char**);
-		evenaddr(PTR2UINT(argv));
+		validalign(PTR2UINT(argv), sizeof(char*));
 		for(;;){
 			validaddr((ulong)argv, sizeof(char**), 0);
 			a = *(char **)argv;
@@ -299,6 +299,10 @@ syscallfmt(int syscallno, ulong pc, va_list list)
 			fmtprint(&fmt, " %lld", vl);
 		}
 		break;
+	case NSEC:
+		v = va_arg(list, vlong*);
+		fmtprint(&fmt, "%#p", v);
+		break;
 	}
 
 	up->syscalltrace = fmtstrflush(&fmt);
@@ -400,6 +404,9 @@ sysretfmt(int syscallno, va_list list, long ret, uvlong start, uvlong stop)
 		}
 		fmtprint(&fmt, " = %ld", ret);
 		break;
+	case NSEC:
+		fmtprint(&fmt, " = %ld", ret);		/* FoV */
+		break;
 	}
 	fmtprint(&fmt, " %s %#llud %#llud\n", errstr, start, stop);
 	up->syscalltrace = fmtstrflush(&fmt);

+ 6 - 5
sys/src/9/port/sysfile.c

@@ -190,8 +190,8 @@ syspipe(ulong *arg)
 	Dev *d;
 	static char *datastr[] = {"data", "data1"};
 
-	validaddr(arg[0], 2*BY2WD, 1);
-	evenaddr(arg[0]);
+	validaddr(arg[0], sizeof(fd), 1);
+	validalign(arg[0], sizeof(int));
 	d = devtab[devno('|', 0)];
 	c[0] = namec("#|", Atodir, 0, 0);
 	c[1] = 0;
@@ -215,8 +215,8 @@ syspipe(ulong *arg)
 		error(Enofd);
 	poperror();
 
-	((long*)arg[0])[0] = fd[0];
-	((long*)arg[0])[1] = fd[1];
+	((int*)arg[0])[0] = fd[0];
+	((int*)arg[0])[1] = fd[1];
 	return 0;
 }
 
@@ -859,7 +859,8 @@ sseek(ulong *arg)
 long
 sysseek(ulong *arg)
 {
-	validaddr(arg[0], BY2V, 1);
+	validaddr(arg[0], sizeof(vlong), 1);
+	validalign(arg[0], sizeof(vlong));
 	sseek(arg);
 	return 0;
 }

+ 16 - 5
sys/src/9/port/sysproc.c

@@ -315,7 +315,7 @@ sysexec(ulong *arg)
 			nargs++;
 		}
 	}
-	evenaddr(arg[1]);
+	validalign(arg[1], sizeof(char**));
 	argp = (char**)arg[1];
 	validaddr((ulong)argp, BY2WD, 0);
 	while(*argp){
@@ -591,7 +591,7 @@ sys_wait(ulong *arg)
 		return pwait(nil);
 
 	validaddr(arg[0], sizeof(OWaitmsg), 1);
-	evenaddr(arg[0]);
+	validalign(arg[0], BY2WD);			/* who cares? */
 	pid = pwait(&w);
 	if(pid >= 0){
 		ow = (OWaitmsg*)arg[0];
@@ -1083,7 +1083,7 @@ syssemacquire(ulong *arg)
 	Segment *s;
 
 	validaddr(arg[0], sizeof(long), 1);
-	evenaddr(arg[0]);
+	validalign(arg[0], sizeof(long));
 	addr = (long*)arg[0];
 	block = arg[1];
 	
@@ -1102,7 +1102,7 @@ systsemacquire(ulong *arg)
 	Segment *s;
 
 	validaddr(arg[0], sizeof(long), 1);
-	evenaddr(arg[0]);
+	validalign(arg[0], sizeof(long));
 	addr = (long*)arg[0];
 	ms = arg[1];
 
@@ -1120,7 +1120,7 @@ syssemrelease(ulong *arg)
 	Segment *s;
 
 	validaddr(arg[0], sizeof(long), 1);
-	evenaddr(arg[0]);
+	validalign(arg[0], sizeof(long));
 	addr = (long*)arg[0];
 	delta = arg[1];
 
@@ -1131,3 +1131,14 @@ syssemrelease(ulong *arg)
 		error(Ebadarg);
 	return semrelease(s, addr, delta);
 }
+
+long
+sysnsec(ulong *arg)
+{
+	validaddr(arg[0], sizeof(vlong), 1);
+	validalign(arg[0], sizeof(vlong));
+
+	*(vlong*)arg[0] = todget(nil);
+
+	return 0;
+}

+ 3 - 0
sys/src/9/port/systab.h

@@ -53,6 +53,7 @@ Syscall sysawait;
 Syscall syspread;
 Syscall syspwrite;
 Syscall systsemacquire;
+Syscall sysnsec;
 Syscall	sysdeath;
 
 Syscall *systab[]={
@@ -107,6 +108,7 @@ Syscall *systab[]={
 	[PREAD]		syspread,
 	[PWRITE]	syspwrite,
 	[TSEMACQUIRE]	systsemacquire,
+	[NSEC]		sysnsec,
 };
 
 char *sysctab[]={
@@ -161,6 +163,7 @@ char *sysctab[]={
 	[PREAD]		"Pread",
 	[PWRITE]	"Pwrite",
 	[TSEMACQUIRE]	"Tsemacquire",
+	[NSEC]		"Nsec",
 };
 
 int nsyscall = (sizeof systab/sizeof systab[0]);

+ 1 - 1
sys/src/9/ppc/fns.h

@@ -17,7 +17,6 @@ void	delayloopinit(void);
 void	dmiss(void);
 void	dumpregs(Ureg*);
 void	eieio(void);
-void	evenaddr(ulong);
 void	faultpower(Ureg*, ulong addr, int read);
 void	flashprogpower(int);
 void	fpgareset(void);
@@ -111,6 +110,7 @@ void	touser(void*);
 void	trapinit(void);
 void	trapvec(void);
 #define	userureg(ur) (((ur)->status & MSR_PR) != 0)
+void	validalign(uintptr, unsigned);
 #define	waserror()	(up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
 #define KADDR(a)	((void*)((ulong)(a)|KZERO))
 #define PADDR(a)	((((ulong)(a)&0xf0000000)==0xf0000000)?(ulong)(a):((ulong)(a)&~KZERO))

+ 23 - 6
sys/src/9/ppc/trap.c

@@ -583,15 +583,32 @@ kprocchild(Proc *p, void (*func)(void*), void *arg)
 }
 
 /*
- * called in sysfile.c
+ * called in syscallfmt.c, sysfile.c, sysproc.c
  */
 void
-evenaddr(ulong addr)
+validalign(uintptr addr, unsigned align)
 {
-	if(addr & 3){
-		postnote(up, 1, "sys: odd address", NDebug);
-		error(Ebadarg);
-	}
+	/*
+	 * Plan 9 is a 32-bit O/S, and the hardware it runs on
+	 * does not usually have instructions which move 64-bit
+	 * quantities directly, synthesizing the operations
+	 * with 32-bit move instructions. Therefore, the compiler
+	 * (and hardware) usually only enforce 32-bit alignment,
+	 * if at all.
+	 *
+	 * Take this out if the architecture warrants it.
+	 */
+	if(align == sizeof(vlong))
+		align = sizeof(long);
+
+	/*
+	 * Check align is a power of 2, then addr alignment.
+	 */
+	if((align != 0 && !(align & (align-1))) && !(addr & (align-1)))
+		return;
+	postnote(up, 1, "sys: odd address", NDebug);
+	error(Ebadarg);
+	/*NOTREACHED*/
 }
 
 long

+ 23 - 6
sys/src/9/rb/faultmips.c

@@ -226,13 +226,30 @@ faultmips(Ureg *ur, int user, int code)
 }
 
 /*
- * called in sysfile.c
+ * called in syscallfmt.c, sysfile.c, sysproc.c
  */
 void
-evenaddr(ulong addr)
+validalign(uintptr addr, unsigned align)
 {
-	if(addr & 3){
-		postnote(up, 1, "sys: odd address", NDebug);
-		error(Ebadarg);
-	}
+	/*
+	 * Plan 9 is a 32-bit O/S, and the hardware it runs on
+	 * does not usually have instructions which move 64-bit
+	 * quantities directly, synthesizing the operations
+	 * with 32-bit move instructions. Therefore, the compiler
+	 * (and hardware) usually only enforce 32-bit alignment,
+	 * if at all.
+	 *
+	 * Take this out if the architecture warrants it.
+	 */
+	if(align == sizeof(vlong))
+		align = sizeof(long);
+
+	/*
+	 * Check align is a power of 2, then addr alignment.
+	 */
+	if((align != 0 && !(align & (align-1))) && !(addr & (align-1)))
+		return;
+	postnote(up, 1, "sys: odd address", NDebug);
+	error(Ebadarg);
+	/*NOTREACHED*/
 }

+ 1 - 1
sys/src/9/rb/fns.h

@@ -12,7 +12,6 @@ int	cmpswap(long*, long, long);
 void	coherence(void);
 void	cycles(uvlong *);
 void	dcflush(void*, ulong);
-void	evenaddr(ulong);
 void	faultmips(Ureg*, int, int);
 ulong	fcr31(void);
 void	firmware(int);
@@ -123,6 +122,7 @@ ulong	tlbvirt(void);
 void	touser(uintptr);
 void	unleash(void);
 #define	userureg(ur) ((ur)->status & KUSER)
+void	validalign(uintptr, unsigned);
 void	vecinit(void);
 void	vector0(void);
 void	vector100(void);

+ 23 - 6
sys/src/9/teg2/arch.c

@@ -28,15 +28,32 @@ setkernur(Ureg* ureg, Proc* p)
 }
 
 /*
- * called in sysfile.c
+ * called in syscallfmt.c, sysfile.c, sysproc.c
  */
 void
-evenaddr(uintptr addr)
+validalign(uintptr addr, unsigned align)
 {
-	if(addr & 3){
-		postnote(up, 1, "sys: odd address", NDebug);
-		error(Ebadarg);
-	}
+	/*
+	 * Plan 9 is a 32-bit O/S, and the hardware it runs on
+	 * does not usually have instructions which move 64-bit
+	 * quantities directly, synthesizing the operations
+	 * with 32-bit move instructions. Therefore, the compiler
+	 * (and hardware) usually only enforce 32-bit alignment,
+	 * if at all.
+	 *
+	 * Take this out if the architecture warrants it.
+	 */
+	if(align == sizeof(vlong))
+		align = sizeof(long);
+
+	/*
+	 * Check align is a power of 2, then addr alignment.
+	 */
+	if((align != 0 && !(align & (align-1))) && !(addr & (align-1)))
+		return;
+	postnote(up, 1, "sys: odd address", NDebug);
+	error(Ebadarg);
+	/*NOTREACHED*/
 }
 
 /* go to user space */

+ 1 - 1
sys/src/9/teg2/fns.h

@@ -197,13 +197,13 @@ extern void ucfreeb(Block*);
 extern void delay(int);				/* only scheddump() */
 extern int islo(void);
 extern void microdelay(int);			/* only edf.c */
-extern void evenaddr(uintptr);
 extern void idlehands(void);
 extern void setkernur(Ureg*, Proc*);		/* only devproc.c */
 extern void syscallfmt(int syscallno, ulong pc, va_list list);
 extern void sysretfmt(int syscallno, va_list list, long ret, uvlong start, uvlong stop);
 extern void* sysexecregs(uintptr, ulong, int);
 extern void sysprocsetup(Proc*);
+extern void validalign(uintptr, unsigned);
 
 /* libc */
 long labs(long);

+ 0 - 1
sys/src/libc/9sys/mkfile

@@ -26,7 +26,6 @@ OFILES=\
 	getppid.$O\
 	getwd.$O\
 	iounit.$O\
-	nsec.$O\
 	nulldir.$O\
 	postnote.$O\
 	privalloc.$O\

+ 0 - 38
sys/src/libc/9sys/time.c

@@ -1,50 +1,12 @@
 #include <u.h>
 #include <libc.h>
 
-
-/*
- *  After a fork with fd's copied, both fd's are pointing to
- *  the same Chan structure.  Since the offset is kept in the Chan
- *  structure, the seek's and read's in the two processes can
- *  compete at moving the offset around.  Hence the unusual loop
- *  in the middle of this routine.
- */
-static long
-oldtime(long *tp)
-{
-	char b[20];
-	static int f = -1;
-	int i, retries;
-	long t;
-
-	memset(b, 0, sizeof(b));
-	for(retries = 0; retries < 100; retries++){
-		if(f < 0)
-			f = open("/dev/time", OREAD|OCEXEC);
-		if(f < 0)
-			break;
-		if(seek(f, 0, 0) < 0 || (i = read(f, b, sizeof(b))) < 0){
-			close(f);
-			f = -1;
-		} else {
-			if(i != 0)
-				break;
-		}
-	}
-	t = atol(b);
-	if(tp)
-		*tp = t;
-	return t;
-}
-
 long
 time(long *tp)
 {
 	vlong t;
 
 	t = nsec()/1000000000LL;
-	if(t == 0)
-		t = oldtime(0);
 	if(tp != nil)
 		*tp = t;
 	return t;

+ 7 - 7
sys/src/libc/9syscall/mkfile

@@ -13,7 +13,7 @@ install:V:
 			echo MOVW R1, '0(FP)'
 			echo MOVW '$'$n, R1
 			echo SYSCALL
-			if(~ $i seek) {
+			if(~ $i seek || ~ $i nsec) {
 				echo 'MOVW $-1,R5
 				BNE R1,R5,4(PC)
 				MOVW a+0(FP),R5
@@ -36,7 +36,7 @@ install:V:
 			echo ADD '$4',R29
 			echo SYSCALL
 			echo ADD '$-4',R29
-			if(~ $i seek) {		# untested so far - geoff
+			if(~ $i seek || ~ $i nsec) {	# untested so far - geoff
 				echo 'MOVW $-1,R5
 				BNE R1,R5,4(PC)
 				MOVW a+0(FP),R5
@@ -48,7 +48,7 @@ install:V:
 			echo TEXT $i'(SB)', 1, '$0'
 			echo MOVL '$'$n, AX
 			echo INT '$'64
-			if(~ $i seek) {
+			if(~ $i seek || ~ $i nsec) {
 				echo 'CMPL AX,$-1
 				JNE 4(PC)
 				MOVL a+0(FP),CX
@@ -66,7 +66,7 @@ install:V:
 			# in a register, if the system call takes no arguments
 			# there will be no 'a0+0(FP)' reserved on the stack.
 			#
-			if(! ~ $i asystemcallwithnoarguments)
+			if(! ~ $i asystemcallwithnoarguments || ! ~ $i nsec)
 				echo MOVQ RARG, 'a0+0(FP)'
 			echo MOVQ '$'$n, RARG
 			echo SYSCALL
@@ -76,7 +76,7 @@ install:V:
 			echo MOVW R7, '0(FP)'
 			echo MOVW '$'$n, R7
 			echo TA R0
-			if(~ $i seek) {
+			if(~ $i seek || ~ $i nsec) {
 				echo 'CMP R7,$-1
 				BNE 4(PC)
 				MOVW a+0(FP),R8
@@ -89,7 +89,7 @@ install:V:
 			echo MOVW R0, '0(FP)'
 			echo MOVW '$'$n, R0
 			echo SWI 0
-			if(~ $i seek) {
+			if(~ $i seek || ~ $i nsec) {
 				echo 'CMP $-1,R0
 				BNE 4(PC)
 				MOVW a+0(FP),R1
@@ -102,7 +102,7 @@ install:V:
 			echo MOVW R3, '0(FP)'
 			echo MOVW '$'$n, R3
 			echo SYSCALL
-			if(~ $i seek) {
+			if(~ $i seek || ~ $i nsec) {
 				echo 'CMP R3,$-1
 				BNE 4(PC)
 				MOVW a+0(FP),R8

+ 1 - 0
sys/src/libc/9syscall/sys.h

@@ -49,3 +49,4 @@
 #define	PREAD		50
 #define	PWRITE		51
 #define	TSEMACQUIRE	52
+#define NSEC		53