shithub: mc

Download patch

ref: f8040a2ba54ace38a662e104fb677dc72da6d647
parent: 1eadc811d6caf591b73d236957617e80811e2637
author: Ori Bernstein <[email protected]>
date: Thu Jan 9 06:04:15 EST 2014

Add system-specific waitstatus

    The format of the value differs by OS

--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -54,6 +54,9 @@
 sys.myr: sys-$(SYS).myr
 	cp sys-$(SYS).myr sys.myr
 
+waitstatus.myr: waitstatus-$(SYS).myr
+	cp waitstatus-$(SYS).myr waitstatus.myr
+
 syscall.s: syscall-$(SYS).s
 	cp syscall-$(SYS).s syscall.s
 
--- /dev/null
+++ b/libstd/waitstatus-linux.myr
@@ -1,0 +1,22 @@
+use "die.use"
+pkg std =
+	type waitstatus = union
+		`Waitexit int64
+		`Waitsig  int64
+		`Waitstop int64
+	;;
+
+	const waitstatus	: (st : int64 -> waitstatus)
+;;
+
+const waitstatus = {st
+	if st & 0x7f == 0 /* if exited */
+		-> `Waitexit ((st & 0xff00) >> 8)
+	elif ((st & 0xffff)-1) < 0xff /* if signaled */
+		-> `Waitsig ((st) & 0x7f)
+	elif (((st & 0xffff)*0x10001)>>8) > 0x7f00
+		-> `Waitstop ((st & 0xff00) >> 8)
+	;;
+	die("unreachable")
+}
+
--- /dev/null
+++ b/libstd/waitstatus-osx.myr
@@ -1,0 +1,19 @@
+use "die.use"
+pkg std =
+	type waitstatus = union
+		`Waitexit int64
+		`Waitsig  int64
+		`Waitstop int64
+	;;
+
+	const waitstatus	: (st : int64 -> waitstatus)
+;;
+
+const waitstatus = {st
+	match st & 0o177
+	| 0:	-> `Waitexit (st >> 8)
+	| 0o177:-> `Waitstop (st >> 8)
+	| sig: 	-> `Waitsig signal
+	;;
+	die("unreachable")
+}
--- a/libstd/waitstatus.myr
+++ /dev/null
@@ -1,21 +1,0 @@
-use "die.use"
-pkg std =
-	type waitstatus = union
-		`Waitexit int64
-		`Waitsig  int64
-		`Waitstop int64
-	;;
-
-	const waitstatus	: (st : int64 -> waitstatus)
-;;
-
-const waitstatus = {st
-	if st & 0x7f == 0 /* if exited */
-		-> `Waitexit ((st & 0xff00) >> 8)
-	elif ((st & 0xffff)-1) < 0xff /* if signaled */
-		-> `Waitsig ((st) & 0x7f)
-	elif (((st & 0xffff)*0x10001)>>8) > 0x7f00
-		-> `Waitstop ((st & 0xff00) >> 8)
-	;;
-	die("unreachable")
-}