ref: e59b8d11ec241cedc71eb70e67901b7b829bc794
parent: 026b3393bd5d9456229de8a56b2da9486742e028
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Mar 3 06:04:00 EST 2015
Make exit() exit the whole process, portably. OSX and Linux exit system calls are not interchangable. Linux exit() exits the thread, and exit_group() exits the process. OSX exit() exits the process. So, we need to wrap these up into system specific syswrap calls. syswrap+posixy.myr now contains shared system calls, and syswrap-ss+posixy-system.myr contains the ones that have different semantics. The goal is to move emulation (sleep, etc) into there.
--- a/libstd/bldfile
+++ b/libstd/bldfile
@@ -72,6 +72,8 @@
strsplit.myr
strstrip.myr
syswrap+plan9.myr
+ syswrap-ss+posixy-linux.myr
+ syswrap-ss+posixy-osx.myr
syswrap+posixy.myr
swap.myr
try.myr
--- a/libstd/fmt.myr
+++ b/libstd/fmt.myr
@@ -5,6 +5,7 @@
use "types.use"
use "utf.use"
use "syswrap.use"
+use "syswrap-ss.use"
use "varargs.use"
use "extremum.use"
use "chartype.use"
--- a/libstd/optparse.myr
+++ b/libstd/optparse.myr
@@ -5,6 +5,7 @@
use "option.use"
use "slpush.use"
use "syswrap.use"
+use "syswrap-ss.use"
use "types.use"
use "utf.use"
--- a/libstd/sys+osx-x64.myr
+++ b/libstd/sys+osx-x64.myr
@@ -622,6 +622,8 @@
const clock_getres : (clk : clock, ts : timespec# -> int)
const clock_gettime : (clk : clock, ts : timespec# -> int)
const clock_settime : (clk : clock, ts : timespec# -> int)
+ /* FIXME: HACK HACK HACK -- does nothing */
+ const sleep : (time : uint64 -> int32)
/* system information */
const uname : (buf : utsname# -> int)
@@ -666,6 +668,8 @@
const waitpid = {pid, loc, opt;
-> wait4(pid, loc, opt, 0 castto(rusage#))
}
+
+const sleep = {time; -> 0}
const execv = {cmd, args
var p, cargs, i
--- a/libstd/syswrap+posixy.myr
+++ b/libstd/syswrap+posixy.myr
@@ -61,7 +61,6 @@
const fork : (-> pid)
const execv : (cmd : byte[:], args : byte[:][:] -> int64)
const execve : (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> int64)
- const exit : (status:int -> void)
const waitpid : (pid:pid, loc:int32#, opt : int64 -> int64)
pkglocal const Canunmap : bool = true
@@ -101,7 +100,6 @@
const fork = {; -> sys.fork() castto(pid)}
const execv = {cmd, args; -> sys.execv(cmd, args)}
const execve = {cmd, args, env; -> sys.execve(cmd, args, env)}
-const exit = {status; sys.exit_group(status)}
const sleep = {time; sys.sleep(time)}
/* memory stuff */
--- /dev/null
+++ b/libstd/syswrap-ss+posixy-osx.myr
@@ -1,0 +1,7 @@
+use sys
+
+pkg std =
+ const exit : (status:int -> void)
+;;
+
+const exit = {status; sys.exit(status)}