summaryrefslogtreecommitdiff
path: root/std/base.toc
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-07-03 18:49:28 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-07-03 18:49:28 -0400
commit8dd389a5f7db1c8ef9e60d900104fef99f25645f (patch)
tree74e07d438e3c30fed3cdb7eec50b37936c4cfc7f /std/base.toc
parent119950ebde3c9f096d1866ba6448d6bd9b22d063 (diff)
io is working but slow
Diffstat (limited to 'std/base.toc')
-rw-r--r--std/base.toc13
1 files changed, 13 insertions, 0 deletions
diff --git a/std/base.toc b/std/base.toc
index 54d64d6..950f817 100644
--- a/std/base.toc
+++ b/std/base.toc
@@ -23,4 +23,17 @@ PLATFORM ::= #builtin("platform");
PLATFORM_IS_UNIX :: bool = PLATFORM == PLATFORM_LINUX || PLATFORM == PLATFORM_OSX || PLATFORM == PLATFORM_FREEBSD
|| PLATFORM == PLATFORM_OPENBSD || PLATFORM == PLATFORM_MISC_UNIX;
+fwrite ::= #foreign("fwrite", libc) fn(#C &"const void", #C size_t, #C size_t, &void) #C size_t;
+stderr_write ::= fn(s: []char) {
+ fwrite(&s[0], 1, s.len as #C size_t, #builtin("stderr"));
+}
+
+exit ::= #foreign("exit", libc) fn(#C int);
+error ::= fn(s: []char) {
+ stderr_write("Fatal error: ");
+ stderr_write(s);
+ // @TODO: backtrace
+ stderr_write("\nExiting.\n");
+ exit(1);
+}