summaryrefslogtreecommitdiff
path: root/std/io.toc
diff options
context:
space:
mode:
Diffstat (limited to 'std/io.toc')
-rw-r--r--std/io.toc12
1 files changed, 8 insertions, 4 deletions
diff --git a/std/io.toc b/std/io.toc
index f864c3c..147834f 100644
--- a/std/io.toc
+++ b/std/io.toc
@@ -24,9 +24,13 @@ toc_putchar ::= fn(x: char) {
c_putchar(x as c_int);
};
+c_fwrite :: fn(&u8, c_size_t, c_size_t, &u8) = #foreign "fwrite", "libc.so.6";
+
+stdout_fwrite ::= fn(data: &u8, size: u64, nmemb: u64) {
+ c_fwrite(data, size as c_size_t, nmemb as c_size_t, #builtin("stdout"));
+};
+
#export puts ::= fn(x: []char) {
- for c := x {
- toc_putchar(c);
- };
- toc_putchar('\n');
+ stdout_fwrite(&x[0] as &u8, 1, x.len as u64);
+ toc_putchar('\n');
}; \ No newline at end of file