shithub: mc

ref: 74d91a0021de012908cfdb35fb61a1473a376130
dir: /lib/std/threadhooks.myr/

View raw version
use "die"

pkg std =
	type thrdata = struct
	;;

	pkglocal var lock	: (l : void# -> void)
	pkglocal var unlock	: (l : void# -> void)
	pkglocal var memlck	: void#
	pkglocal var netlck	: void#
	pkglocal var envlck	: void#

	const __lockinit	: ( \
		mem : void#, \
		net : void#, \
		env : void#, \
		lck : (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
*/
const __init__ = {
	lock = {l; }
	unlock = {l; }
	tlsget = {; -> thrptr}
	tlsset = {v; thrptr = v}
}

const __lockinit = {mem, net, env, lck, unlck, tlsget_, tlset_
	memlck = mem
	netlck = net
	envlck = env
	lock = lck
	unlock = unlck
	tlsget = tlsget_
	tlsget = tlsget_
}