summaryrefslogtreecommitdiff
path: root/libstd
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-03-03 11:04:00 -0800
committerOri Bernstein <ori@eigenstate.org>2015-03-03 11:04:00 -0800
commit773fe672bb1910db23857626dfde78340e682098 (patch)
tree8817cdf7db6ffe9612e9bceed34f8db24765ace9 /libstd
parent996e59437ef5c435689d2f669fb9c0e987d04c5e (diff)
downloadmc-773fe672bb1910db23857626dfde78340e682098.tar.gz
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.
Diffstat (limited to 'libstd')
-rw-r--r--libstd/bldfile2
-rw-r--r--libstd/fmt.myr1
-rw-r--r--libstd/optparse.myr1
-rw-r--r--libstd/sys+osx-x64.myr4
-rw-r--r--libstd/syswrap+posixy.myr2
-rw-r--r--libstd/syswrap-ss+posixy-osx.myr7
6 files changed, 15 insertions, 2 deletions
diff --git a/libstd/bldfile b/libstd/bldfile
index cbd074c..d0ab7bb 100644
--- a/libstd/bldfile
+++ b/libstd/bldfile
@@ -72,6 +72,8 @@ lib std {inc=.} =
strsplit.myr
strstrip.myr
syswrap+plan9.myr
+ syswrap-ss+posixy-linux.myr
+ syswrap-ss+posixy-osx.myr
syswrap+posixy.myr
swap.myr
try.myr
diff --git a/libstd/fmt.myr b/libstd/fmt.myr
index 5504710..9092cd1 100644
--- a/libstd/fmt.myr
+++ b/libstd/fmt.myr
@@ -5,6 +5,7 @@ use "die.use"
use "types.use"
use "utf.use"
use "syswrap.use"
+use "syswrap-ss.use"
use "varargs.use"
use "extremum.use"
use "chartype.use"
diff --git a/libstd/optparse.myr b/libstd/optparse.myr
index 0e6ea66..8a0d28f 100644
--- a/libstd/optparse.myr
+++ b/libstd/optparse.myr
@@ -5,6 +5,7 @@ use "fmt.use"
use "option.use"
use "slpush.use"
use "syswrap.use"
+use "syswrap-ss.use"
use "types.use"
use "utf.use"
diff --git a/libstd/sys+osx-x64.myr b/libstd/sys+osx-x64.myr
index 727027c..a84c006 100644
--- a/libstd/sys+osx-x64.myr
+++ b/libstd/sys+osx-x64.myr
@@ -622,6 +622,8 @@ pkg sys =
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)
@@ -667,6 +669,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
diff --git a/libstd/syswrap+posixy.myr b/libstd/syswrap+posixy.myr
index 63f3535..e5fd6d1 100644
--- a/libstd/syswrap+posixy.myr
+++ b/libstd/syswrap+posixy.myr
@@ -61,7 +61,6 @@ pkg std =
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 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)}
-const exit = {status; sys.exit_group(status)}
const sleep = {time; sys.sleep(time)}
/* memory stuff */
diff --git a/libstd/syswrap-ss+posixy-osx.myr b/libstd/syswrap-ss+posixy-osx.myr
new file mode 100644
index 0000000..62bc6f4
--- /dev/null
+++ b/libstd/syswrap-ss+posixy-osx.myr
@@ -0,0 +1,7 @@
+use sys
+
+pkg std =
+ const exit : (status:int -> void)
+;;
+
+const exit = {status; sys.exit(status)}