summaryrefslogtreecommitdiff
path: root/lib/thread
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-04-22 00:12:26 -0700
committerOri Bernstein <ori@eigenstate.org>2017-04-22 00:12:26 -0700
commit09d82f137706f80e53cdb12b12cd0e52217aeb57 (patch)
tree655b0024411baac31c3075281fedbab57122e004 /lib/thread
parentb0b7605bb866cccae5ea15cb9b8b18524ecc84d6 (diff)
downloadmc-09d82f137706f80e53cdb12b12cd0e52217aeb57.tar.gz
Reserve stack space for the environment.
We copied it, but then clobbered it. Shit.
Diffstat (limited to 'lib/thread')
-rw-r--r--lib/thread/spawn+freebsd.myr12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/thread/spawn+freebsd.myr b/lib/thread/spawn+freebsd.myr
index ebeb616..cdc7673 100644
--- a/lib/thread/spawn+freebsd.myr
+++ b/lib/thread/spawn+freebsd.myr
@@ -17,7 +17,7 @@ const spawn = {fn
const spawnstk = {fn, sz
var stk : byte#, tid, ctid, ret
- var szp, fp, tos, env, envsz
+ var szp, f, tos, env, envsz
stk = getstk(sz)
if stk == sys.Mapbad
@@ -36,11 +36,13 @@ const spawnstk = {fn, sz
/* store the function we call */
envsz = std.fnenvsz(fn)
tos -= (envsz : std.intptr)
+ sz -= (envsz : sys.size)
env = tos
tos -= sizeof((->void))
sz -= sizeof((->void))
- fp = (tos : (->void)#)
- fp# = std.fnbdup(fn, (env : byte#)[:envsz])
+ f = (tos : (->void)#)
+ f# = std.fnbdup(fn, (env : byte#)[:envsz])
+ var repr = (&fn : int64[2]#)#
ret = sys.thr_new(&[
.startfn = (startthread : void#),
@@ -70,8 +72,8 @@ const getstk = {sz
-> (m : byte#)
}
-const startthread = {fn : (-> void)#
- fn#()
+const startthread = {f : (-> void)#
+ f#()
exit()
}