summaryrefslogtreecommitdiff
path: root/lib/thread/spawn+freebsd.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-04-09 02:09:15 -0700
committerOri Bernstein <ori@eigenstate.org>2017-04-09 02:23:39 -0700
commit4078e565e99dfb4abf07df16f0317c85a6bca3f1 (patch)
treee4e955cfb9007391ff2872d734b4bc2521c493dd /lib/thread/spawn+freebsd.myr
parent73518d58457d543258e344b96a8f4b13ccd16882 (diff)
downloadmc-4078e565e99dfb4abf07df16f0317c85a6bca3f1.tar.gz
Duplicate env on thread spawn.
Diffstat (limited to 'lib/thread/spawn+freebsd.myr')
-rw-r--r--lib/thread/spawn+freebsd.myr7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/thread/spawn+freebsd.myr b/lib/thread/spawn+freebsd.myr
index 71ae87d..ebeb616 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
+ var szp, fp, tos, env, envsz
stk = getstk(sz)
if stk == sys.Mapbad
@@ -34,10 +34,13 @@ const spawnstk = {fn, sz
szp# = Stacksz
/* store the function we call */
+ envsz = std.fnenvsz(fn)
+ tos -= (envsz : std.intptr)
+ env = tos
tos -= sizeof((->void))
sz -= sizeof((->void))
fp = (tos : (->void)#)
- fp# = fn
+ fp# = std.fnbdup(fn, (env : byte#)[:envsz])
ret = sys.thr_new(&[
.startfn = (startthread : void#),