summaryrefslogtreecommitdiff
path: root/lib/thread/spawn+plan9.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-11-05 23:30:56 -0800
committerOri Bernstein <ori@eigenstate.org>2018-11-05 23:30:56 -0800
commitb4074b239d8dda2fccc500ee1467ed21987938e9 (patch)
tree67dde27e2d1eded6174e9586252e639bc5c00295 /lib/thread/spawn+plan9.myr
parent3821901ac0c5ef909818d887ffe3d4565ecd469d (diff)
downloadmc-b4074b239d8dda2fccc500ee1467ed21987938e9.tar.gz
TLS implementation for 9front.
Diffstat (limited to 'lib/thread/spawn+plan9.myr')
-rw-r--r--lib/thread/spawn+plan9.myr13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/thread/spawn+plan9.myr b/lib/thread/spawn+plan9.myr
index e577e7c..22b63f8 100644
--- a/lib/thread/spawn+plan9.myr
+++ b/lib/thread/spawn+plan9.myr
@@ -1,5 +1,6 @@
use std
use sys
+use "tls"
pkg thread =
type tid = uint64
@@ -8,11 +9,23 @@ pkg thread =
;;
const spawn = {fn
+ var p, s
+
fn = std.fndup(fn)
match sys.rfork(sys.Rfproc | sys.Rfmem)
| 0:
+ if ntlsslots > Staticcap
+ p = getpriv()
+ s = std.slalloc(ntlsslots)
+ p[0] = (s : void#)
+ ;;
fn()
std.fnfree(fn)
+ if ntlsslots > Staticcap
+ p = getpriv()
+ s = (p[0] : void##)[:ntlsslots]
+ std.slfree(s)
+ ;;
std.exit(0)
| -1:
std.fnfree(fn)