shithub: riscv

Download patch

ref: 3207e8b6a4339f39e2261d1f1878e8049b65c23c
parent: 7abf926bcf5a4f301a9ab48173093524196fd8ce
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue May 20 01:06:31 EDT 2014

add _nsec() syscall 53 for binary compatibility with labs distribution

the new syscall is added under the symbol _nsec() for
binary compatibility.

nsec() is still a library function reading /dev/bintime.

--- a/sys/lib/acid/syscall
+++ b/sys/lib/acid/syscall
@@ -130,6 +130,7 @@
 	{50, {"pread",		"DADZ",		code(*syspread:list)}},
 	{51, {"pwrite",		"DTDZ",		code(*syspwrite:list)}},
 	{52, {"tsemacquire",	"AD",		code(*systsemacquire:list)}},
+	{53, {"_nsec",		"A",		code(*sys_nsec:list)}},
 };
 
 defn syscall() {
--- a/sys/lib/acid/truss
+++ b/sys/lib/acid/truss
@@ -98,6 +98,7 @@
 		"pread",
 		"pwrite",
 		"tsemacquire",
+		"_nsec",
 	};
 
 trussapecalls = {
--- a/sys/src/9/port/syscallfmt.c
+++ b/sys/src/9/port/syscallfmt.c
@@ -297,6 +297,10 @@
 			fmtprint(&fmt, " %lld", vl);
 		}
 		break;
+	case _NSEC:
+		v = va_arg(list, vlong*);
+		fmtprint(&fmt, "%#p", v);
+		break;
 	}
 
 	a = fmtstrflush(&fmt);
--- a/sys/src/9/port/sysfile.c
+++ b/sys/src/9/port/sysfile.c
@@ -879,6 +879,7 @@
 	vlong n, *v;
 
 	v = va_arg(list, vlong*);
+	evenaddr((uintptr)v);
 	validaddr((uintptr)v, sizeof(vlong), 1);
 
 	fd = va_arg(list, int);
--- a/sys/src/9/port/sysproc.c
+++ b/sys/src/9/port/sysproc.c
@@ -1182,3 +1182,16 @@
 		error(Ebadarg);
 	return (uintptr)semrelease(s, addr, delta);
 }
+
+/* For binary compatibility */
+uintptr
+sys_nsec(va_list list)
+{
+	vlong *v;
+
+	v = va_arg(list, vlong*);
+	evenaddr((uintptr)v);
+	validaddr((uintptr)v, sizeof(vlong), 1);
+	*v = todget(nil);
+	return 0;
+}
--- a/sys/src/9/port/systab.h
+++ /dev/null
@@ -1,166 +1,0 @@
-#include "/sys/src/libc/9syscall/sys.h"
-
-typedef uintptr Syscall(va_list);
-
-Syscall sysr1;
-Syscall sys_errstr;
-Syscall sysbind;
-Syscall syschdir;
-Syscall sysclose;
-Syscall sysdup;
-Syscall sysalarm;
-Syscall sysexec;
-Syscall sysexits;
-Syscall sys_fsession;
-Syscall sysfauth;
-Syscall sys_fstat;
-Syscall syssegbrk;
-Syscall sys_mount;
-Syscall sysopen;
-Syscall sys_read;
-Syscall sysoseek;
-Syscall syssleep;
-Syscall sys_stat;
-Syscall sysrfork;
-Syscall sys_write;
-Syscall syspipe;
-Syscall syscreate;
-Syscall sysfd2path;
-Syscall sysbrk_;
-Syscall sysremove;
-Syscall sys_wstat;
-Syscall sys_fwstat;
-Syscall sysnotify;
-Syscall sysnoted;
-Syscall syssegattach;
-Syscall syssegdetach;
-Syscall syssegfree;
-Syscall syssegflush;
-Syscall sysrendezvous;
-Syscall sysunmount;
-Syscall sys_wait;
-Syscall syssemacquire;
-Syscall syssemrelease;
-Syscall sysseek;
-Syscall sysfversion;
-Syscall syserrstr;
-Syscall sysstat;
-Syscall sysfstat;
-Syscall syswstat;
-Syscall sysfwstat;
-Syscall sysmount;
-Syscall sysawait;
-Syscall syspread;
-Syscall syspwrite;
-Syscall systsemacquire;
-Syscall	sysdeath;
-
-Syscall *systab[]={
-	[SYSR1]		sysr1,
-	[_ERRSTR]	sys_errstr,
-	[BIND]		sysbind,
-	[CHDIR]		syschdir,
-	[CLOSE]		sysclose,
-	[DUP]		sysdup,
-	[ALARM]		sysalarm,
-	[EXEC]		sysexec,
-	[EXITS]		sysexits,
-	[_FSESSION]	sys_fsession,
-	[FAUTH]		sysfauth,
-	[_FSTAT]	sys_fstat,
-	[SEGBRK]	syssegbrk,
-	[_MOUNT]	sys_mount,
-	[OPEN]		sysopen,
-	[_READ]		sys_read,
-	[OSEEK]		sysoseek,
-	[SLEEP]		syssleep,
-	[_STAT]		sys_stat,
-	[RFORK]		sysrfork,
-	[_WRITE]	sys_write,
-	[PIPE]		syspipe,
-	[CREATE]	syscreate,
-	[FD2PATH]	sysfd2path,
-	[BRK_]		sysbrk_,
-	[REMOVE]	sysremove,
-	[_WSTAT]	sys_wstat,
-	[_FWSTAT]	sys_fwstat,
-	[NOTIFY]	sysnotify,
-	[NOTED]		sysnoted,
-	[SEGATTACH]	syssegattach,
-	[SEGDETACH]	syssegdetach,
-	[SEGFREE]	syssegfree,
-	[SEGFLUSH]	syssegflush,
-	[RENDEZVOUS]	sysrendezvous,
-	[UNMOUNT]	sysunmount,
-	[_WAIT]		sys_wait,
-	[SEMACQUIRE]	syssemacquire,
-	[SEMRELEASE]	syssemrelease,
-	[SEEK]		sysseek,
-	[FVERSION]	sysfversion,
-	[ERRSTR]	syserrstr,
-	[STAT]		sysstat,
-	[FSTAT]		sysfstat,
-	[WSTAT]		syswstat,
-	[FWSTAT]	sysfwstat,
-	[MOUNT]		sysmount,
-	[AWAIT]		sysawait,
-	[PREAD]		syspread,
-	[PWRITE]	syspwrite,
-	[TSEMACQUIRE]	systsemacquire,
-};
-
-char *sysctab[]={
-	[SYSR1]		"Running",
-	[_ERRSTR]	"_errstr",
-	[BIND]		"Bind",
-	[CHDIR]		"Chdir",
-	[CLOSE]		"Close",
-	[DUP]		"Dup",
-	[ALARM]		"Alarm",
-	[EXEC]		"Exec",
-	[EXITS]		"Exits",
-	[_FSESSION]	"_fsession",
-	[FAUTH]		"Fauth",
-	[_FSTAT]	"_fstat",
-	[SEGBRK]	"Segbrk",
-	[_MOUNT]	"_mount",
-	[OPEN]		"Open",
-	[_READ]		"_read",
-	[OSEEK]		"Oseek",
-	[SLEEP]		"Sleep",
-	[_STAT]		"_stat",
-	[RFORK]		"Rfork",
-	[_WRITE]	"_write",
-	[PIPE]		"Pipe",
-	[CREATE]	"Create",
-	[FD2PATH]	"Fd2path",
-	[BRK_]		"Brk",
-	[REMOVE]	"Remove",
-	[_WSTAT]	"_wstat",
-	[_FWSTAT]	"_fwstat",
-	[NOTIFY]	"Notify",
-	[NOTED]		"Noted",
-	[SEGATTACH]	"Segattach",
-	[SEGDETACH]	"Segdetach",
-	[SEGFREE]	"Segfree",
-	[SEGFLUSH]	"Segflush",
-	[RENDEZVOUS]	"Rendez",
-	[UNMOUNT]	"Unmount",
-	[_WAIT]		"_wait",
-	[SEMACQUIRE]	"Semacquire",
-	[SEMRELEASE]	"Semrelease",
-	[SEEK]		"Seek",
-	[FVERSION]	"Fversion",
-	[ERRSTR]	"Errstr",
-	[STAT]		"Stat",
-	[FSTAT]		"Fstat",
-	[WSTAT]		"Wstat",
-	[FWSTAT]	"Fwstat",
-	[MOUNT]		"Mount",
-	[AWAIT]		"Await",
-	[PREAD]		"Pread",
-	[PWRITE]	"Pwrite",
-	[TSEMACQUIRE]	"Tsemacquire",
-};
-
-int nsyscall = (sizeof systab/sizeof systab[0]);
--- a/sys/src/libc/9syscall/mkfile
+++ b/sys/src/libc/9syscall/mkfile
@@ -6,7 +6,7 @@
 	for(I in $SYS) {
 		i=`{echo $I|tr A-Z a-z}
 		n=`{sed -n '/[ 	]'$I'[ 	]/s/.*	//p' sys.h}
-		if(~ $i exits) i=_exits
+		if(~ $i (exits nsec)) i=_$i
 		{switch($objtype){
 		case 68000 68020
 			echo TEXT $i'(SB)', 1, '$0'
@@ -18,7 +18,7 @@
 			echo MOVW R1, '0(FP)'
 			echo MOVW '$'$n, R1
 			echo SYSCALL
-			if(~ $i seek) {
+			if(~ $i (seek _nsec)) {
 				echo 'MOVW $-1,R5
 				BNE R1,R5,4(PC)
 				MOVW a+0(FP),R5
@@ -41,7 +41,7 @@
 			echo ADD '$4',R29
 			echo SYSCALL
 			echo ADD '$-4',R29
-			if(~ $i seek) {		# untested so far - geoff
+			if(~ $i (seek _nsec)) {		# untested so far - geoff
 				echo 'MOVW $-1,R5
 				BNE R1,R5,4(PC)
 				MOVW a+0(FP),R5
@@ -53,7 +53,7 @@
 			echo TEXT $i'(SB)', 1, '$0'
 			echo MOVL '$'$n, AX
 			echo INT '$'64
-			if(~ $i seek) {
+			if(~ $i (seek _nsec)) {
 				echo 'CMPL AX,$-1
 				JNE 4(PC)
 				MOVL a+0(FP),CX
@@ -62,10 +62,9 @@
 			}
 			echo RET
 		case amd64
-			if(~ $i seek)
-				echo TEXT _seek'(SB)', 1, '$0'
-			if not
-				echo TEXT $i'(SB)', 1, '$0'
+			j=$i
+			if(~ $i seek) j=_seek
+			echo TEXT $j'(SB)', 1, '$0'
 			echo MOVQ RARG, 'a0+0(FP)'
 			echo MOVQ '$'$n, RARG
 			echo SYSCALL
@@ -75,7 +74,7 @@
 			echo MOVW R7, '0(FP)'
 			echo MOVW '$'$n, R7
 			echo TA R0
-			if(~ $i seek) {
+			if(~ $i (seek _nsec)) {
 				echo 'CMP R7,$-1
 				BNE 4(PC)
 				MOVW a+0(FP),R8
@@ -100,7 +99,7 @@
 			echo MOVW R0, '0(FP)'
 			echo MOVW '$'$n, R0
 			echo SWI 0
-			if(~ $i seek) {
+			if(~ $i (seek _nsec)) {
 				echo 'CMP $-1,R0
 				BNE 4(PC)
 				MOVW a+0(FP),R1
@@ -113,7 +112,7 @@
 			echo MOVW R3, '0(FP)'
 			echo MOVW '$'$n, R3
 			echo SYSCALL
-			if(~ $i seek) {
+			if(~ $i (seek _nsec)) {
 				echo 'CMP R3,$-1
 				BNE 4(PC)
 				MOVW a+0(FP),R8
--- a/sys/src/libc/9syscall/sys.h
+++ b/sys/src/libc/9syscall/sys.h
@@ -49,3 +49,4 @@
 #define	PREAD		50
 #define	PWRITE		51
 #define	TSEMACQUIRE	52
+#define _NSEC		53