summaryrefslogtreecommitdiff
path: root/lib/sys
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-12-14 14:51:30 -0800
committerOri Bernstein <ori@eigenstate.org>2017-12-14 14:51:30 -0800
commit920b587c66cc2bb5169a117500deb9f8b00127fd (patch)
treefa78cd059c021511f87906a5fc66a7cc00b2750e /lib/sys
parent377381aa9dcdc3a004faac1b06aa79d0e4fa9c98 (diff)
downloadmc-920b587c66cc2bb5169a117500deb9f8b00127fd.tar.gz
Add atexit for 9front.
A tad ugly, but a start. Maybe we'll figure something better out soon.
Diffstat (limited to 'lib/sys')
-rw-r--r--lib/sys/sys+plan9-x64.myr17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/sys/sys+plan9-x64.myr b/lib/sys/sys+plan9-x64.myr
index 2a749ae..33541fe 100644
--- a/lib/sys/sys+plan9-x64.myr
+++ b/lib/sys/sys+plan9-x64.myr
@@ -169,8 +169,25 @@ pkg sys =
extern var tosptr : tos#
extern var curbrk : byte#
+
+ const atexit : (fn : (-> void) -> void)
+
+ pkglocal const __fini__ : (-> void)
;;
+var exitfn : (-> void)[128]
+var nexit : size
+
+const atexit = {fn
+ exitfn[nexit++] = fn
+}
+
+const __fini__ = {
+ for var i = 0; i < nexit; i++
+ exitfn[i]()
+ ;;
+}
+
/* asm stub from syscall.s */
extern const syscall : (scno : scno, args : ... -> int64)
/* asm stubs from util+plan9.s */