summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/arr.toc2
-rw-r--r--std/io.toc12
2 files changed, 9 insertions, 5 deletions
diff --git a/std/arr.toc b/std/arr.toc
index af89ecb..0e81f3a 100644
--- a/std/arr.toc
+++ b/std/arr.toc
@@ -20,7 +20,7 @@ pkg "arr";
a.len += 1;
};
-#export arr_forfor ::= fn(t ::=, a : Arr(t), f : fn(&t)) {
+#export arr_foreach ::= fn(t ::=, a : Arr(t), f : fn(&t)) {
for i := 0..a.len-1 {
f(&a.data[i]);
}
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