summaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-11-03 16:43:48 -0700
committerOri Bernstein <ori@eigenstate.org>2018-11-03 16:43:48 -0700
commit205416ed364a55ee1792123c2fd73c949600aa50 (patch)
treee0b879eb7a38cb9bd3637d4ede5121c65fbc634d /lib/std
parent183f3d40a1dbc2254f1e01de21eb022996f40ad2 (diff)
downloadmc-205416ed364a55ee1792123c2fd73c949600aa50.tar.gz
Add tls hooks to libstd.
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/threadhooks.myr17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/std/threadhooks.myr b/lib/std/threadhooks.myr
index 71f4d4c..9b04cf3 100644
--- a/lib/std/threadhooks.myr
+++ b/lib/std/threadhooks.myr
@@ -1,6 +1,9 @@
use "die"
pkg std =
+ type thrdata = struct
+ ;;
+
pkglocal var lock : (l : void# -> void)
pkglocal var unlock : (l : void# -> void)
pkglocal var memlck : void#
@@ -12,18 +15,24 @@ pkg std =
net : void#, \
env : void#, \
lck : (l : void# -> void), \
- unlck : (l : void# -> void) \
+ unlck : (l : void# -> void), \
+ tlsget : (-> thrdata#), \
+ tlsset : (v : thrdata# -> void) \
-> void)
;;
/* thread lock wrapper functions */
var lock
var unlock
+var tlsget
+var tlsset
/* locks for various parts of libstd */
var memlck
var netlck
var envlck
+var thrptr
+
/*
work around compiler bug: we don't generate
syms for the funcs with an initializer
@@ -31,13 +40,17 @@ syms for the funcs with an initializer
const __init__ = {
lock = {l; }
unlock = {l; }
+ tlsget = {; -> thrptr}
+ tlsset = {v; thrptr = v}
}
-const __lockinit = {mem, net, env, lck, unlck
+const __lockinit = {mem, net, env, lck, unlck, tlsget_, tlset_
memlck = mem
netlck = net
envlck = env
lock = lck
unlock = unlck
+ tlsget = tlsget_
+ tlsget = tlsget_
}