shithub: mc

Download patch

ref: ba9f79ecd79a5d24b74f714cc8c70204d5bc26c5
parent: fc5368fb01485128fbead0818c0136cc83e750be
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Dec 23 11:54:59 EST 2014

Closer to working plan9 code.

--- a/libstd/sys+plan9-x64.myr
+++ b/libstd/sys+plan9-x64.myr
@@ -1,9 +1,9 @@
 use "systypes.use"
 
 pkg sys =
-	type pid	= int64	/* process id */
-	type scno	= int64	/* syscall */
-	type fdopt	= int64	/* fd options */
+	type pid	= int32 process id */
+	type scno	= int32	/* syscall */
+	type fdopt	= int32	/* fd options */
 	type fd		= int32	/* fd */
 	type rflags	= int32	/* rfork flags */
 
@@ -12,17 +12,17 @@
 		cyclefreq	: uint64
 		kcycles	: int64
 		pcycles	: int64
-		pid	: uint32
+		pid	: pid
 		clock	: uint32
 	;;
 
-	type prof = 
+	type prof = struct
 		pp	: byte#	/* plink */
-		next	: byte# /* plink */
-		last	: byte# /* plink */
-		first	: byte# /* plink */
-		pid	: uint32 /* plink */
-		what	: uint32 /* plink */
+		next	: byte#	/* plink */
+		last	: byte#	/* plink */
+		first	: byte#	/* plink */
+		pid	: pid	/* plink */
+		what	: uint32	/* plink */
 	;;
 
 
@@ -54,17 +54,17 @@
 	const Dmwrite	: int = 0x2
 	const Dmexec	: int = 0x1
 
-	const Rfnameg	: rflags = 1 << 0,
-	const Rfenvg	: rflags = 1 << 1,
-	const Rffdg	: rflags = 1 << 2,
-	const Rfnoteg	: rflags = 1 << 3,
-	const Rfproc	: rflags = 1 << 4,
-	const Rfmem	: rflags = 1 << 5,
-	const Rfnowait	: rflags = 1 << 6,
-	const Rfcnameg	: rflags = 1 << 10,
-	const Rfcenvg	: rflags = 1 << 11,
-	const Rfcfdg	: rflags = 1 << 12,
-	const Rfrend	: rflags = 1 << 13,
+	const Rfnameg	: rflags = 1 << 0
+	const Rfenvg	: rflags = 1 << 1
+	const Rffdg	: rflags = 1 << 2
+	const Rfnoteg	: rflags = 1 << 3
+	const Rfproc	: rflags = 1 << 4
+	const Rfmem	: rflags = 1 << 5
+	const Rfnowait	: rflags = 1 << 6
+	const Rfcnameg	: rflags = 1 << 10
+	const Rfcenvg	: rflags = 1 << 11
+	const Rfcfdg	: rflags = 1 << 12
+	const Rfrend	: rflags = 1 << 13
 	const Rfnomnt	: rflags = 1 << 14
 
 	const Syssysr1		: scno = 0
--- a/libstd/syswrap+plan9.myr
+++ b/libstd/syswrap+plan9.myr
@@ -30,7 +30,7 @@
 
 	/* process stuff */
 	const getpid	: ( -> pid)
-	const kill	: (pid:pid, sig:int64 -> int64)
+	const suicide	: (-> void)
 	const fork	: (-> pid)
 	const execv	: (cmd : byte[:], args : byte[:][:] -> int64)
 	const execve	: (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> int64)
@@ -38,8 +38,6 @@
 	const waitpid	: (pid:pid, loc:int32#, opt : int64	-> int64)
 ;;
 
-extern const _tos : 
-
 /* fd stuff */
 const open	= {path, opts;	-> openmode(path, opts, 0o777)}
 const openmode	= {path, opts, mod
@@ -53,10 +51,10 @@
 const creat	= {path, mode;	-> sys.create(path, sys.Owronly | sys.Otrunc, mode castto(int)) castto(fd)}
 const read	= {fd, buf;	-> sys.pread(fd castto(sys.fd), buf, -1 castto(sys.off)) castto(size)}
 const write	= {fd, buf;	-> sys.pwrite(fd castto(sys.fd), buf, -1 castto(sys.off)) castto(size)}
-const pipe	= {fds;		-> sys.pipe(fds castto(sys.fd[2]#))}
+const pipe	= {fds;		-> sys.pipe(fds castto(sys.fd[2]#)) castto(int64)}
 
 /* path manipulation */
-const mkdir	= {path, mod
+const mkdir	= {path, mode
 	var fd
 
 	fd = sys.create(path, sys.Ordonly, sys.Dmdir | (mode castto(int)))
@@ -70,8 +68,13 @@
 const unlink	= {path;	-> sys.remove(path)}
 
 /* process stuff */
-const getpid	= {;		-> sys.gettos().pid}
-const suicide	= {pid;		-> (0 castto(int#))#}
+const getpid	= {;		
+	var tos
+	
+	tos = sys.gettos()
+	-> tos.pid castto(pid)
+}
+const suicide	= {;		(0 castto(int#))#}
 const fork	= {;		-> sys.rfork(sys.Rfproc | sys.Rffdg | sys.Rfrend) castto(pid)}
 const execv	= {cmd, args;	-> sys.exec(cmd, args) castto(int64)}
 const execve	= {cmd, args, env;	-> sys.exec(cmd, args) castto(int64)}	/* FIXME: don't ignore env */
--- a/libstd/syswrap+posixy.myr
+++ b/libstd/syswrap+posixy.myr
@@ -29,7 +29,7 @@
 
 	/* process stuff */
 	const getpid	: ( -> pid)
-	const suicide	: ( -> int64)
+	const suicide	: ( -> void)
 	const fork	: (-> pid)
 	const execv	: (cmd : byte[:], args : byte[:][:] -> int64)
 	const execve	: (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> int64)
@@ -52,7 +52,7 @@
 
 /* process stuff */
 const getpid	= {;		-> sys.getpid() castto(pid)}
-const suicide	= {;		-> sys.kill(sys.getpid(), 6)}	/* kill self with sigabort */
+const suicide	= {;		sys.kill(sys.getpid(), 6)}	/* kill self with sigabort */
 const fork	= {;		-> sys.fork() castto(pid)}
 const execv	= {cmd, args;	-> sys.execv(cmd, args)}
 const execve	= {cmd, args, env;	-> sys.execve(cmd, args, env)}